diff --git a/spec/rspec/core/explicit_subject_spec.cr b/spec/rspec/core/explicit_subject_spec.cr index 6086bdd..bc102e8 100644 --- a/spec/rspec/core/explicit_subject_spec.cr +++ b/spec/rspec/core/explicit_subject_spec.cr @@ -115,11 +115,11 @@ Spectator.describe "Explicit Subject" do end it "the subject and named helpers return the same object" do - expect(global_count).to eq(subject) # TODO: `be` matcher with value (no same? method). + expect(global_count).to be(subject) end it "is set to the block return value (i.e. the global $count)" do - expect(global_count).to eq(@@count) # TODO: `be` matcher with value (no same? method). + expect(global_count).to be(@@count) end end end diff --git a/spec/rspec/core/helper_methods_spec.cr b/spec/rspec/core/helper_methods_spec.cr index a5981de..3fc6802 100644 --- a/spec/rspec/core/helper_methods_spec.cr +++ b/spec/rspec/core/helper_methods_spec.cr @@ -8,7 +8,7 @@ Spectator.describe "Arbitrary helper methods" do end it "has access to methods define in its group" do - expect(help).to eq(:available) # TODO: `be` matcher with value (no same? method). + expect(help).to be(:available) end end end @@ -21,7 +21,7 @@ Spectator.describe "Arbitrary helper methods" do describe "in a nested group" do it "has access to methods defined in its parent group" do - expect(help).to eq(:available) # TODO: `be` matcher with value (no same? method). + expect(help).to be(:available) end end end diff --git a/src/spectator/matchers/reference_matcher.cr b/src/spectator/matchers/reference_matcher.cr index 3586e14..dc6c476 100644 --- a/src/spectator/matchers/reference_matcher.cr +++ b/src/spectator/matchers/reference_matcher.cr @@ -13,7 +13,13 @@ module Spectator::Matchers # Checks whether the matcher is satisifed with the expression given to it. private def match?(actual : TestExpression(T)) : Bool forall T - expected.value.same?(actual.value) + value = expected.value + if value.responds_to?(:same) + value.same?(actual.value) + else + # Value type (struct) comparison. + actual.value.class == value.class && actual.value == value + end end # Message displayed when the matcher isn't satisifed.