Merge pull request #2190 from reitermarkus/spec-build_options
Convert BuildOptions test to spec.
This commit is contained in:
commit
714b23f002
52
Library/Homebrew/test/build_options_spec.rb
Normal file
52
Library/Homebrew/test/build_options_spec.rb
Normal file
@ -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
|
@ -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
|
|
@ -1,7 +1,7 @@
|
|||||||
require "tab"
|
require "tab"
|
||||||
require "formula"
|
require "formula"
|
||||||
|
|
||||||
RSpec::Matchers.alias_matcher :have_option_with, :be_with
|
RSpec::Matchers.alias_matcher :be_built_with, :be_with
|
||||||
|
|
||||||
describe Tab do
|
describe Tab do
|
||||||
matcher :be_poured_from_bottle do
|
matcher :be_poured_from_bottle do
|
||||||
@ -80,10 +80,10 @@ describe Tab do
|
|||||||
end
|
end
|
||||||
|
|
||||||
specify "#with?" do
|
specify "#with?" do
|
||||||
expect(subject).to have_option_with("foo")
|
expect(subject).to be_built_with("foo")
|
||||||
expect(subject).to have_option_with("qux")
|
expect(subject).to be_built_with("qux")
|
||||||
expect(subject).not_to have_option_with("bar")
|
expect(subject).not_to be_built_with("bar")
|
||||||
expect(subject).not_to have_option_with("baz")
|
expect(subject).not_to be_built_with("baz")
|
||||||
end
|
end
|
||||||
|
|
||||||
specify "#universal?" do
|
specify "#universal?" do
|
||||||
|
Loading…
x
Reference in New Issue
Block a user