Update EmptyMatcher to use MatchData

This commit is contained in:
Michael Miller 2019-03-03 20:21:39 -07:00
parent be3218bcd8
commit df663d30d9
2 changed files with 90 additions and 48 deletions

View file

@ -1,43 +1,73 @@
require "../spec_helper"
describe Spectator::Matchers::EmptyMatcher do
describe "#match?" do
context "with an empty set" do
it "is true" do
array = [] of Symbol
partial = new_partial(array)
matcher = Spectator::Matchers::EmptyMatcher.new
matcher.match?(partial).should be_true
describe "#match" do
context "returned MatchData" do
describe "#matched?" do
context "with an empty set" do
it "is true" do
array = [] of Symbol
partial = new_partial(array)
matcher = Spectator::Matchers::EmptyMatcher.new
match_data = matcher.match(partial)
match_data.matched?.should be_true
end
end
context "with a filled set" do
it "is false" do
array = %i[a b c]
partial = new_partial(array)
matcher = Spectator::Matchers::EmptyMatcher.new
match_data = matcher.match(partial)
match_data.matched?.should be_false
end
end
end
end
context "with a filled set" do
it "is false" do
array = %i[a b c]
partial = new_partial(array)
matcher = Spectator::Matchers::EmptyMatcher.new
matcher.match?(partial).should be_false
describe "#values" do
context "expected" do
it "is an empty set" do
array = %i[a b c]
partial = new_partial(array)
matcher = Spectator::Matchers::EmptyMatcher.new
match_data = matcher.match(partial)
match_data.values[:expected].size.should eq(0)
end
end
context "actual" do
it "is the actual set" do
array = %i[a b c]
partial = new_partial(array)
matcher = Spectator::Matchers::EmptyMatcher.new
match_data = matcher.match(partial)
match_data.values[:actual].should eq(array)
end
end
end
end
end
describe "#message" do
it "contains the actual label" do
array = %i[a b c]
label = "everything"
partial = new_partial(array, label)
matcher = Spectator::Matchers::EmptyMatcher.new
matcher.message(partial).should contain(label)
end
end
describe "#message" do
it "contains the actual label" do
array = %i[a b c]
label = "everything"
partial = new_partial(array, label)
matcher = Spectator::Matchers::EmptyMatcher.new
match_data = matcher.match(partial)
match_data.message.should contain(label)
end
end
describe "#negated_message" do
it "contains the actual label" do
array = %i[a b c]
label = "everything"
partial = new_partial(array, label)
matcher = Spectator::Matchers::EmptyMatcher.new
matcher.negated_message(partial).should contain(label)
describe "#negated_message" do
it "contains the actual label" do
array = %i[a b c]
label = "everything"
partial = new_partial(array, label)
matcher = Spectator::Matchers::EmptyMatcher.new
match_data = matcher.match(partial)
match_data.negated_message.should contain(label)
end
end
end
end
end