[mocha-developer] using mocha with rspec

James Mead jamesmead44 at gmail.com
Tue Mar 13 08:03:34 EDT 2007

On 13/03/07, Dan North <dan at tastapod.com> wrote:
> The big things on my wishlist are:
> 1. Matchers in with(..) like JMock has:
> expects(:chew).with(is_a(Chewable), ANYTHING) where is_a(..) is a
> [something] that responds to matches?(actual) with true/false, and
> ANYTHING is a matcher that always returns true. That way, you could use
> rspec's expectation matcher framework or roll your own matchers. (I've
> got a bunch I wrote for my own mocking framework - everyone should write
> a mocking framework at least twice once :)
> The method matches?(actual) seems fairly universal across these
> frameworks.

Something like this has been on the drawing board for a while.

You can currently achieve something similar by using a block on the call to
with(), but I admit the syntax is not great.

expects(:chew).with { |mouthful1, mouthful2| mouthful1.is_a?(Chewable) }

2. Type-aware mocks that fail with a NoMethodError if the underlying
> type doesn't respond to an invoked method or method_missing (see earlier
> thread).

3. Something akin to after(another_mock, :method).
> None of these are showstoppers, but 1 is really high on my priorities
> and 2 and 3 would make my life happier. I might try to roll something
> for 1 if I get the time (read: unlikely!).

Cool. My bandwidth is a bit limited at the moment too, but I'll see what we
can do.

Thanks for your constructive suggestions.


More information about the mocha-developer mailing list