| 
									
										
										
										
											2017-09-04 13:47:05 +05:30
										 |  |  | require_relative "../../rubocops/class_cop" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | describe RuboCop::Cop::FormulaAudit::ClassName do | 
					
						
							|  |  |  |   subject(:cop) { described_class.new } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-21 03:12:50 +02:00
										 |  |  |   it "reports an offense when using ScriptFileFormula" do | 
					
						
							|  |  |  |     expect_offense(<<~RUBY) | 
					
						
							|  |  |  |       class Foo < ScriptFileFormula | 
					
						
							|  |  |  |                   ^^^^^^^^^^^^^^^^^ ScriptFileFormula is deprecated, use Formula instead | 
					
						
							|  |  |  |         url 'http://example.com/foo-1.0.tgz' | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  |     RUBY | 
					
						
							|  |  |  |   end | 
					
						
							| 
									
										
										
										
											2017-09-04 13:47:05 +05:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-21 03:12:50 +02:00
										 |  |  |   it "reports an offense when using GithubGistFormula" do | 
					
						
							|  |  |  |     expect_offense(<<~RUBY) | 
					
						
							|  |  |  |       class Foo < GithubGistFormula | 
					
						
							|  |  |  |                   ^^^^^^^^^^^^^^^^^ GithubGistFormula is deprecated, use Formula instead | 
					
						
							|  |  |  |         url 'http://example.com/foo-1.0.tgz' | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  |     RUBY | 
					
						
							|  |  |  |   end | 
					
						
							| 
									
										
										
										
											2017-09-04 13:47:05 +05:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-21 03:12:50 +02:00
										 |  |  |   it "reports an offense when using AmazonWebServicesFormula" do | 
					
						
							|  |  |  |     expect_offense(<<~RUBY) | 
					
						
							|  |  |  |       class Foo < AmazonWebServicesFormula | 
					
						
							|  |  |  |                   ^^^^^^^^^^^^^^^^^^^^^^^^ AmazonWebServicesFormula is deprecated, use Formula instead | 
					
						
							|  |  |  |         url 'http://example.com/foo-1.0.tgz' | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  |     RUBY | 
					
						
							|  |  |  |   end | 
					
						
							| 
									
										
										
										
											2017-09-04 13:47:05 +05:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-21 03:12:50 +02:00
										 |  |  |   it "supports auto-correcting deprecated parent classes" do | 
					
						
							| 
									
										
										
										
											2018-07-11 15:17:40 +02:00
										 |  |  |     source = <<~RUBY | 
					
						
							| 
									
										
										
										
											2017-10-21 03:12:50 +02:00
										 |  |  |       class Foo < AmazonWebServicesFormula | 
					
						
							|  |  |  |         url 'http://example.com/foo-1.0.tgz' | 
					
						
							| 
									
										
										
										
											2017-09-04 13:47:05 +05:30
										 |  |  |       end | 
					
						
							| 
									
										
										
										
											2018-07-11 15:17:40 +02:00
										 |  |  |     RUBY | 
					
						
							| 
									
										
										
										
											2017-09-04 13:47:05 +05:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-11 15:17:40 +02:00
										 |  |  |     corrected_source = <<~RUBY | 
					
						
							| 
									
										
										
										
											2017-10-21 03:12:50 +02:00
										 |  |  |       class Foo < Formula | 
					
						
							|  |  |  |         url 'http://example.com/foo-1.0.tgz' | 
					
						
							|  |  |  |       end | 
					
						
							| 
									
										
										
										
											2018-07-11 15:17:40 +02:00
										 |  |  |     RUBY | 
					
						
							| 
									
										
										
										
											2017-09-04 13:47:05 +05:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-21 03:12:50 +02:00
										 |  |  |     new_source = autocorrect_source(source) | 
					
						
							|  |  |  |     expect(new_source).to eq(corrected_source) | 
					
						
							| 
									
										
										
										
											2017-09-04 13:47:05 +05:30
										 |  |  |   end | 
					
						
							|  |  |  | end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | describe RuboCop::Cop::FormulaAuditStrict::Test do | 
					
						
							|  |  |  |   subject(:cop) { described_class.new } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-21 03:12:50 +02:00
										 |  |  |   it "reports an offense when there is no test block" do | 
					
						
							|  |  |  |     expect_offense(<<~RUBY) | 
					
						
							|  |  |  |       class Foo < Formula | 
					
						
							|  |  |  |       ^^^^^^^^^^^^^^^^^^^ A `test do` test block should be added | 
					
						
							|  |  |  |         url 'http://example.com/foo-1.0.tgz' | 
					
						
							| 
									
										
										
										
											2017-09-04 13:47:05 +05:30
										 |  |  |       end | 
					
						
							| 
									
										
										
										
											2017-10-21 03:12:50 +02:00
										 |  |  |     RUBY | 
					
						
							| 
									
										
										
										
											2017-09-04 13:47:05 +05:30
										 |  |  |   end | 
					
						
							|  |  |  | end |