Class: Mocktail::Matchers::Captor
- Inherits:
-
Object
- Object
- Mocktail::Matchers::Captor
- Extended by:
- T::Sig
- Defined in:
- lib/mocktail/matchers/captor.rb,
lib/mocktail/sorbet/mocktail/matchers/captor.rb
Overview
Captors are conceptually complex implementations, but with a simple usage/purpose: They are values the user can create and hold onto that will return a matcher and then “capture” the value made by the real call, for later analysis & assertion.
Unlike other matchers, these don’t make any useful sense for stubbing, but are very useful when asserting complication call verifications
The fact the user will need the reference outside the verification call is why this is a top-level method on Mocktail, and not included in the |m| block arg to stubs/verify
See Mockito, which is the earliest implementation I know of: javadoc.io/doc/org.mockito/mockito-core/latest/org/mockito/Captor.html
Defined Under Namespace
Classes: Capture
Instance Attribute Summary collapse
-
#capture ⇒ Object
readonly
This T.untyped is intentional.
Instance Method Summary collapse
- #captured? ⇒ Boolean
-
#initialize ⇒ Captor
constructor
A new instance of Captor.
- #value ⇒ Object
Constructor Details
Instance Attribute Details
#capture ⇒ Object (readonly)
This T.untyped is intentional. Even though a Capture is surely returned, in order for a verification demonstration to pass its own type check, it needs to think it’s being returned whatever parameter is expected
51 52 53 |
# File 'lib/mocktail/matchers/captor.rb', line 51 def capture @capture end |
Instance Method Details
#captured? ⇒ Boolean
57 58 59 |
# File 'lib/mocktail/matchers/captor.rb', line 57 def captured? @capture.captured? end |
#value ⇒ Object
61 62 63 |
# File 'lib/mocktail/matchers/captor.rb', line 61 def value @capture.value end |