2019-04-19 15:38:03 +09:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-02-25 20:28:38 +01:00
|
|
|
require "build_options"
|
|
|
|
require "options"
|
|
|
|
|
2024-02-18 15:11:11 -08:00
|
|
|
RSpec.describe BuildOptions do
|
2017-05-09 23:00:51 +02:00
|
|
|
alias_matcher :be_built_with, :be_with
|
|
|
|
alias_matcher :be_built_without, :be_without
|
|
|
|
|
2021-01-31 13:14:23 -05:00
|
|
|
subject(:build_options) { described_class.new(args, opts) }
|
2018-03-25 13:30:37 +01:00
|
|
|
|
2017-02-25 20:28:38 +01:00
|
|
|
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 "#with?" do
|
2021-01-31 13:14:23 -05:00
|
|
|
expect(build_options).to be_built_with("foo")
|
|
|
|
expect(build_options).to be_built_with("bar")
|
|
|
|
expect(build_options).to be_built_with("baz")
|
2017-02-25 20:28:38 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
specify "#without?" do
|
2021-01-31 13:14:23 -05:00
|
|
|
expect(build_options).to be_built_without("qux")
|
|
|
|
expect(build_options).to be_built_without("xyz")
|
2017-02-25 20:28:38 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
specify "#used_options" do
|
2021-01-31 13:14:23 -05:00
|
|
|
expect(build_options.used_options).to include("--with-foo")
|
|
|
|
expect(build_options.used_options).to include("--with-bar")
|
2017-02-25 20:28:38 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
specify "#unused_options" do
|
2021-01-31 13:14:23 -05:00
|
|
|
expect(build_options.unused_options).to include("--without-baz")
|
2017-02-25 20:28:38 +01:00
|
|
|
end
|
|
|
|
end
|