mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Friendlier descriptions of objects
This commit is contained in:
parent
d422376aaf
commit
76fa7e294f
4 changed files with 22 additions and 1 deletions
|
@ -6,6 +6,9 @@ module Spectator
|
|||
@spectator_stubs = Deque(MethodStub).new
|
||||
@spectator_stub_calls = Deque(MethodCall).new
|
||||
|
||||
def initialize(@spectator_double_name : Symbol)
|
||||
end
|
||||
|
||||
private macro stub(definition, &block)
|
||||
{%
|
||||
name = nil
|
||||
|
@ -78,6 +81,12 @@ module Spectator
|
|||
end
|
||||
end
|
||||
|
||||
def to_s(io)
|
||||
io << "Double("
|
||||
io << @spectator_double_name
|
||||
io << ')'
|
||||
end
|
||||
|
||||
protected def spectator_define_stub(stub : MethodStub) : Nil
|
||||
@spectator_stubs << stub
|
||||
end
|
||||
|
|
|
@ -9,6 +9,7 @@ module Spectator::DSL
|
|||
{% else %}
|
||||
class Double{{name.id}} < ::Spectator::Double
|
||||
def initialize(@spectator_test : {{@type.id}})
|
||||
super({{name.id.symbolize}})
|
||||
end
|
||||
|
||||
forward_missing_to @spectator_test
|
||||
|
|
|
@ -9,5 +9,16 @@ module Spectator
|
|||
def initialize(name : Symbol, @args : T, @options : NT)
|
||||
super(name)
|
||||
end
|
||||
|
||||
def to_s(io)
|
||||
io << name
|
||||
return if @args.empty? && @options.empty?
|
||||
|
||||
io << '('
|
||||
io << @args
|
||||
io << ", " if @args.any?
|
||||
io << @options
|
||||
io << ')'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -17,7 +17,7 @@ module Spectator::Matchers
|
|||
end
|
||||
|
||||
def failure_message(actual : TestExpression(T)) : String forall T
|
||||
"#{actual.value} did not receive #{@expected.label}"
|
||||
"#{actual.label} did not receive #{@expected.label}"
|
||||
end
|
||||
|
||||
def values(actual : TestExpression(T)) forall T
|
||||
|
|
Loading…
Reference in a new issue