[mocha-developer] If I stub do I have to mock as well?
jamesmead44 at gmail.com
Fri Oct 13 11:39:21 EDT 2006
On 13/10/06, Tim Case <gk at karmacrash.com> wrote:
> Hi, I'm new to mocha and stubba but eager to learn. I have a rails
> functional test in which I would like to stub an instance method of
> particular class to always return true. I tried the following:
> def test_post_checkout
> post :checkout
> assert_response :redirect
> assert_equal "Checkout was successful.", flash[:notice]
> I expected that the stub would help my test pass but instead it failed
> and the failure included the following:
> #<Mocha::Mock: 28754118>.successful?() - expected calls: 0, actual calls:
> I was confused by this and it seemed to indicate that I need to tell
> Order that a call to #successful? was expected. Do I have to create a
> mock in order to stub? How do I do this?
> Tim Case
> tim at karmacrash.com
A first glance your test looks fine and it sounds like you understand how it
should work. Can you send the code for your checkout action? Also can you
tell me whether you are using the gem (which version?) or the Rails plugin
(which revision?) - I've been making a few fairly big changes in HEAD
recently and I may have inadvertantly introduced a bug to the Rails plugin.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the mocha-developer