Skip to content
Snippets Groups Projects
Commit 2826aa4c authored by Markus Reiter's avatar Markus Reiter
Browse files

Convert BuildOptions test to spec.

parent 2401de49
No related branches found
No related tags found
No related merge requests found
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
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
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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment