| 
									
										
										
										
											2017-05-24 21:07:50 +05:30
										 |  |  | require_relative "../../rubocops/options_cop" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | describe RuboCop::Cop::FormulaAudit::Options do | 
					
						
							|  |  |  |   subject(:cop) { described_class.new } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-21 03:12:50 +02:00
										 |  |  |   it "reports an offense when using the 32-bit option" do | 
					
						
							|  |  |  |     expect_offense(<<~RUBY) | 
					
						
							|  |  |  |       class Foo < Formula | 
					
						
							|  |  |  |         url 'http://example.com/foo-1.0.tgz' | 
					
						
							|  |  |  |         option "32-bit", "with 32-bit" | 
					
						
							|  |  |  |                 ^^^^^^ macOS has been 64-bit only since 10.6 so 32-bit options are deprecated. | 
					
						
							| 
									
										
										
										
											2017-05-24 21:07:50 +05:30
										 |  |  |       end | 
					
						
							| 
									
										
										
										
											2017-10-21 03:12:50 +02:00
										 |  |  |     RUBY | 
					
						
							| 
									
										
										
										
											2017-05-24 21:07:50 +05:30
										 |  |  |   end | 
					
						
							|  |  |  | end | 
					
						
							| 
									
										
										
										
											2017-07-14 21:11:53 +05:30
										 |  |  | 
 | 
					
						
							|  |  |  | describe RuboCop::Cop::FormulaAuditStrict::Options do | 
					
						
							|  |  |  |   subject(:cop) { described_class.new } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   context "When auditing options strictly" do | 
					
						
							|  |  |  |     it "with universal" do | 
					
						
							| 
									
										
										
										
											2017-10-21 03:12:50 +02:00
										 |  |  |       expect_offense(<<~RUBY) | 
					
						
							| 
									
										
										
										
											2017-07-14 21:11:53 +05:30
										 |  |  |         class Foo < Formula | 
					
						
							|  |  |  |           url 'http://example.com/foo-1.0.tgz' | 
					
						
							|  |  |  |           option :universal | 
					
						
							| 
									
										
										
										
											2017-10-21 03:12:50 +02:00
										 |  |  |           ^^^^^^^^^^^^^^^^^ macOS has been 64-bit only since 10.6 so universal options are deprecated. | 
					
						
							| 
									
										
										
										
											2017-07-14 21:11:53 +05:30
										 |  |  |         end | 
					
						
							| 
									
										
										
										
											2017-10-21 03:12:50 +02:00
										 |  |  |       RUBY | 
					
						
							| 
									
										
										
										
											2017-07-14 21:11:53 +05:30
										 |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     it "with deprecated options" do | 
					
						
							| 
									
										
										
										
											2017-10-21 03:12:50 +02:00
										 |  |  |       expect_offense(<<~RUBY) | 
					
						
							| 
									
										
										
										
											2017-07-14 21:11:53 +05:30
										 |  |  |         class Foo < Formula | 
					
						
							|  |  |  |           url 'http://example.com/foo-1.0.tgz' | 
					
						
							|  |  |  |           option :cxx11 | 
					
						
							|  |  |  |           option "examples", "with-examples" | 
					
						
							| 
									
										
										
										
											2017-10-21 03:12:50 +02:00
										 |  |  |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Options should begin with with/without. Migrate '--examples' with `deprecated_option`. | 
					
						
							| 
									
										
										
										
											2017-07-14 21:11:53 +05:30
										 |  |  |         end | 
					
						
							| 
									
										
										
										
											2017-10-21 03:12:50 +02:00
										 |  |  |       RUBY | 
					
						
							| 
									
										
										
										
											2017-07-14 21:11:53 +05:30
										 |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     it "with misc deprecated options" do | 
					
						
							| 
									
										
										
										
											2017-10-21 03:12:50 +02:00
										 |  |  |       expect_offense(<<~RUBY) | 
					
						
							| 
									
										
										
										
											2017-07-14 21:11:53 +05:30
										 |  |  |         class Foo < Formula | 
					
						
							|  |  |  |           url 'http://example.com/foo-1.0.tgz' | 
					
						
							|  |  |  |           option "without-check" | 
					
						
							| 
									
										
										
										
											2017-10-21 03:12:50 +02:00
										 |  |  |           ^^^^^^^^^^^^^^^^^^^^^^ Use '--without-test' instead of '--without-check'. Migrate '--without-check' with `deprecated_option`. | 
					
						
							| 
									
										
										
										
											2017-07-14 21:11:53 +05:30
										 |  |  |         end | 
					
						
							| 
									
										
										
										
											2017-10-21 03:12:50 +02:00
										 |  |  |       RUBY | 
					
						
							| 
									
										
										
										
											2017-07-14 21:11:53 +05:30
										 |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | end | 
					
						
							| 
									
										
										
										
											2017-07-15 13:34:16 +05:30
										 |  |  | 
 | 
					
						
							|  |  |  | describe RuboCop::Cop::NewFormulaAudit::Options do | 
					
						
							|  |  |  |   subject(:cop) { described_class.new } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   context "When auditing options for a new formula" do | 
					
						
							|  |  |  |     it "with deprecated options" do | 
					
						
							| 
									
										
										
										
											2017-10-21 03:12:50 +02:00
										 |  |  |       expect_offense(<<~RUBY) | 
					
						
							| 
									
										
										
										
											2017-07-15 13:34:16 +05:30
										 |  |  |         class Foo < Formula | 
					
						
							|  |  |  |           url 'http://example.com/foo-1.0.tgz' | 
					
						
							|  |  |  |           deprecated_option "examples" => "with-examples" | 
					
						
							| 
									
										
										
										
											2017-10-21 03:12:50 +02:00
										 |  |  |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ New Formula should not use `deprecated_option` | 
					
						
							| 
									
										
										
										
											2017-07-15 13:34:16 +05:30
										 |  |  |         end | 
					
						
							| 
									
										
										
										
											2017-10-21 03:12:50 +02:00
										 |  |  |       RUBY | 
					
						
							| 
									
										
										
										
											2017-07-15 13:34:16 +05:30
										 |  |  |     end | 
					
						
							| 
									
										
										
										
											2018-05-22 19:39:10 +10:00
										 |  |  | 
 | 
					
						
							|  |  |  |     it "with options" do | 
					
						
							|  |  |  |       expect_offense(<<~RUBY, "/homebrew-core/") | 
					
						
							|  |  |  |         class Foo < Formula | 
					
						
							|  |  |  |           url 'http://example.com/foo-1.0.tgz' | 
					
						
							|  |  |  |           option "with-examples" | 
					
						
							|  |  |  |           ^^^^^^^^^^^^^^^^^^^^^^ Formula should not have an `option` | 
					
						
							|  |  |  |         end | 
					
						
							|  |  |  |       RUBY | 
					
						
							|  |  |  |     end | 
					
						
							| 
									
										
										
										
											2017-07-15 13:34:16 +05:30
										 |  |  |   end | 
					
						
							|  |  |  | end |