mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Display "None" when no methods are called
This commit is contained in:
parent
b65f53f105
commit
181a34a0b3
2 changed files with 35 additions and 17 deletions
|
@ -164,25 +164,33 @@ Spectator.describe Spectator::Matchers::ReceiveMatcher do
|
||||||
|
|
||||||
pre_condition { expect(match_data).to be_a(failed_match) }
|
pre_condition { expect(match_data).to be_a(failed_match) }
|
||||||
|
|
||||||
before_each do
|
|
||||||
dbl.test_method
|
|
||||||
dbl.test_method(1, "wrong", :xyz, foo: "foobarbaz")
|
|
||||||
dbl.irrelevant("foo")
|
|
||||||
end
|
|
||||||
|
|
||||||
it "has the expected call listed" do
|
it "has the expected call listed" do
|
||||||
is_expected.to contain({:expected, "#test_method(1, \"test\", Symbol, foo: #{/bar/.inspect})"})
|
is_expected.to contain({:expected, "#test_method(1, \"test\", Symbol, foo: #{/bar/.inspect})"})
|
||||||
end
|
end
|
||||||
|
|
||||||
it "has the list of called methods" do
|
context "with method calls" do
|
||||||
is_expected.to contain({
|
before_each do
|
||||||
:actual,
|
dbl.test_method
|
||||||
<<-SIGNATURES
|
dbl.test_method(1, "wrong", :xyz, foo: "foobarbaz")
|
||||||
#test_method(no args)
|
dbl.irrelevant("foo")
|
||||||
#test_method(1, "wrong", :xyz, foo: "foobarbaz")
|
end
|
||||||
#irrelevant("foo")
|
|
||||||
SIGNATURES
|
it "has the list of called methods" do
|
||||||
})
|
is_expected.to contain({
|
||||||
|
:actual,
|
||||||
|
<<-SIGNATURES
|
||||||
|
#test_method(no args)
|
||||||
|
#test_method(1, "wrong", :xyz, foo: "foobarbaz")
|
||||||
|
#irrelevant("foo")
|
||||||
|
SIGNATURES
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "with no method calls" do
|
||||||
|
it "reports \"None\" for the actual value" do
|
||||||
|
is_expected.to contain({:actual, "None"})
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -62,7 +62,7 @@ module Spectator::Matchers
|
||||||
private def values(actual : Expression(T)) forall T
|
private def values(actual : Expression(T)) forall T
|
||||||
{
|
{
|
||||||
expected: @stub.to_s,
|
expected: @stub.to_s,
|
||||||
actual: actual.value._spectator_calls.join("\n"),
|
actual: method_call_list(actual.value),
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -70,8 +70,18 @@ module Spectator::Matchers
|
||||||
private def negated_values(actual : Expression(T)) forall T
|
private def negated_values(actual : Expression(T)) forall T
|
||||||
{
|
{
|
||||||
expected: "Not #{@stub}",
|
expected: "Not #{@stub}",
|
||||||
actual: actual.value._spectator_calls.join("\n"),
|
actual: method_call_list(actual.value),
|
||||||
}
|
}
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue