[#10413] Mock Blocks
Reported by James Mead | January 1st, 2009 @ 06:26 PM
Date: 2007-04-27 16:39 Sender: Brian Takita
Allow mock expectations to be defined within a block. This syntax is similar to ActiveRecord and Markaby.
In these examples, the block is instance evaled with the binding of the mock.
mock('The new mock') do
foo(1,2) {:bar}
baz(3,4).returning(:foobar)
end
User.mocks do
find('3').once {user}
destroy(7)
end
An alternate syntax does not instance eval the block.
mock('The new mock') do |m|
m.foo(1,2) {:bar}
m.baz(3,4).returning(:foobar)
end
User.mocks do |m|
m.find('3').once {user}
m.destroy(7)
end
This feature request is coupled with the merge with block into the method name expectation feature. http://rubyforge.org/tracker/ind...
No comments found
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป
A mocking & stubbing library for Ruby.
* <a href="http://github.com/floehopper/mocha">GitHub repository</a>
* <a href="http://mocha.rubyforge.org">Documentation</a>
* <a href="http://groups.google.com/group/mocha-developer">Mailing List</a>