Add tests for match data values

This commit is contained in:
Michael Miller 2019-03-05 14:00:14 -07:00
parent 27409f4a92
commit 0288e1d6f8
1 changed files with 59 additions and 2 deletions

View File

@ -205,7 +205,64 @@ describe Spectator::Matchers::EndWithMatcher do
end end
describe "#values" do describe "#values" do
context "with a String" do
context "expected" do
it "is the expected value" do
value = "FOOBAR"
last = /baz/i
partial = new_partial(value)
matcher = Spectator::Matchers::EndWithMatcher.new(last)
match_data = matcher.match(partial)
match_data.values[:expected].should eq(last)
end
end
context "actual" do
it "is the actual value" do
value = "FOOBAR"
last = /baz/i
partial = new_partial(value)
matcher = Spectator::Matchers::EndWithMatcher.new(last)
match_data = matcher.match(partial)
match_data.values[:actual].should eq(value)
end
end
end
context "with an Indexable" do
context "expected" do
it "is the expected value" do
array = %w[FOO BAR BAZ]
last = /qux/i
partial = new_partial(array)
matcher = Spectator::Matchers::EndWithMatcher.new(last)
match_data = matcher.match(partial)
match_data.values[:expected].should eq(last)
end
end
context "actual" do
it "is the last element" do
array = %w[FOO BAR BAZ]
last = /qux/i
partial = new_partial(array)
matcher = Spectator::Matchers::EndWithMatcher.new(last)
match_data = matcher.match(partial)
match_data.values[:actual].should eq(array.last)
end
end
context "list" do
it "is the full actual list" do
array = %w[FOO BAR BAZ]
last = /qux/i
partial = new_partial(array)
matcher = Spectator::Matchers::EndWithMatcher.new(last)
match_data = matcher.match(partial)
match_data.values[:list].should eq(array)
end
end
end
end end
describe "#message" do describe "#message" do
@ -220,7 +277,7 @@ describe Spectator::Matchers::EndWithMatcher do
end end
end end
context "with an Enumerable" do context "with an Indexable" do
it "mentions ===" do it "mentions ===" do
array = %i[a b c] array = %i[a b c]
partial = new_partial(array) partial = new_partial(array)
@ -282,7 +339,7 @@ describe Spectator::Matchers::EndWithMatcher do
end end
end end
context "with an Enumerable" do context "with an Indexable" do
it "mentions ===" do it "mentions ===" do
array = %i[a b c] array = %i[a b c]
partial = new_partial(array) partial = new_partial(array)