| 
									
										
										
										
											2019-04-19 15:38:03 +09:00
										 |  |  | # frozen_string_literal: true | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-03 10:49:58 +02:00
										 |  |  | require_relative "shared_examples/requires_cask_token" | 
					
						
							|  |  |  | require_relative "shared_examples/invalid_option" | 
					
						
							| 
									
										
										
										
											2020-05-19 14:58:55 +05:30
										 |  |  | require "utils" | 
					
						
							| 
									
										
										
										
											2017-10-03 10:49:58 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-06 08:29:14 +02:00
										 |  |  | describe Cask::Cmd::Info, :cask do | 
					
						
							| 
									
										
										
										
											2017-10-03 10:49:58 +02:00
										 |  |  |   it_behaves_like "a command that requires a Cask token" | 
					
						
							|  |  |  |   it_behaves_like "a command that handles invalid options" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  |   it "displays some nice info about the specified Cask" do | 
					
						
							| 
									
										
										
										
											2017-02-08 12:19:51 +01:00
										 |  |  |     expect { | 
					
						
							| 
									
										
										
										
											2017-10-03 10:49:58 +02:00
										 |  |  |       described_class.run("local-caffeine") | 
					
						
							| 
									
										
										
										
											2017-10-15 02:28:32 +02:00
										 |  |  |     }.to output(<<~EOS).to_stdout | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  |       local-caffeine: 1.2.3
 | 
					
						
							| 
									
										
										
										
											2019-09-22 11:41:46 -04:00
										 |  |  |       https://brew.sh/ | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  |       Not installed | 
					
						
							| 
									
										
										
										
											2020-06-25 11:20:57 +01:00
										 |  |  |       From: https://github.com/Homebrew/homebrew-cask/blob/HEAD/Casks/local-caffeine.rb | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  |       ==> Name | 
					
						
							|  |  |  |       None | 
					
						
							|  |  |  |       ==> Artifacts | 
					
						
							| 
									
										
										
										
											2017-04-06 00:33:31 +02:00
										 |  |  |       Caffeine.app (App) | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  |     EOS | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-20 09:07:56 +01:00
										 |  |  |   it "prints auto_updates if the Cask has `auto_updates true`" do | 
					
						
							| 
									
										
										
										
											2018-06-15 16:16:55 +10:00
										 |  |  |     expect { | 
					
						
							|  |  |  |       described_class.run("with-auto-updates") | 
					
						
							|  |  |  |     }.to output(<<~EOS).to_stdout | 
					
						
							|  |  |  |       with-auto-updates: 1.0 (auto_updates) | 
					
						
							| 
									
										
										
										
											2018-11-28 20:51:55 +01:00
										 |  |  |       https://brew.sh/autoupdates | 
					
						
							| 
									
										
										
										
											2018-06-15 16:16:55 +10:00
										 |  |  |       Not installed | 
					
						
							| 
									
										
										
										
											2020-06-25 11:20:57 +01:00
										 |  |  |       From: https://github.com/Homebrew/homebrew-cask/blob/HEAD/Casks/with-auto-updates.rb | 
					
						
							| 
									
										
										
										
											2018-06-15 16:16:55 +10:00
										 |  |  |       ==> Name | 
					
						
							|  |  |  |       AutoUpdates | 
					
						
							|  |  |  |       ==> Artifacts | 
					
						
							|  |  |  |       AutoUpdates.app (App) | 
					
						
							|  |  |  |     EOS | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  |   describe "given multiple Casks" do | 
					
						
							| 
									
										
										
										
											2017-02-08 12:19:51 +01:00
										 |  |  |     let(:expected_output) { | 
					
						
							| 
									
										
										
										
											2017-10-15 02:28:32 +02:00
										 |  |  |       <<~EOS | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  |         local-caffeine: 1.2.3
 | 
					
						
							| 
									
										
										
										
											2019-09-22 11:41:46 -04:00
										 |  |  |         https://brew.sh/ | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  |         Not installed | 
					
						
							| 
									
										
										
										
											2020-06-25 11:20:57 +01:00
										 |  |  |         From: https://github.com/Homebrew/homebrew-cask/blob/HEAD/Casks/local-caffeine.rb | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  |         ==> Name | 
					
						
							|  |  |  |         None | 
					
						
							|  |  |  |         ==> Artifacts | 
					
						
							| 
									
										
										
										
											2017-04-06 00:33:31 +02:00
										 |  |  |         Caffeine.app (App) | 
					
						
							| 
									
										
										
										
											2019-05-13 18:59:45 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  |         local-transmission: 2.61
 | 
					
						
							| 
									
										
										
										
											2019-09-22 11:41:46 -04:00
										 |  |  |         https://brew.sh/ | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  |         Not installed | 
					
						
							| 
									
										
										
										
											2020-06-25 11:20:57 +01:00
										 |  |  |         From: https://github.com/Homebrew/homebrew-cask/blob/HEAD/Casks/local-transmission.rb | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  |         ==> Name | 
					
						
							| 
									
										
										
										
											2018-08-31 13:16:11 +00:00
										 |  |  |         Transmission | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  |         ==> Artifacts | 
					
						
							| 
									
										
										
										
											2017-04-06 00:33:31 +02:00
										 |  |  |         Transmission.app (App) | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  |       EOS | 
					
						
							| 
									
										
										
										
											2017-02-08 12:19:51 +01:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  |     it "displays the info" do | 
					
						
							| 
									
										
										
										
											2017-02-08 12:19:51 +01:00
										 |  |  |       expect { | 
					
						
							| 
									
										
										
										
											2017-10-03 10:49:58 +02:00
										 |  |  |         described_class.run("local-caffeine", "local-transmission") | 
					
						
							| 
									
										
										
										
											2017-02-08 12:19:51 +01:00
										 |  |  |       }.to output(expected_output).to_stdout | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-25 13:30:37 +01:00
										 |  |  |   it "prints caveats if the Cask provided one" do | 
					
						
							| 
									
										
										
										
											2017-02-08 12:19:51 +01:00
										 |  |  |     expect { | 
					
						
							| 
									
										
										
										
											2017-10-03 10:49:58 +02:00
										 |  |  |       described_class.run("with-caveats") | 
					
						
							| 
									
										
										
										
											2017-10-15 02:28:32 +02:00
										 |  |  |     }.to output(<<~EOS).to_stdout | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  |       with-caveats: 1.2.3
 | 
					
						
							| 
									
										
										
										
											2019-09-22 11:41:46 -04:00
										 |  |  |       https://brew.sh/ | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  |       Not installed | 
					
						
							| 
									
										
										
										
											2020-06-25 11:20:57 +01:00
										 |  |  |       From: https://github.com/Homebrew/homebrew-cask/blob/HEAD/Casks/with-caveats.rb | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  |       ==> Name | 
					
						
							|  |  |  |       None | 
					
						
							|  |  |  |       ==> Artifacts | 
					
						
							| 
									
										
										
										
											2017-04-06 00:33:31 +02:00
										 |  |  |       Caffeine.app (App) | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  |       ==> Caveats | 
					
						
							|  |  |  |       Here are some things you might want to know. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       Cask token: with-caveats | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       Custom text via puts followed by DSL-generated text: | 
					
						
							|  |  |  |       To use with-caveats, you may need to add the /custom/path/bin directory | 
					
						
							| 
									
										
										
										
											2019-04-08 12:47:15 -04:00
										 |  |  |       to your PATH environment variable, e.g. (for bash shell): | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  |         export PATH=/custom/path/bin:"$PATH" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     EOS | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-25 13:30:37 +01:00
										 |  |  |   it 'does not print "Caveats" section divider if the caveats block has no output' do | 
					
						
							| 
									
										
										
										
											2017-02-08 12:19:51 +01:00
										 |  |  |     expect { | 
					
						
							| 
									
										
										
										
											2017-10-03 10:49:58 +02:00
										 |  |  |       described_class.run("with-conditional-caveats") | 
					
						
							| 
									
										
										
										
											2017-10-15 02:28:32 +02:00
										 |  |  |     }.to output(<<~EOS).to_stdout | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  |       with-conditional-caveats: 1.2.3
 | 
					
						
							| 
									
										
										
										
											2019-09-22 11:41:46 -04:00
										 |  |  |       https://brew.sh/ | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  |       Not installed | 
					
						
							| 
									
										
										
										
											2020-06-25 11:20:57 +01:00
										 |  |  |       From: https://github.com/Homebrew/homebrew-cask/blob/HEAD/Casks/with-conditional-caveats.rb | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  |       ==> Name | 
					
						
							|  |  |  |       None | 
					
						
							|  |  |  |       ==> Artifacts | 
					
						
							| 
									
										
										
										
											2017-04-06 00:33:31 +02:00
										 |  |  |       Caffeine.app (App) | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  |     EOS | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-02 11:34:50 -07:00
										 |  |  |   it "prints languages specified in the Cask" do | 
					
						
							| 
									
										
										
										
											2017-09-27 00:17:47 -07:00
										 |  |  |     expect { | 
					
						
							| 
									
										
										
										
											2017-10-03 10:49:58 +02:00
										 |  |  |       described_class.run("with-languages") | 
					
						
							| 
									
										
										
										
											2017-10-15 02:28:32 +02:00
										 |  |  |     }.to output(<<~EOS).to_stdout | 
					
						
							| 
									
										
										
										
											2017-09-27 00:17:47 -07:00
										 |  |  |       with-languages: 1.2.3
 | 
					
						
							| 
									
										
										
										
											2019-09-22 11:41:46 -04:00
										 |  |  |       https://brew.sh/ | 
					
						
							| 
									
										
										
										
											2017-09-27 00:17:47 -07:00
										 |  |  |       Not installed | 
					
						
							| 
									
										
										
										
											2020-06-25 11:20:57 +01:00
										 |  |  |       From: https://github.com/Homebrew/homebrew-cask/blob/HEAD/Casks/with-languages.rb | 
					
						
							| 
									
										
										
										
											2017-09-27 00:17:47 -07:00
										 |  |  |       ==> Name | 
					
						
							|  |  |  |       None | 
					
						
							|  |  |  |       ==> Languages | 
					
						
							|  |  |  |       zh, en-US | 
					
						
							|  |  |  |       ==> Artifacts | 
					
						
							|  |  |  |       Caffeine.app (App) | 
					
						
							|  |  |  |     EOS | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-02 11:34:50 -07:00
										 |  |  |   it 'does not print "Languages" section divider if the languages block has no output' do | 
					
						
							| 
									
										
										
										
											2017-09-27 00:17:47 -07:00
										 |  |  |     expect { | 
					
						
							| 
									
										
										
										
											2017-10-03 10:49:58 +02:00
										 |  |  |       described_class.run("without-languages") | 
					
						
							| 
									
										
										
										
											2017-10-15 02:28:32 +02:00
										 |  |  |     }.to output(<<~EOS).to_stdout | 
					
						
							| 
									
										
										
										
											2017-10-02 11:34:50 -07:00
										 |  |  |       without-languages: 1.2.3
 | 
					
						
							| 
									
										
										
										
											2019-09-22 11:41:46 -04:00
										 |  |  |       https://brew.sh/ | 
					
						
							| 
									
										
										
										
											2017-09-27 00:17:47 -07:00
										 |  |  |       Not installed | 
					
						
							| 
									
										
										
										
											2020-06-25 11:20:57 +01:00
										 |  |  |       From: https://github.com/Homebrew/homebrew-cask/blob/HEAD/Casks/without-languages.rb | 
					
						
							| 
									
										
										
										
											2017-09-27 00:17:47 -07:00
										 |  |  |       ==> Name | 
					
						
							|  |  |  |       None | 
					
						
							|  |  |  |       ==> Artifacts | 
					
						
							|  |  |  |       Caffeine.app (App) | 
					
						
							|  |  |  |     EOS | 
					
						
							|  |  |  |   end | 
					
						
							| 
									
										
										
										
											2019-02-01 14:22:36 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-19 21:41:02 +05:30
										 |  |  |   it "can run be run with a url twice and returns analytics", :needs_network do | 
					
						
							| 
									
										
										
										
											2020-05-19 19:35:30 +05:30
										 |  |  |     analytics = { | 
					
						
							|  |  |  |       "analytics" => { | 
					
						
							|  |  |  |         "install" => { | 
					
						
							|  |  |  |           "30d" => { "docker" => 1000 }, "90d" => { "docker" => 2000 }, "365d" => { "docker" => 3000 } | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |       }, | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-05-19 17:25:16 +05:30
										 |  |  |     expect(Utils::Analytics).to receive(:formulae_brew_sh_json).twice.with("cask/docker.json") | 
					
						
							| 
									
										
										
										
											2020-05-19 19:35:30 +05:30
										 |  |  |     .and_return(analytics) | 
					
						
							| 
									
										
										
										
											2020-05-19 14:58:55 +05:30
										 |  |  |     expect { | 
					
						
							| 
									
										
										
										
											2019-02-01 14:22:36 -08:00
										 |  |  |       described_class.run("https://raw.githubusercontent.com/Homebrew/homebrew-cask" \ | 
					
						
							|  |  |  |                           "/d0b2c58652ae5eff20a7a4ac93292a08b250912b/Casks/docker.rb") | 
					
						
							|  |  |  |       described_class.run("https://raw.githubusercontent.com/Homebrew/homebrew-cask" \ | 
					
						
							|  |  |  |                           "/d0b2c58652ae5eff20a7a4ac93292a08b250912b/Casks/docker.rb") | 
					
						
							|  |  |  |     }.to output(<<~EOS).to_stdout | 
					
						
							|  |  |  |       ==> Downloading https://raw.githubusercontent.com/Homebrew/homebrew-cask/d0b2c58652ae5eff20a7a4ac93292a08b250912b/Casks/docker.rb. | 
					
						
							|  |  |  |       docker: 2.0.0.2-ce-mac81,30215 (auto_updates) | 
					
						
							|  |  |  |       https://www.docker.com/community-edition | 
					
						
							|  |  |  |       Not installed | 
					
						
							|  |  |  |       ==> Names | 
					
						
							|  |  |  |       Docker Community Edition | 
					
						
							|  |  |  |       Docker CE | 
					
						
							|  |  |  |       ==> Artifacts | 
					
						
							|  |  |  |       Docker.app (App) | 
					
						
							| 
									
										
										
										
											2020-05-17 02:51:57 +05:30
										 |  |  |       ==> Analytics | 
					
						
							| 
									
										
										
										
											2020-05-19 17:25:16 +05:30
										 |  |  |       install: 1,000 (30 days), 2,000 (90 days), 3,000 (365 days) | 
					
						
							| 
									
										
										
										
											2019-02-01 14:22:36 -08:00
										 |  |  |       ==> Downloading https://raw.githubusercontent.com/Homebrew/homebrew-cask/d0b2c58652ae5eff20a7a4ac93292a08b250912b/Casks/docker.rb. | 
					
						
							|  |  |  |       docker: 2.0.0.2-ce-mac81,30215 (auto_updates) | 
					
						
							|  |  |  |       https://www.docker.com/community-edition | 
					
						
							|  |  |  |       Not installed | 
					
						
							|  |  |  |       ==> Names | 
					
						
							|  |  |  |       Docker Community Edition | 
					
						
							|  |  |  |       Docker CE | 
					
						
							|  |  |  |       ==> Artifacts | 
					
						
							|  |  |  |       Docker.app (App) | 
					
						
							| 
									
										
										
										
											2020-05-17 02:51:57 +05:30
										 |  |  |       ==> Analytics | 
					
						
							| 
									
										
										
										
											2020-05-19 17:25:16 +05:30
										 |  |  |       install: 1,000 (30 days), 2,000 (90 days), 3,000 (365 days) | 
					
						
							| 
									
										
										
										
											2019-02-01 14:22:36 -08:00
										 |  |  |     EOS | 
					
						
							|  |  |  |   end | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  | end |