Merge pull request #2219 from reitermarkus/spec-formula_support
Convert `formula_support` test to spec.
This commit is contained in:
commit
6392f5f081
29
Library/Homebrew/test/formula_support_spec.rb
Normal file
29
Library/Homebrew/test/formula_support_spec.rb
Normal file
@ -0,0 +1,29 @@
|
||||
require "formula_support"
|
||||
|
||||
describe KegOnlyReason do
|
||||
describe "#to_s" do
|
||||
it "returns the reason provided" do
|
||||
r = KegOnlyReason.new :provided_by_osx, "test"
|
||||
expect(r.to_s).to eq("test")
|
||||
end
|
||||
|
||||
it "returns a default message when no reason is provided" do
|
||||
r = KegOnlyReason.new :provided_by_macos, ""
|
||||
expect(r.to_s).to match(/^macOS already provides/)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe BottleDisableReason do
|
||||
specify ":unneeded" do
|
||||
bottle_disable_reason = BottleDisableReason.new :unneeded, nil
|
||||
expect(bottle_disable_reason).to be_unneeded
|
||||
expect(bottle_disable_reason.to_s).to eq("This formula doesn't require compiling.")
|
||||
end
|
||||
|
||||
specify ":disabled" do
|
||||
bottle_disable_reason = BottleDisableReason.new :disable, "reason"
|
||||
expect(bottle_disable_reason).not_to be_unneeded
|
||||
expect(bottle_disable_reason.to_s).to eq("reason")
|
||||
end
|
||||
end
|
||||
@ -1,28 +0,0 @@
|
||||
require "testing_env"
|
||||
require "formula_support"
|
||||
|
||||
class KegOnlyReasonTests < Homebrew::TestCase
|
||||
def test_to_s_explanation
|
||||
r = KegOnlyReason.new :provided_by_osx, "test"
|
||||
assert_equal "test", r.to_s
|
||||
end
|
||||
|
||||
def test_to_s_no_explanation
|
||||
r = KegOnlyReason.new :provided_by_macos, ""
|
||||
assert_match(/^macOS already provides/, r.to_s)
|
||||
end
|
||||
end
|
||||
|
||||
class BottleDisableReasonTests < Homebrew::TestCase
|
||||
def test_bottle_unneeded
|
||||
bottle_disable_reason = BottleDisableReason.new :unneeded, nil
|
||||
assert_predicate bottle_disable_reason, :unneeded?
|
||||
assert_equal "This formula doesn't require compiling.", bottle_disable_reason.to_s
|
||||
end
|
||||
|
||||
def test_bottle_disabled
|
||||
bottle_disable_reason = BottleDisableReason.new :disable, "reason"
|
||||
refute_predicate bottle_disable_reason, :unneeded?
|
||||
assert_equal "reason", bottle_disable_reason.to_s
|
||||
end
|
||||
end
|
||||
Loading…
x
Reference in New Issue
Block a user