Module: Mocha::API
- Defined in:
- lib/bourne/api.rb
Defined Under Namespace
Classes: HaveReceived
Instance Method Summary collapse
-
#assert_received(mock, expected_method_name) {|matcher| ... } ⇒ Object
Asserts that the given mock received the given method.
-
#have_received(expected_method_name) ⇒ Object
:call-seq: should have_received(method).with(arguments).times(times).
Instance Method Details
#assert_received(mock, expected_method_name) {|matcher| ... } ⇒ Object
Asserts that the given mock received the given method.
Examples:
assert_received(mock, :to_s)
assert_received(Radio, :new) {|expect| expect.with(1041) }
assert_received(radio, :volume) {|expect| expect.with(11).twice }
13 14 15 16 17 |
# File 'lib/bourne/api.rb', line 13 def assert_received(mock, expected_method_name) matcher = have_received(expected_method_name) yield(matcher) if block_given? assert matcher.matches?(mock), matcher. end |
#have_received(expected_method_name) ⇒ Object
:call-seq:
should have_received(method).with(arguments).times(times)
Ensures that the given mock received the given method.
Examples:
mock.should have_received(:to_s)
Radio.should have_received(:new).with(1041)
radio.should have_received(:volume).with(11).twice
78 79 80 |
# File 'lib/bourne/api.rb', line 78 def have_received(expected_method_name) HaveReceived.new(expected_method_name) end |