Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Some docs about yields mock in README #82

Closed
wants to merge 1 commit into from

3 participants

@seban

Some time ago I had problem with mocking method which yields a block. I will be helpful to see some info in README. It is related to iissue #71

@raphaelcm

Still +1 that documentation needs to be added

@raphaelcm

Finally got it. I think the documentation should be expanded beyond your snippet, but it's a good start.

@mcmire
Collaborator

Thanks - I'll review this and pull it in.

@mcmire
Collaborator

Hey there - sorry for the late update, new maintainer here. I added a new section to the README titled "Modifying doubles" which documents #yields as well as the other methods which you are allowed to call on doubles. Can you take a look and tell me if this clears things up? Thanks.

@mcmire mcmire closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 7, 2012
  1. @seban
This page is out of date. Refresh to see the latest.
Showing with 8 additions and 0 deletions.
  1. +8 −0 README.rdoc
View
8 README.rdoc
@@ -115,6 +115,14 @@ Rspec mocks:
my_object.should_receive(:hello).with('bob', 'jane').and_return('Hello Bob and Jane')
my_object.should_receive(:hello).with('bob', 'jane') {'Hello Bob and Jane'} #rspec also supports blocks for the return value
+=== mocking method which yields a block
+RR supports mocking methods call which yields a passed block.
+
+ mock(my_object).method_with_block.yields(yield_arg) {return_value}
+ my_object.method_with_block do |something|
+ # do some stuff
+ end
+
== Using RR
To create a double on an object, you can use the following methods:
* mock or mock!
Something went wrong with that request. Please try again.