diff --git a/src/spectator/matchers/exception_matcher.cr b/src/spectator/matchers/exception_matcher.cr index c4b9197..d1a289e 100644 --- a/src/spectator/matchers/exception_matcher.cr +++ b/src/spectator/matchers/exception_matcher.cr @@ -15,6 +15,14 @@ module Spectator::Matchers def initialize(@expected : TestValue(ExpectedType)) end + def description + if (message = @expected) + "raises #{ExceptionType} with message #{message}" + else + "raises #{ExceptionType}" + end + end + def match(actual) exception = capture_exception { actual.value } case exception diff --git a/src/spectator/matchers/have_predicate_matcher.cr b/src/spectator/matchers/have_predicate_matcher.cr index eef56f7..ccd4451 100644 --- a/src/spectator/matchers/have_predicate_matcher.cr +++ b/src/spectator/matchers/have_predicate_matcher.cr @@ -34,6 +34,14 @@ module Spectator::Matchers end end + private def failure_message(actual) + "#{actual.label} does not have #{expected.label}" + end + + private def failure_message_when_negated(actual) + "#{actual.label} has #{expected.label}" + end + # Captures all of the actual values. # A `NamedTuple` is returned, with each key being the attribute. private def snapshot_values(object) diff --git a/src/spectator/matchers/predicate_matcher.cr b/src/spectator/matchers/predicate_matcher.cr index 507049c..6cbbb88 100644 --- a/src/spectator/matchers/predicate_matcher.cr +++ b/src/spectator/matchers/predicate_matcher.cr @@ -5,7 +5,7 @@ module Spectator::Matchers # The `ExpectedType` type param should be a `NamedTuple`. # Each key in the tuple is a predicate (without the '?') to test. # Each value is a a `Tuple` of arguments to pass to the predicate method. - struct PredicateMatcher(ExpectedType) < Matcher(ExpectedType) + struct PredicateMatcher(ExpectedType) < Matcher private getter expected def initialize(@expected : TestValue(ExpectedType)) @@ -33,6 +33,14 @@ module Spectator::Matchers end end + private def failure_message(actual) + "#{actual.label} is not #{expected.label}" + end + + private def failure_message_when_negated(actual) + "#{actual.label} is #{expected.label}" + end + # Captures all of the actual values. # A `NamedTuple` is returned, with each key being the attribute. private def snapshot_values(object)