| 
									
										
										
										
											2018-09-06 08:29:14 +02:00
										 |  |  | describe Cask::Cmd, :cask do | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  |   it "supports setting the appdir" do | 
					
						
							| 
									
										
										
										
											2018-09-06 08:29:14 +02:00
										 |  |  |     allow(Cask::Config.global).to receive(:appdir).and_call_original | 
					
						
							| 
									
										
										
										
											2017-12-03 09:06:23 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-03 10:49:58 +02:00
										 |  |  |     described_class.new.process_options("help", "--appdir=/some/path/foo") | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-06 08:29:14 +02:00
										 |  |  |     expect(Cask::Config.global.appdir).to eq(Pathname.new("/some/path/foo")) | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   it "supports setting the appdir from ENV" do | 
					
						
							| 
									
										
										
										
											2018-09-06 08:29:14 +02:00
										 |  |  |     allow(Cask::Config.global).to receive(:appdir).and_call_original | 
					
						
							| 
									
										
										
										
											2017-12-03 09:06:23 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  |     ENV["HOMEBREW_CASK_OPTS"] = "--appdir=/some/path/bar" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-03 10:49:58 +02:00
										 |  |  |     described_class.new.process_options("help") | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-06 08:29:14 +02:00
										 |  |  |     expect(Cask::Config.global.appdir).to eq(Pathname.new("/some/path/bar")) | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   it "supports setting the prefpanedir" do | 
					
						
							| 
									
										
										
										
											2018-09-06 08:29:14 +02:00
										 |  |  |     allow(Cask::Config.global).to receive(:prefpanedir).and_call_original | 
					
						
							| 
									
										
										
										
											2017-12-03 09:06:23 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-03 10:49:58 +02:00
										 |  |  |     described_class.new.process_options("help", "--prefpanedir=/some/path/foo") | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-06 08:29:14 +02:00
										 |  |  |     expect(Cask::Config.global.prefpanedir).to eq(Pathname.new("/some/path/foo")) | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   it "supports setting the prefpanedir from ENV" do | 
					
						
							| 
									
										
										
										
											2018-09-06 08:29:14 +02:00
										 |  |  |     allow(Cask::Config.global).to receive(:prefpanedir).and_call_original | 
					
						
							| 
									
										
										
										
											2017-12-03 09:06:23 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  |     ENV["HOMEBREW_CASK_OPTS"] = "--prefpanedir=/some/path/bar" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-03 10:49:58 +02:00
										 |  |  |     described_class.new.process_options("help") | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-06 08:29:14 +02:00
										 |  |  |     expect(Cask::Config.global.prefpanedir).to eq(Pathname.new("/some/path/bar")) | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   it "supports setting the qlplugindir" do | 
					
						
							| 
									
										
										
										
											2018-09-06 08:29:14 +02:00
										 |  |  |     allow(Cask::Config.global).to receive(:qlplugindir).and_call_original | 
					
						
							| 
									
										
										
										
											2017-12-03 09:06:23 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-03 10:49:58 +02:00
										 |  |  |     described_class.new.process_options("help", "--qlplugindir=/some/path/foo") | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-06 08:29:14 +02:00
										 |  |  |     expect(Cask::Config.global.qlplugindir).to eq(Pathname.new("/some/path/foo")) | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   it "supports setting the qlplugindir from ENV" do | 
					
						
							| 
									
										
										
										
											2018-09-06 08:29:14 +02:00
										 |  |  |     allow(Cask::Config.global).to receive(:qlplugindir).and_call_original | 
					
						
							| 
									
										
										
										
											2017-12-03 09:06:23 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  |     ENV["HOMEBREW_CASK_OPTS"] = "--qlplugindir=/some/path/bar" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-03 10:49:58 +02:00
										 |  |  |     described_class.new.process_options("help") | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-06 08:29:14 +02:00
										 |  |  |     expect(Cask::Config.global.qlplugindir).to eq(Pathname.new("/some/path/bar")) | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   it "supports setting the colorpickerdir" do | 
					
						
							| 
									
										
										
										
											2018-09-06 08:29:14 +02:00
										 |  |  |     allow(Cask::Config.global).to receive(:colorpickerdir).and_call_original | 
					
						
							| 
									
										
										
										
											2017-12-03 09:06:23 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-03 10:49:58 +02:00
										 |  |  |     described_class.new.process_options("help", "--colorpickerdir=/some/path/foo") | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-06 08:29:14 +02:00
										 |  |  |     expect(Cask::Config.global.colorpickerdir).to eq(Pathname.new("/some/path/foo")) | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   it "supports setting the colorpickerdir from ENV" do | 
					
						
							| 
									
										
										
										
											2018-09-06 08:29:14 +02:00
										 |  |  |     allow(Cask::Config.global).to receive(:colorpickerdir).and_call_original | 
					
						
							| 
									
										
										
										
											2017-12-03 09:06:23 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  |     ENV["HOMEBREW_CASK_OPTS"] = "--colorpickerdir=/some/path/bar" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-03 10:49:58 +02:00
										 |  |  |     described_class.new.process_options("help") | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-06 08:29:14 +02:00
										 |  |  |     expect(Cask::Config.global.colorpickerdir).to eq(Pathname.new("/some/path/bar")) | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-23 17:32:19 +02:00
										 |  |  |   it "supports setting the dictionarydir" do | 
					
						
							| 
									
										
										
										
											2018-09-06 08:29:14 +02:00
										 |  |  |     allow(Cask::Config.global).to receive(:dictionarydir).and_call_original | 
					
						
							| 
									
										
										
										
											2017-12-03 09:06:23 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-03 10:49:58 +02:00
										 |  |  |     described_class.new.process_options("help", "--dictionarydir=/some/path/foo") | 
					
						
							| 
									
										
										
										
											2016-10-23 17:32:19 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-06 08:29:14 +02:00
										 |  |  |     expect(Cask::Config.global.dictionarydir).to eq(Pathname.new("/some/path/foo")) | 
					
						
							| 
									
										
										
										
											2016-10-23 17:32:19 +02:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   it "supports setting the dictionarydir from ENV" do | 
					
						
							| 
									
										
										
										
											2018-09-06 08:29:14 +02:00
										 |  |  |     allow(Cask::Config.global).to receive(:dictionarydir).and_call_original | 
					
						
							| 
									
										
										
										
											2017-12-03 09:06:23 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-23 17:32:19 +02:00
										 |  |  |     ENV["HOMEBREW_CASK_OPTS"] = "--dictionarydir=/some/path/bar" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-03 10:49:58 +02:00
										 |  |  |     described_class.new.process_options("help") | 
					
						
							| 
									
										
										
										
											2016-10-23 17:32:19 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-06 08:29:14 +02:00
										 |  |  |     expect(Cask::Config.global.dictionarydir).to eq(Pathname.new("/some/path/bar")) | 
					
						
							| 
									
										
										
										
											2016-10-23 17:32:19 +02:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  |   it "supports setting the fontdir" do | 
					
						
							| 
									
										
										
										
											2018-09-06 08:29:14 +02:00
										 |  |  |     allow(Cask::Config.global).to receive(:fontdir).and_call_original | 
					
						
							| 
									
										
										
										
											2017-12-03 09:06:23 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-03 10:49:58 +02:00
										 |  |  |     described_class.new.process_options("help", "--fontdir=/some/path/foo") | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-06 08:29:14 +02:00
										 |  |  |     expect(Cask::Config.global.fontdir).to eq(Pathname.new("/some/path/foo")) | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   it "supports setting the fontdir from ENV" do | 
					
						
							| 
									
										
										
										
											2018-09-06 08:29:14 +02:00
										 |  |  |     allow(Cask::Config.global).to receive(:fontdir).and_call_original | 
					
						
							| 
									
										
										
										
											2017-12-03 09:06:23 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  |     ENV["HOMEBREW_CASK_OPTS"] = "--fontdir=/some/path/bar" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-03 10:49:58 +02:00
										 |  |  |     described_class.new.process_options("help") | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-06 08:29:14 +02:00
										 |  |  |     expect(Cask::Config.global.fontdir).to eq(Pathname.new("/some/path/bar")) | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   it "supports setting the servicedir" do | 
					
						
							| 
									
										
										
										
											2018-09-06 08:29:14 +02:00
										 |  |  |     allow(Cask::Config.global).to receive(:servicedir).and_call_original | 
					
						
							| 
									
										
										
										
											2017-12-03 09:06:23 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-03 10:49:58 +02:00
										 |  |  |     described_class.new.process_options("help", "--servicedir=/some/path/foo") | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-06 08:29:14 +02:00
										 |  |  |     expect(Cask::Config.global.servicedir).to eq(Pathname.new("/some/path/foo")) | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   it "supports setting the servicedir from ENV" do | 
					
						
							| 
									
										
										
										
											2018-09-06 08:29:14 +02:00
										 |  |  |     allow(Cask::Config.global).to receive(:servicedir).and_call_original | 
					
						
							| 
									
										
										
										
											2017-12-03 09:06:23 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  |     ENV["HOMEBREW_CASK_OPTS"] = "--servicedir=/some/path/bar" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-03 10:49:58 +02:00
										 |  |  |     described_class.new.process_options("help") | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-06 08:29:14 +02:00
										 |  |  |     expect(Cask::Config.global.servicedir).to eq(Pathname.new("/some/path/bar")) | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   it "allows additional options to be passed through" do | 
					
						
							| 
									
										
										
										
											2018-09-06 08:29:14 +02:00
										 |  |  |     allow(Cask::Config.global).to receive(:appdir).and_call_original | 
					
						
							| 
									
										
										
										
											2017-12-03 09:06:23 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-03 10:49:58 +02:00
										 |  |  |     rest = described_class.new.process_options("edit", "foo", "--create", "--appdir=/some/path/qux") | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-06 08:29:14 +02:00
										 |  |  |     expect(Cask::Config.global.appdir).to eq(Pathname.new("/some/path/qux")) | 
					
						
							| 
									
										
										
										
											2017-02-08 13:25:10 +01:00
										 |  |  |     expect(rest).to eq(%w[edit foo --create]) | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   describe "--help" do | 
					
						
							|  |  |  |     it "sets the Cask help method to true" do | 
					
						
							| 
									
										
										
										
											2017-10-03 10:49:58 +02:00
										 |  |  |       command = described_class.new("foo", "--help") | 
					
						
							| 
									
										
										
										
											2017-05-21 02:32:46 +02:00
										 |  |  |       expect(command.help?).to be true | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | end |