aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Reiter2017-02-26 01:11:48 +0100
committerGitHub2017-02-26 01:11:48 +0100
commit714b23f002690c0692d45287c7019e274fea2ef4 (patch)
tree8f0dea62227b7c3435bdd2604cf41087612fc486
parent2401de493d68f341e34b926883f39e404c88173b (diff)
parent2826aa4c7f9b6d8c9ebac30c084160e10365ef55 (diff)
downloadbrew-714b23f002690c0692d45287c7019e274fea2ef4.tar.bz2
Merge pull request #2190 from reitermarkus/spec-build_options
Convert BuildOptions test to spec.
-rw-r--r--Library/Homebrew/test/build_options_spec.rb52
-rw-r--r--Library/Homebrew/test/build_options_test.rb50
-rw-r--r--Library/Homebrew/test/tab_spec.rb10
3 files changed, 57 insertions, 55 deletions
diff --git a/Library/Homebrew/test/build_options_spec.rb b/Library/Homebrew/test/build_options_spec.rb
new file mode 100644
index 000000000..5acc12f30
--- /dev/null
+++ b/Library/Homebrew/test/build_options_spec.rb
@@ -0,0 +1,52 @@
+require "build_options"
+require "options"
+
+RSpec::Matchers.alias_matcher :be_built_with, :be_with
+RSpec::Matchers.alias_matcher :be_built_without, :be_without
+
+describe BuildOptions do
+ subject { described_class.new(args, opts) }
+ let(:bad_build) { described_class.new(bad_args, opts) }
+ let(:args) { Options.create(%w[--with-foo --with-bar --without-qux]) }
+ let(:opts) { Options.create(%w[--with-foo --with-bar --without-baz --without-qux]) }
+ let(:bad_args) { Options.create(%w[--with-foo --with-bar --without-bas --without-qux --without-abc]) }
+
+ specify "#include?" do
+ expect(subject).to include("with-foo")
+ expect(subject).not_to include("with-qux")
+ expect(subject).not_to include("--with-foo")
+ end
+
+ specify "#with?" do
+ expect(subject).to be_built_with("foo")
+ expect(subject).to be_built_with("bar")
+ expect(subject).to be_built_with("baz")
+ end
+
+ specify "#without?" do
+ expect(subject).to be_built_without("qux")
+ expect(subject).to be_built_without("xyz")
+ end
+
+ specify "#used_options" do
+ expect(subject.used_options).to include("--with-foo")
+ expect(subject.used_options).to include("--with-bar")
+ end
+
+ specify "#unused_options" do
+ expect(subject.unused_options).to include("--without-baz")
+ end
+
+ specify "#invalid_options" do
+ expect(subject.invalid_options).to be_empty
+ expect(bad_build.invalid_options).to include("--without-bas")
+ expect(bad_build.invalid_options).to include("--without-abc")
+ expect(bad_build.invalid_options).not_to include("--with-foo")
+ expect(bad_build.invalid_options).not_to include("--with-baz")
+ end
+
+ specify "#invalid_option_names" do
+ expect(subject.invalid_option_names).to be_empty
+ expect(bad_build.invalid_option_names).to eq(%w[--without-abc --without-bas])
+ end
+end
diff --git a/Library/Homebrew/test/build_options_test.rb b/Library/Homebrew/test/build_options_test.rb
deleted file mode 100644
index 05e7ccd94..000000000
--- a/Library/Homebrew/test/build_options_test.rb
+++ /dev/null
@@ -1,50 +0,0 @@
-require "testing_env"
-require "build_options"
-require "options"
-
-class BuildOptionsTests < Homebrew::TestCase
- def setup
- super
- args = Options.create(%w[--with-foo --with-bar --without-qux])
- opts = Options.create(%w[--with-foo --with-bar --without-baz --without-qux])
- @build = BuildOptions.new(args, opts)
- bad_args = Options.create(%w[--with-foo --with-bar --without-bas --without-qux --without-abc])
- @bad_build = BuildOptions.new(bad_args, opts)
- end
-
- def test_include
- assert_includes @build, "with-foo"
- refute_includes @build, "with-qux"
- refute_includes @build, "--with-foo"
- end
-
- def test_with_without
- assert @build.with?("foo")
- assert @build.with?("bar")
- assert @build.with?("baz")
- assert @build.without?("qux")
- assert @build.without?("xyz")
- end
-
- def test_used_options
- assert_includes @build.used_options, "--with-foo"
- assert_includes @build.used_options, "--with-bar"
- end
-
- def test_unused_options
- assert_includes @build.unused_options, "--without-baz"
- end
-
- def test_invalid_options
- assert_empty @build.invalid_options
- assert_includes @bad_build.invalid_options, "--without-bas"
- assert_includes @bad_build.invalid_options, "--without-abc"
- refute_includes @bad_build.invalid_options, "--with-foo"
- refute_includes @bad_build.invalid_options, "--with-baz"
- end
-
- def test_invalid_option_names
- assert_empty @build.invalid_option_names
- assert_equal @bad_build.invalid_option_names, %w[--without-abc --without-bas]
- end
-end
diff --git a/Library/Homebrew/test/tab_spec.rb b/Library/Homebrew/test/tab_spec.rb
index 32a06a681..01dbeb67c 100644
--- a/Library/Homebrew/test/tab_spec.rb
+++ b/Library/Homebrew/test/tab_spec.rb
@@ -1,7 +1,7 @@
require "tab"
require "formula"
-RSpec::Matchers.alias_matcher :have_option_with, :be_with
+RSpec::Matchers.alias_matcher :be_built_with, :be_with
describe Tab do
matcher :be_poured_from_bottle do
@@ -80,10 +80,10 @@ describe Tab do
end
specify "#with?" do
- expect(subject).to have_option_with("foo")
- expect(subject).to have_option_with("qux")
- expect(subject).not_to have_option_with("bar")
- expect(subject).not_to have_option_with("baz")
+ expect(subject).to be_built_with("foo")
+ expect(subject).to be_built_with("qux")
+ expect(subject).not_to be_built_with("bar")
+ expect(subject).not_to be_built_with("baz")
end
specify "#universal?" do