Class: Stirlitz::Matchers::HaveReceived
- Inherits:
-
Object
- Object
- Stirlitz::Matchers::HaveReceived
- Defined in:
- lib/stirlitz/matchers.rb
Instance Method Summary collapse
- #failure_message_for_should ⇒ Object
- #failure_message_for_should_not ⇒ Object
-
#initialize(expected) ⇒ HaveReceived
constructor
A new instance of HaveReceived.
- #matches?(actual) ⇒ Boolean
- #with(*args) ⇒ Object
Constructor Details
#initialize(expected) ⇒ HaveReceived
Returns a new instance of HaveReceived.
21 22 23 |
# File 'lib/stirlitz/matchers.rb', line 21 def initialize(expected) @expected = expected end |
Instance Method Details
#failure_message_for_should ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/stirlitz/matchers.rb', line 39 def if @args "#{@expected} should have been called on #{@actual.inspect} with #{@args.inspect}, but #{@actual.(@expected) ? ' was called with other arguments' : 'wasn\'t'}" else "#{@expected} should have been called on #{@actual.inspect}. but wasn't" end end |
#failure_message_for_should_not ⇒ Object
47 48 49 50 51 52 53 54 |
# File 'lib/stirlitz/matchers.rb', line 47 def if @args "#{@expected} should not have been called on #{@actual.inspect} with #{@args.inspect}, but was" else "#{@expected} should not have been called on #{@actual.inspect}. but was" end "#{@expected} should not have been called on #{@actual.inspect}" end |
#matches?(actual) ⇒ Boolean
25 26 27 28 29 30 31 32 |
# File 'lib/stirlitz/matchers.rb', line 25 def matches?(actual) @actual = actual if @args actual.(@expected, *@args) else actual.(@expected) end end |
#with(*args) ⇒ Object
34 35 36 37 |
# File 'lib/stirlitz/matchers.rb', line 34 def with(*args) @args = args self end |