Class: Spy::API::HaveReceived
- Inherits:
-
Object
- Object
- Spy::API::HaveReceived
- Defined in:
- lib/spy/api.rb
Instance Attribute Summary collapse
-
#actual ⇒ Object
readonly
Returns the value of attribute actual.
-
#method_name ⇒ Object
readonly
Returns the value of attribute method_name.
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message_for_should ⇒ Object
- #failure_message_for_should_not ⇒ Object
-
#initialize(method_name) ⇒ HaveReceived
constructor
A new instance of HaveReceived.
- #matches?(actual) ⇒ Boolean
- #with(*args, &block) ⇒ Object
Constructor Details
#initialize(method_name) ⇒ HaveReceived
Returns a new instance of HaveReceived.
22 23 24 25 |
# File 'lib/spy/api.rb', line 22 def initialize(method_name) @method_name = method_name @with = nil end |
Instance Attribute Details
#actual ⇒ Object (readonly)
Returns the value of attribute actual.
20 21 22 |
# File 'lib/spy/api.rb', line 20 def actual @actual end |
#method_name ⇒ Object (readonly)
Returns the value of attribute method_name.
20 21 22 |
# File 'lib/spy/api.rb', line 20 def method_name @method_name end |
Instance Method Details
#description ⇒ Object
52 53 54 |
# File 'lib/spy/api.rb', line 52 def description "to have received #{method_name.inspect}#{}" end |
#failure_message_for_should ⇒ Object
44 45 46 |
# File 'lib/spy/api.rb', line 44 def "expected #{actual.inspect} to have received #{method_name.inspect}#{}" end |
#failure_message_for_should_not ⇒ Object
48 49 50 |
# File 'lib/spy/api.rb', line 48 def "expected #{actual.inspect} to not have received #{method_name.inspect}#{}, but did" end |
#matches?(actual) ⇒ Boolean
27 28 29 30 31 32 33 34 35 36 37 |
# 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, &block) ⇒ Object
39 40 41 42 |
# File 'lib/spy/api.rb', line 39 def with(*args, &block) @with = block_given? ? block : args self end |