Fix for issue #4
This commit is contained in:
parent
e5ad6fc514
commit
6d81e26298
|
@ -517,7 +517,7 @@ module Spectator::DSL
|
||||||
# expect { raise ArgumentError.new("foobar") }.to raise_error(ArgumentError, "foobar")
|
# expect { raise ArgumentError.new("foobar") }.to raise_error(ArgumentError, "foobar")
|
||||||
# ```
|
# ```
|
||||||
macro raise_error(type, message)
|
macro raise_error(type, message)
|
||||||
::Spectator::Matchers::ExceptionMatcher.new({{type}}, {{message}}, {{message.stringify}})
|
::Spectator::Matchers::ExceptionMatcher.create({{type}}, {{message}}, {{message.stringify}})
|
||||||
end
|
end
|
||||||
|
|
||||||
# Indicates that some block should raise an error.
|
# Indicates that some block should raise an error.
|
||||||
|
|
|
@ -57,6 +57,11 @@ module Spectator::Matchers
|
||||||
ExceptionMatcher(Exception, typeof(expected)).new(expected, label)
|
ExceptionMatcher(Exception, typeof(expected)).new(expected, label)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Creates a new exception matcher with a type and message check.
|
||||||
|
def self.create(exception_type : T.class, expected, label : String) forall T
|
||||||
|
ExceptionMatcher(T, typeof(expected)).new(expected, label)
|
||||||
|
end
|
||||||
|
|
||||||
# Match data specific to this matcher.
|
# Match data specific to this matcher.
|
||||||
private struct MatchData(ExceptionType, ExpectedType, ActualType) < MatchData
|
private struct MatchData(ExceptionType, ExpectedType, ActualType) < MatchData
|
||||||
# Creates the match data.
|
# Creates the match data.
|
||||||
|
|
Loading…
Reference in New Issue