mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Pass actual value to failure message methods and values
This commit is contained in:
parent
f63697b019
commit
4b59dcf142
1 changed files with 4 additions and 4 deletions
|
@ -18,7 +18,7 @@ module Spectator::Matchers
|
||||||
|
|
||||||
# Message displayed when the matcher isn't satisifed.
|
# Message displayed when the matcher isn't satisifed.
|
||||||
# This is only called when `#matches?` returns false.
|
# This is only called when `#matches?` returns false.
|
||||||
abstract def failure_message : String
|
abstract def failure_message(actual) : String
|
||||||
|
|
||||||
# Message displayed when the matcher isn't satisifed and is negated.
|
# Message displayed when the matcher isn't satisifed and is negated.
|
||||||
# This is only called when `#does_not_match?` returns false.
|
# This is only called when `#does_not_match?` returns false.
|
||||||
|
@ -26,7 +26,7 @@ module Spectator::Matchers
|
||||||
# A default implementation of this method is provided,
|
# A default implementation of this method is provided,
|
||||||
# which causes compilation to fail.
|
# which causes compilation to fail.
|
||||||
# If the matcher supports negation, it must override this method.
|
# If the matcher supports negation, it must override this method.
|
||||||
def failure_message_when_negated : String
|
def failure_message_when_negated(actual) : String
|
||||||
{% raise "Negation with #{@type.name} is not supported." %}
|
{% raise "Negation with #{@type.name} is not supported." %}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ module Spectator::Matchers
|
||||||
if match?(actual)
|
if match?(actual)
|
||||||
SuccessfulMatchData.new
|
SuccessfulMatchData.new
|
||||||
else
|
else
|
||||||
FailedMatchData.new(failure_message, values)
|
FailedMatchData.new(failure_message(actual), values(actual))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ module Spectator::Matchers
|
||||||
if does_not_match?(actual)
|
if does_not_match?(actual)
|
||||||
SuccessfulMatchData.new
|
SuccessfulMatchData.new
|
||||||
else
|
else
|
||||||
FailedMatchData.new(failure_message_when_negated, negated_values)
|
FailedMatchData.new(failure_message_when_negated(actual), negated_values(actual))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue