Extract linux spec cases & add hash support to default #uses_from_macos

This commit is contained in:
Gabriel 2019-05-26 00:17:40 -03:00
parent 77f2d01739
commit 41f39939ca
4 changed files with 41 additions and 14 deletions

View File

@ -1,6 +1,8 @@
# frozen_string_literal: true
class SoftwareSpec
undef uses_from_macos
def uses_from_macos(deps, **args)
if deps.is_a?(Hash)
args = deps

View File

@ -170,8 +170,10 @@ class SoftwareSpec
add_dep_option(dep) if dep
end
def uses_from_macos(spec, **_args)
depends_on(spec)
def uses_from_macos(deps, **_args)
deps.is_a?(Hash) && deps = Hash[*deps.shift]
depends_on(deps)
end
def deps

View File

@ -0,0 +1,35 @@
# frozen_string_literal: true
require "software_spec"
describe SoftwareSpec do
subject(:spec) { described_class.new }
describe "#uses_from_macos" do
before do
allow(OS).to receive(:linux?).and_return(true)
end
it "allows specifying dependencies" do
spec.uses_from_macos("foo")
expect(spec.deps.first.name).to eq("foo")
end
it "works with tags" do
spec.uses_from_macos("foo" => :head, :after => :mojave)
expect(spec.deps.first.name).to eq("foo")
expect(spec.deps.first.tags).to include(:head)
end
it "ignores OS version specifications" do
spec.uses_from_macos("foo", after: :mojave)
spec.uses_from_macos("bar" => :head, :after => :mojave)
expect(spec.deps.first.name).to eq("foo")
expect(spec.deps.last.name).to eq("bar")
expect(spec.deps.last.tags).to include(:head)
end
end
end

View File

@ -138,18 +138,6 @@ describe SoftwareSpec do
expect(subject.options.first.description).to eq("blah")
end
describe "#uses_from_macos" do
it "allows specifying dependencies" do
subject.uses_from_macos("foo")
expect(subject.deps.first.name).to eq("foo")
end
it "ignores OS version specifications" do
subject.uses_from_macos("foo", after: :mojave)
expect(subject.deps.first.name).to eq("foo")
end
end
describe "#patch" do
it "adds a patch" do
subject.patch(:p1, :DATA)