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_stubs = Deque(MethodStub).new
|
||||||
@spectator_stub_calls = Deque(MethodCall).new
|
@spectator_stub_calls = Deque(MethodCall).new
|
||||||
|
|
||||||
|
def initialize(@spectator_double_name : Symbol)
|
||||||
|
end
|
||||||
|
|
||||||
private macro stub(definition, &block)
|
private macro stub(definition, &block)
|
||||||
{%
|
{%
|
||||||
name = nil
|
name = nil
|
||||||
|
@ -78,6 +81,12 @@ module Spectator
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def to_s(io)
|
||||||
|
io << "Double("
|
||||||
|
io << @spectator_double_name
|
||||||
|
io << ')'
|
||||||
|
end
|
||||||
|
|
||||||
protected def spectator_define_stub(stub : MethodStub) : Nil
|
protected def spectator_define_stub(stub : MethodStub) : Nil
|
||||||
@spectator_stubs << stub
|
@spectator_stubs << stub
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,6 +9,7 @@ module Spectator::DSL
|
||||||
{% else %}
|
{% else %}
|
||||||
class Double{{name.id}} < ::Spectator::Double
|
class Double{{name.id}} < ::Spectator::Double
|
||||||
def initialize(@spectator_test : {{@type.id}})
|
def initialize(@spectator_test : {{@type.id}})
|
||||||
|
super({{name.id.symbolize}})
|
||||||
end
|
end
|
||||||
|
|
||||||
forward_missing_to @spectator_test
|
forward_missing_to @spectator_test
|
||||||
|
|
|
@ -9,5 +9,16 @@ module Spectator
|
||||||
def initialize(name : Symbol, @args : T, @options : NT)
|
def initialize(name : Symbol, @args : T, @options : NT)
|
||||||
super(name)
|
super(name)
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
|
|
|
@ -17,7 +17,7 @@ module Spectator::Matchers
|
||||||
end
|
end
|
||||||
|
|
||||||
def failure_message(actual : TestExpression(T)) : String forall T
|
def failure_message(actual : TestExpression(T)) : String forall T
|
||||||
"#{actual.value} did not receive #{@expected.label}"
|
"#{actual.label} did not receive #{@expected.label}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def values(actual : TestExpression(T)) forall T
|
def values(actual : TestExpression(T)) forall T
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue