Update NilMatcher to use MatchData and #match

This commit is contained in:
Michael Miller 2019-02-28 11:31:05 -07:00
parent 0dd66c8803
commit 94cbb9860a

View file

@ -1,13 +1,16 @@
require "../spec_helper"
describe Spectator::Matchers::NilMatcher do
describe "#match?" do
describe "#match" do
context "returned MatchData" do
describe "#matched?" do
context "with nil" do
it "is true" do
value = nil.as(Bool?)
partial = new_partial(value)
matcher = Spectator::Matchers::NilMatcher.new
matcher.match?(partial).should be_true
match_data = matcher.match(partial)
match_data.matched?.should be_true
end
end
@ -16,7 +19,8 @@ describe Spectator::Matchers::NilMatcher do
value = true.as(Bool?)
partial = new_partial(value)
matcher = Spectator::Matchers::NilMatcher.new
matcher.match?(partial).should be_false
match_data = matcher.match(partial)
match_data.matched?.should be_false
end
end
end
@ -25,7 +29,8 @@ describe Spectator::Matchers::NilMatcher do
it "mentions nil" do
partial = new_partial(42)
matcher = Spectator::Matchers::NilMatcher.new
matcher.message(partial).should contain("nil")
match_data = matcher.match(partial)
match_data.message.should contain("nil")
end
it "contains the actual label" do
@ -33,7 +38,8 @@ describe Spectator::Matchers::NilMatcher do
label = "everything"
partial = new_partial(value, label)
matcher = Spectator::Matchers::NilMatcher.new
matcher.message(partial).should contain(label)
match_data = matcher.match(partial)
match_data.message.should contain(label)
end
end
@ -41,7 +47,8 @@ describe Spectator::Matchers::NilMatcher do
it "mentions nil" do
partial = new_partial(42)
matcher = Spectator::Matchers::NilMatcher.new
matcher.negated_message(partial).should contain("nil")
match_data = matcher.match(partial)
match_data.negated_message.should contain("nil")
end
it "contains the actual label" do
@ -49,7 +56,10 @@ describe Spectator::Matchers::NilMatcher do
label = "everything"
partial = new_partial(value, label)
matcher = Spectator::Matchers::NilMatcher.new
matcher.negated_message(partial).should contain(label)
match_data = matcher.match(partial)
match_data.negated_message.should contain(label)
end
end
end
end
end