Match RSpec behavior

This commit is contained in:
Michael Miller 2022-03-25 22:32:27 -06:00
parent 28488d308e
commit b28437ccc4
No known key found for this signature in database
GPG key ID: AC78B32D30CE34A2
2 changed files with 54 additions and 62 deletions

View file

@ -3,6 +3,7 @@ require "./arguments"
require "./double"
require "./method_call"
require "./stub"
require "./value_stub"
module Spectator
# Stands in for an object for testing that a SUT calls expected methods.
@ -17,8 +18,12 @@ module Spectator
@name : String?
def initialize(_spectator_double_name = nil, _spectator_double_stubs = [] of Stub, **@messages : **Messages)
super(_spectator_double_stubs)
@name = _spectator_double_name.try &.inspect
message_stubs = messages.map do |method, value|
ValueStub.new(method, value)
end
super(_spectator_double_stubs + message_stubs)
end
# Returns the double's name formatted for user output.