class Spy::API::HaveReceived
Attributes
actual[R]
method_name[R]
Public Class Methods
new(method_name)
click to toggle source
# File lib/spy/api.rb, line 22 def initialize(method_name) @method_name = method_name @with = nil end
Public Instance Methods
description()
click to toggle source
# File lib/spy/api.rb, line 52 def description "to have received #{method_name.inspect}#{args_message}" end
failure_message_for_should()
click to toggle source
# File lib/spy/api.rb, line 44 def failure_message_for_should "expected #{actual.inspect} to have received #{method_name.inspect}#{args_message}" end
failure_message_for_should_not()
click to toggle source
# File lib/spy/api.rb, line 48 def failure_message_for_should_not "expected #{actual.inspect} to not have received #{method_name.inspect}#{args_message}, but did" end
matches?(actual)
click to toggle source
# File lib/spy/api.rb, line 27 def matches?(actual) @actual = actual case @with when Proc spy.has_been_called_with?(&@with) when Array spy.has_been_called_with?(*@with) else spy.has_been_called? end end
with(*args)
click to toggle source
# File lib/spy/api.rb, line 39 def with(*args) @with = block_given? ? Proc.new : args self end
Private Instance Methods
args_message()
click to toggle source
# File lib/spy/api.rb, line 58 def args_message case @with when Array " with #{@with.inspect}" when Proc " with given block" end end
spy()
click to toggle source
# File lib/spy/api.rb, line 67 def spy @spy ||= Subroutine.get(@actual, @method_name) end