From ec06daaf35a5283602ffa4dba43fa4715803d582 Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Sun, 3 Mar 2019 12:13:35 -0700 Subject: [PATCH] Test values returned by match data --- spec/matchers/equality_matcher_spec.cr | 22 ++++++++++++++++++++++ spec/matchers/nil_matcher_spec.cr | 21 +++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/spec/matchers/equality_matcher_spec.cr b/spec/matchers/equality_matcher_spec.cr index e973a15..1c6804e 100644 --- a/spec/matchers/equality_matcher_spec.cr +++ b/spec/matchers/equality_matcher_spec.cr @@ -69,6 +69,28 @@ describe Spectator::Matchers::EqualityMatcher do end end + describe "#values" do + context "expected" do + it "is the expected value" do + expected, actual = 42, 777 + partial = new_partial(actual) + matcher = Spectator::Matchers::EqualityMatcher.new(expected) + match_data = matcher.match(partial) + match_data.values[:expected].should eq(expected) + end + end + + context "actual" do + it "is the actual value" do + expected, actual = 42, 777 + partial = new_partial(actual) + matcher = Spectator::Matchers::EqualityMatcher.new(expected) + match_data = matcher.match(partial) + match_data.values[:actual].should eq(actual) + end + end + end + describe "#message" do it "mentions ==" do value = 42 diff --git a/spec/matchers/nil_matcher_spec.cr b/spec/matchers/nil_matcher_spec.cr index c9a6862..220dca2 100644 --- a/spec/matchers/nil_matcher_spec.cr +++ b/spec/matchers/nil_matcher_spec.cr @@ -25,6 +25,27 @@ describe Spectator::Matchers::NilMatcher do end end + describe "#values" do + context "expected" do + it "is nil" do + partial = new_partial(42) + matcher = Spectator::Matchers::NilMatcher.new + match_data = matcher.match(partial) + match_data.values[:expected].should eq(nil) + end + end + + context "actual" do + it "is the actual value" do + value = 42 + partial = new_partial(value) + matcher = Spectator::Matchers::NilMatcher.new + match_data = matcher.match(partial) + match_data.values[:actual].should eq(value) + end + end + end + describe "#message" do it "mentions nil" do partial = new_partial(42)