aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/test/cask/cli/options_spec.rb
diff options
context:
space:
mode:
authorMarkus Reiter2017-05-21 02:32:46 +0200
committerMarkus Reiter2017-05-22 02:51:17 +0200
commit02a1e2781fcb808b731fd04d18369ec5bfd3bc68 (patch)
tree8328ec31ac14351eeb8a231f4b932bc9f8221468 /Library/Homebrew/test/cask/cli/options_spec.rb
parentdf1864ee435c1c48f87344800d2e7cf055a12f93 (diff)
downloadbrew-02a1e2781fcb808b731fd04d18369ec5bfd3bc68.tar.bz2
Fix tests for `CLI::Options` DSL.
Diffstat (limited to 'Library/Homebrew/test/cask/cli/options_spec.rb')
-rw-r--r--Library/Homebrew/test/cask/cli/options_spec.rb54
1 files changed, 17 insertions, 37 deletions
diff --git a/Library/Homebrew/test/cask/cli/options_spec.rb b/Library/Homebrew/test/cask/cli/options_spec.rb
index eb0bf1a49..98eb05f7e 100644
--- a/Library/Homebrew/test/cask/cli/options_spec.rb
+++ b/Library/Homebrew/test/cask/cli/options_spec.rb
@@ -1,6 +1,6 @@
describe Hbc::CLI, :cask do
it "supports setting the appdir" do
- Hbc::CLI.process_options %w[help --appdir=/some/path/foo]
+ Hbc::CLI.new.process_options("help", "--appdir=/some/path/foo")
expect(Hbc.appdir).to eq(Pathname.new("/some/path/foo"))
end
@@ -8,13 +8,13 @@ describe Hbc::CLI, :cask do
it "supports setting the appdir from ENV" do
ENV["HOMEBREW_CASK_OPTS"] = "--appdir=/some/path/bar"
- Hbc::CLI.process_options %w[help]
+ Hbc::CLI.new.process_options("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]
+ Hbc::CLI.new.process_options("help", "--prefpanedir=/some/path/foo")
expect(Hbc.prefpanedir).to eq(Pathname.new("/some/path/foo"))
end
@@ -22,13 +22,13 @@ describe Hbc::CLI, :cask do
it "supports setting the prefpanedir from ENV" do
ENV["HOMEBREW_CASK_OPTS"] = "--prefpanedir=/some/path/bar"
- Hbc::CLI.process_options %w[help]
+ Hbc::CLI.new.process_options("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]
+ Hbc::CLI.new.process_options("help", "--qlplugindir=/some/path/foo")
expect(Hbc.qlplugindir).to eq(Pathname.new("/some/path/foo"))
end
@@ -36,13 +36,13 @@ describe Hbc::CLI, :cask do
it "supports setting the qlplugindir from ENV" do
ENV["HOMEBREW_CASK_OPTS"] = "--qlplugindir=/some/path/bar"
- Hbc::CLI.process_options %w[help]
+ Hbc::CLI.new.process_options("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]
+ Hbc::CLI.new.process_options("help", "--colorpickerdir=/some/path/foo")
expect(Hbc.colorpickerdir).to eq(Pathname.new("/some/path/foo"))
end
@@ -50,13 +50,13 @@ describe Hbc::CLI, :cask do
it "supports setting the colorpickerdir from ENV" do
ENV["HOMEBREW_CASK_OPTS"] = "--colorpickerdir=/some/path/bar"
- Hbc::CLI.process_options %w[help]
+ Hbc::CLI.new.process_options("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]
+ Hbc::CLI.new.process_options("help", "--dictionarydir=/some/path/foo")
expect(Hbc.dictionarydir).to eq(Pathname.new("/some/path/foo"))
end
@@ -64,13 +64,13 @@ describe Hbc::CLI, :cask do
it "supports setting the dictionarydir from ENV" do
ENV["HOMEBREW_CASK_OPTS"] = "--dictionarydir=/some/path/bar"
- Hbc::CLI.process_options %w[help]
+ Hbc::CLI.new.process_options("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]
+ Hbc::CLI.new.process_options("help", "--fontdir=/some/path/foo")
expect(Hbc.fontdir).to eq(Pathname.new("/some/path/foo"))
end
@@ -78,13 +78,13 @@ describe Hbc::CLI, :cask do
it "supports setting the fontdir from ENV" do
ENV["HOMEBREW_CASK_OPTS"] = "--fontdir=/some/path/bar"
- Hbc::CLI.process_options %w[help]
+ Hbc::CLI.new.process_options("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]
+ Hbc::CLI.new.process_options("help", "--servicedir=/some/path/foo")
expect(Hbc.servicedir).to eq(Pathname.new("/some/path/foo"))
end
@@ -92,42 +92,22 @@ describe Hbc::CLI, :cask do
it "supports setting the servicedir from ENV" do
ENV["HOMEBREW_CASK_OPTS"] = "--servicedir=/some/path/bar"
- Hbc::CLI.process_options %w[help]
+ Hbc::CLI.new.process_options("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]
+ rest = Hbc::CLI.new.process_options("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(ArgumentError)
- 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(ArgumentError)
- end
- end
-
describe "--help" do
it "sets the Cask help method to true" do
- begin
- Hbc::CLI.process_options %w[foo --help]
- expect(Hbc::CLI.help?).to be true
- ensure
- Hbc::CLI.help = false
- end
+ command = Hbc::CLI.new("foo", "--help")
+ expect(command.help?).to be true
end
end
end