Class: Crspec::Mock::Spy
Overview
A spy: a double that accepts any message and records calls for have_received verification.
Instance Attribute Summary
Attributes inherited from Double
Instance Method Summary collapse
- #inspect ⇒ Object
- #method_missing(method_name, *args, **kwargs, &block) ⇒ Object
- #respond_to_missing?(_method_name, _include_private = false) ⇒ Boolean
Methods inherited from Double
#__crspec_verify_stub!, #initialize, #verify_expectations!
Constructor Details
This class inherits a constructor from Crspec::Mock::Double
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, **kwargs, &block) ⇒ Object
441 442 443 444 445 446 447 448 449 450 451 |
# File 'lib/crspec/mock/double.rb', line 441 def method_missing(method_name, *args, **kwargs, &block) space = Fiber[Space::STORAGE_KEY] if space if (stub = space.fetch_stub(self, method_name)) return stub.call(*args, **kwargs, &block) end space.record_call(self, method_name, args, kwargs) end nil end |
Instance Method Details
#inspect ⇒ Object
457 458 459 |
# File 'lib/crspec/mock/double.rb', line 457 def inspect "#<Spy #{@name.inspect}>" end |
#respond_to_missing?(_method_name, _include_private = false) ⇒ Boolean
453 454 455 |
# File 'lib/crspec/mock/double.rb', line 453 def respond_to_missing?(_method_name, _include_private = false) true end |