Class: Bogus::HaveReceivedMatcher
- Inherits:
-
Object
- Object
- Bogus::HaveReceivedMatcher
- Extended by:
- Takes
- Includes:
- ProxiesMethodCalls
- Defined in:
- lib/bogus/stubbing/have_received_matcher.rb
Constant Summary collapse
- NO_SHADOW =
"Given object is not a fake and nothing was ever stubbed or mocked on it!"
Instance Method Summary collapse
- #build(*args) ⇒ Object
- #description ⇒ Object
- #failure_message ⇒ Object (also: #failure_message_for_should)
- #failure_message_when_negated ⇒ Object (also: #failure_message_for_should_not)
- #matches?(subject) ⇒ Boolean
- #method_call ⇒ Object
- #set_method(name, *args, &block) ⇒ Object
Methods included from Takes
Methods included from ProxiesMethodCalls
Instance Method Details
#build(*args) ⇒ Object
40 41 42 43 |
# File 'lib/bogus/stubbing/have_received_matcher.rb', line 40 def build(*args) return method_call if args.empty? set_method(*args) end |
#description ⇒ Object
20 21 22 |
# File 'lib/bogus/stubbing/have_received_matcher.rb', line 20 def description "have received #{call_str(@name, @args)}" end |
#failure_message ⇒ Object Also known as: failure_message_for_should
24 25 26 27 |
# File 'lib/bogus/stubbing/have_received_matcher.rb', line 24 def return NO_SHADOW unless Shadow.has_shadow?(@subject) %Q{Expected #{@subject.inspect} to #{description}, but it didn't.\n\n} + all_calls_str end |
#failure_message_when_negated ⇒ Object Also known as: failure_message_for_should_not
30 31 32 33 |
# File 'lib/bogus/stubbing/have_received_matcher.rb', line 30 def return NO_SHADOW unless Shadow.has_shadow?(@subject) %Q{Expected #{@subject.inspect} not to #{description}, but it did.} end |
#matches?(subject) ⇒ Boolean
10 11 12 13 14 15 16 17 18 |
# File 'lib/bogus/stubbing/have_received_matcher.rb', line 10 def matches?(subject) @subject = subject return false unless Shadow.has_shadow?(subject) verifies_stub_definition.verify!(subject, @name, @args) records_double_interactions.record(subject, @name, @args) subject.__shadow__.has_received(@name, @args) end |
#method_call ⇒ Object
36 37 38 |
# File 'lib/bogus/stubbing/have_received_matcher.rb', line 36 def method_call proxy(:set_method) end |
#set_method(name, *args, &block) ⇒ Object
45 46 47 48 49 |
# File 'lib/bogus/stubbing/have_received_matcher.rb', line 45 def set_method(name, *args, &block) @name = name @args = args self end |