aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/test/cask/cli/options_spec.rb
diff options
context:
space:
mode:
authorMarkus Reiter2017-03-05 06:31:36 +0100
committerMarkus Reiter2017-03-05 23:08:14 +0100
commit9fc6c7b2be300ff35dc52d80f4dc38d36d52ddc2 (patch)
tree43e99a683329471c1dc965dcc92daccb57df7e8d /Library/Homebrew/test/cask/cli/options_spec.rb
parent67ec76d1492fbb03959a782a85c4fb985d6a5884 (diff)
downloadbrew-9fc6c7b2be300ff35dc52d80f4dc38d36d52ddc2.tar.bz2
Move Cask specs into `brew tests`.
Diffstat (limited to 'Library/Homebrew/test/cask/cli/options_spec.rb')
-rw-r--r--Library/Homebrew/test/cask/cli/options_spec.rb138
1 files changed, 138 insertions, 0 deletions
diff --git a/Library/Homebrew/test/cask/cli/options_spec.rb b/Library/Homebrew/test/cask/cli/options_spec.rb
new file mode 100644
index 000000000..86933e27e
--- /dev/null
+++ b/Library/Homebrew/test/cask/cli/options_spec.rb
@@ -0,0 +1,138 @@
+describe Hbc::CLI, :cask do
+ it "supports setting the appdir" do
+ Hbc::CLI.process_options %w[help --appdir=/some/path/foo]
+
+ expect(Hbc.appdir).to eq(Pathname.new("/some/path/foo"))
+ end
+
+ it "supports setting the appdir from ENV" do
+ ENV["HOMEBREW_CASK_OPTS"] = "--appdir=/some/path/bar"
+
+ Hbc::CLI.process_options %w[help]
+
+ expect(Hbc.appdir).to eq(Pathname.new("/some/path/bar"))
+ end
+
+ it "supports setting the prefpanedir" do
+ Hbc::CLI.process_options %w[help --prefpanedir=/some/path/foo]
+
+ expect(Hbc.prefpanedir).to eq(Pathname.new("/some/path/foo"))
+ end
+
+ it "supports setting the prefpanedir from ENV" do
+ ENV["HOMEBREW_CASK_OPTS"] = "--prefpanedir=/some/path/bar"
+
+ Hbc::CLI.process_options %w[help]
+
+ expect(Hbc.prefpanedir).to eq(Pathname.new("/some/path/bar"))
+ end
+
+ it "supports setting the qlplugindir" do
+ Hbc::CLI.process_options %w[help --qlplugindir=/some/path/foo]
+
+ expect(Hbc.qlplugindir).to eq(Pathname.new("/some/path/foo"))
+ end
+
+ it "supports setting the qlplugindir from ENV" do
+ ENV["HOMEBREW_CASK_OPTS"] = "--qlplugindir=/some/path/bar"
+
+ Hbc::CLI.process_options %w[help]
+
+ expect(Hbc.qlplugindir).to eq(Pathname.new("/some/path/bar"))
+ end
+
+ it "supports setting the colorpickerdir" do
+ Hbc::CLI.process_options %w[help --colorpickerdir=/some/path/foo]
+
+ expect(Hbc.colorpickerdir).to eq(Pathname.new("/some/path/foo"))
+ end
+
+ it "supports setting the colorpickerdir from ENV" do
+ ENV["HOMEBREW_CASK_OPTS"] = "--colorpickerdir=/some/path/bar"
+
+ Hbc::CLI.process_options %w[help]
+
+ expect(Hbc.colorpickerdir).to eq(Pathname.new("/some/path/bar"))
+ end
+
+ it "supports setting the dictionarydir" do
+ Hbc::CLI.process_options %w[help --dictionarydir=/some/path/foo]
+
+ expect(Hbc.dictionarydir).to eq(Pathname.new("/some/path/foo"))
+ end
+
+ it "supports setting the dictionarydir from ENV" do
+ ENV["HOMEBREW_CASK_OPTS"] = "--dictionarydir=/some/path/bar"
+
+ Hbc::CLI.process_options %w[help]
+
+ expect(Hbc.dictionarydir).to eq(Pathname.new("/some/path/bar"))
+ end
+
+ it "supports setting the fontdir" do
+ Hbc::CLI.process_options %w[help --fontdir=/some/path/foo]
+
+ expect(Hbc.fontdir).to eq(Pathname.new("/some/path/foo"))
+ end
+
+ it "supports setting the fontdir from ENV" do
+ ENV["HOMEBREW_CASK_OPTS"] = "--fontdir=/some/path/bar"
+
+ Hbc::CLI.process_options %w[help]
+
+ expect(Hbc.fontdir).to eq(Pathname.new("/some/path/bar"))
+ end
+
+ it "supports setting the servicedir" do
+ Hbc::CLI.process_options %w[help --servicedir=/some/path/foo]
+
+ expect(Hbc.servicedir).to eq(Pathname.new("/some/path/foo"))
+ end
+
+ it "supports setting the servicedir from ENV" do
+ ENV["HOMEBREW_CASK_OPTS"] = "--servicedir=/some/path/bar"
+
+ Hbc::CLI.process_options %w[help]
+
+ expect(Hbc.servicedir).to eq(Pathname.new("/some/path/bar"))
+ end
+
+ it "allows additional options to be passed through" do
+ rest = Hbc::CLI.process_options %w[edit foo --create --appdir=/some/path/qux]
+
+ expect(Hbc.appdir).to eq(Pathname.new("/some/path/qux"))
+ expect(rest).to eq(%w[edit foo --create])
+ end
+
+ describe "when a mandatory argument is missing" do
+ it "shows a user-friendly error message" do
+ expect {
+ Hbc::CLI.process_options %w[install -f]
+ }.to raise_error(Hbc::CaskError)
+ end
+ end
+
+ describe "given an ambiguous option" do
+ it "shows a user-friendly error message" do
+ expect {
+ Hbc::CLI.process_options %w[edit -c]
+ }.to raise_error(Hbc::CaskError)
+ end
+ end
+
+ describe "--debug" do
+ it "sets the Cask debug method to true" do
+ Hbc::CLI.process_options %w[help --debug]
+ expect(Hbc.debug).to be true
+ Hbc.debug = false
+ end
+ end
+
+ describe "--help" do
+ it "sets the Cask help method to true" do
+ Hbc::CLI.process_options %w[foo --help]
+ expect(Hbc.help).to be true
+ Hbc.help = false
+ end
+ end
+end