| 
									
										
										
										
											2019-04-19 15:38:03 +09:00
										 |  |  | # frozen_string_literal: true | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-18 17:02:08 +02:00
										 |  |  | require "missing_formula" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | describe Homebrew::MissingFormula do | 
					
						
							| 
									
										
										
										
											2018-04-14 01:39:00 +02:00
										 |  |  |   describe "::reason" do | 
					
						
							| 
									
										
										
										
											2017-03-18 17:02:08 +02:00
										 |  |  |     subject { described_class.reason("gem") } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-25 13:30:37 +01:00
										 |  |  |     it { is_expected.not_to be_nil } | 
					
						
							| 
									
										
										
										
											2017-03-18 17:02:08 +02:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-14 01:39:00 +02:00
										 |  |  |   describe "::blacklisted_reason" do | 
					
						
							| 
									
										
										
										
											2019-03-28 19:16:56 +00:00
										 |  |  |     matcher :blacklist do |name| | 
					
						
							| 
									
										
										
										
											2018-03-27 10:58:25 +02:00
										 |  |  |       match do |expected| | 
					
						
							| 
									
										
										
										
											2019-03-28 19:16:56 +00:00
										 |  |  |         expected.blacklisted_reason(name) | 
					
						
							| 
									
										
										
										
											2018-03-27 10:58:25 +02:00
										 |  |  |       end | 
					
						
							| 
									
										
										
										
											2017-03-18 17:02:08 +02:00
										 |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-28 19:16:56 +00:00
										 |  |  |     it { is_expected.to blacklist("gem") } | 
					
						
							|  |  |  |     it { is_expected.to blacklist("latex") } | 
					
						
							|  |  |  |     it { is_expected.to blacklist("pip") } | 
					
						
							|  |  |  |     it { is_expected.to blacklist("pil") } | 
					
						
							|  |  |  |     it { is_expected.to blacklist("macruby") } | 
					
						
							|  |  |  |     it { is_expected.to blacklist("lzma") } | 
					
						
							|  |  |  |     it { is_expected.to blacklist("gtest") } | 
					
						
							|  |  |  |     it { is_expected.to blacklist("gmock") } | 
					
						
							|  |  |  |     it { is_expected.to blacklist("sshpass") } | 
					
						
							|  |  |  |     it { is_expected.to blacklist("gsutil") } | 
					
						
							|  |  |  |     it { is_expected.to blacklist("gfortran") } | 
					
						
							|  |  |  |     it { is_expected.to blacklist("play") } | 
					
						
							|  |  |  |     it { is_expected.to blacklist("haskell-platform") } | 
					
						
							|  |  |  |     it { is_expected.to blacklist("mysqldump-secure") } | 
					
						
							|  |  |  |     it { is_expected.to blacklist("ngrok") } | 
					
						
							|  |  |  |     it("blacklists Xcode", :needs_macos) { is_expected.to blacklist("xcode") } | 
					
						
							| 
									
										
										
										
											2017-03-18 17:02:08 +02:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2017-03-20 20:37:12 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-14 01:39:00 +02:00
										 |  |  |   describe "::tap_migration_reason" do | 
					
						
							| 
									
										
										
										
											2017-03-20 20:37:12 +01:00
										 |  |  |     subject { described_class.tap_migration_reason(formula) } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     before do | 
					
						
							|  |  |  |       Tap.clear_cache | 
					
						
							|  |  |  |       tap_path = Tap::TAP_DIRECTORY/"homebrew/homebrew-foo" | 
					
						
							|  |  |  |       tap_path.mkpath | 
					
						
							| 
									
										
										
										
											2018-07-11 15:17:40 +02:00
										 |  |  |       (tap_path/"tap_migrations.json").write <<~JSON | 
					
						
							| 
									
										
										
										
											2017-03-20 20:37:12 +01:00
										 |  |  |         { "migrated-formula": "homebrew/bar" } | 
					
						
							| 
									
										
										
										
											2018-07-11 15:17:40 +02:00
										 |  |  |       JSON | 
					
						
							| 
									
										
										
										
											2017-03-20 20:37:12 +01:00
										 |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     context "with a migrated formula" do | 
					
						
							|  |  |  |       let(:formula) { "migrated-formula" } | 
					
						
							| 
									
										
										
										
											2018-03-25 13:30:37 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |       it { is_expected.not_to be_nil } | 
					
						
							| 
									
										
										
										
											2017-03-20 20:37:12 +01:00
										 |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     context "with a missing formula" do | 
					
						
							|  |  |  |       let(:formula) { "missing-formula" } | 
					
						
							| 
									
										
										
										
											2018-03-25 13:30:37 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-20 20:37:12 +01:00
										 |  |  |       it { is_expected.to be_nil } | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-14 01:39:00 +02:00
										 |  |  |   describe "::deleted_reason" do | 
					
						
							| 
									
										
										
										
											2017-04-22 12:26:18 +01:00
										 |  |  |     subject { described_class.deleted_reason(formula, silent: true) } | 
					
						
							| 
									
										
										
										
											2017-03-20 20:37:12 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     before do | 
					
						
							|  |  |  |       Tap.clear_cache | 
					
						
							|  |  |  |       tap_path = Tap::TAP_DIRECTORY/"homebrew/homebrew-foo" | 
					
						
							|  |  |  |       tap_path.mkpath | 
					
						
							|  |  |  |       (tap_path/"deleted-formula.rb").write "placeholder" | 
					
						
							| 
									
										
										
										
											2017-12-30 21:18:02 +00:00
										 |  |  |       ENV.delete "GIT_AUTHOR_DATE" | 
					
						
							|  |  |  |       ENV.delete "GIT_COMMITTER_DATE" | 
					
						
							| 
									
										
										
										
											2017-03-20 20:37:12 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |       tap_path.cd do | 
					
						
							| 
									
										
										
										
											2017-07-29 19:55:05 +02:00
										 |  |  |         system "git", "init" | 
					
						
							|  |  |  |         system "git", "add", "--all" | 
					
						
							|  |  |  |         system "git", "commit", "-m", "initial state" | 
					
						
							|  |  |  |         system "git", "rm", "deleted-formula.rb" | 
					
						
							|  |  |  |         system "git", "commit", "-m", "delete formula 'deleted-formula'" | 
					
						
							| 
									
										
										
										
											2017-03-20 20:37:12 +01:00
										 |  |  |       end | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     context "with a deleted formula" do | 
					
						
							|  |  |  |       let(:formula) { "homebrew/foo/deleted-formula" } | 
					
						
							| 
									
										
										
										
											2018-03-25 13:30:37 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |       it { is_expected.not_to be_nil } | 
					
						
							| 
									
										
										
										
											2017-03-20 20:37:12 +01:00
										 |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     context "with a formula that never existed" do | 
					
						
							|  |  |  |       let(:formula) { "homebrew/foo/missing-formula" } | 
					
						
							| 
									
										
										
										
											2018-03-25 13:30:37 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-20 20:37:12 +01:00
										 |  |  |       it { is_expected.to be_nil } | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							| 
									
										
										
										
											2019-03-21 17:18:21 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |   describe "::cask_reason", :cask do | 
					
						
							| 
									
										
										
										
											2019-03-24 15:28:34 -04:00
										 |  |  |     subject { described_class.cask_reason(formula, show_info: show_info) } | 
					
						
							| 
									
										
										
										
											2019-03-21 17:18:21 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-24 15:28:34 -04:00
										 |  |  |     context "with a formula name that is a cask and show_info: false" do | 
					
						
							| 
									
										
										
										
											2019-03-21 17:18:21 -04:00
										 |  |  |       let(:formula) { "local-caffeine" } | 
					
						
							| 
									
										
										
										
											2019-03-24 15:28:34 -04:00
										 |  |  |       let(:show_info) { false } | 
					
						
							| 
									
										
										
										
											2019-03-21 17:18:21 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-24 15:28:34 -04:00
										 |  |  |       it { is_expected.to match(/Found a cask named "local-caffeine" instead./) } | 
					
						
							| 
									
										
										
										
											2019-03-21 17:18:21 -04:00
										 |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-24 15:28:34 -04:00
										 |  |  |     context "with a formula name that is a cask and show_info: true" do | 
					
						
							|  |  |  |       let(:formula) { "local-caffeine" } | 
					
						
							|  |  |  |       let(:show_info) { true } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       it { is_expected.to match(/Found a cask named "local-caffeine" instead.\nlocal-caffeine: 1.2.3\n/) } | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     context "with a formula name that is not a cask" do | 
					
						
							| 
									
										
										
										
											2019-03-21 17:18:21 -04:00
										 |  |  |       let(:formula) { "missing-formula" } | 
					
						
							| 
									
										
										
										
											2019-03-24 15:28:34 -04:00
										 |  |  |       let(:show_info) { false } | 
					
						
							| 
									
										
										
										
											2019-03-21 17:18:21 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |       it { is_expected.to be_nil } | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							| 
									
										
										
										
											2017-03-18 17:02:08 +02:00
										 |  |  | end |