Display "None" when no methods are called

This commit is contained in:
Michael Miller 2022-07-13 10:53:57 -06:00
parent b65f53f105
commit 181a34a0b3
No known key found for this signature in database
GPG key ID: 32B47AE8F388A1FF
2 changed files with 35 additions and 17 deletions

View file

@ -62,7 +62,7 @@ module Spectator::Matchers
private def values(actual : Expression(T)) forall T
{
expected: @stub.to_s,
actual: actual.value._spectator_calls.join("\n"),
actual: method_call_list(actual.value),
}
end
@ -70,8 +70,18 @@ module Spectator::Matchers
private def negated_values(actual : Expression(T)) forall T
{
expected: "Not #{@stub}",
actual: actual.value._spectator_calls.join("\n"),
actual: method_call_list(actual.value),
}
end
# Formatted list of method calls.
private def method_call_list(stubbable)
calls = stubbable._spectator_calls
if calls.empty?
"None"
else
calls.join("\n")
end
end
end
end