#452 √ invalid
Glenn Ford

When should_receive fails on a real object, the feedback says it's a mock

Reported by Glenn Ford | July 1st, 2008 @ 07:52 PM | in No-Milestone-Assigned

I have a real model I'm writing a spec for here:

    @restaurant.web_page.should_receive(:send_shipping_notice)
    @restaurant.web_page.purchase

Error looks like:

1)
Spec::Mocks::MockExpectationError in 'WebPage should complete a purchase from google activating the web page'
Mock 'WebPage' expected :send_shipping_notice with (any args) once, but received it 0 times
./spec/models/web_page_spec.rb:22:in `given_bought_on'
script/spec:4:

So it describes the error as if the real model is a mock.

More code here:

http://pastie.org/225652

Comments and changes to this ticket

  • Pat Maddox

    Pat Maddox August 11th, 2008 @ 09:27 PM

    I don't think this is a bug. You've partially mocked the object, and a mock expectation fails, so it's reasonable that the error message would say something along those lines. What would you prefer?

  • Glenn Ford

    Glenn Ford August 11th, 2008 @ 09:41 PM

    To be honest, I'm not really sure! David Chilemsky was helping me debug a problem in #rspec and when he came across this, he asked me if I'd please make this ticket. I sent him the link to the ticket once completed, and he thanked me.

    Perhaps the concern is that if I used WebPage.new or mock_model(WebPage) that I wouldn't get any difference in feedback. Or maybe the concern is something to do with the problem that the expectation is actually failing because WebPage is actually an Association Proxy and not even a WebPage at all.

    I hope that's at least helpful! I don't recall exactly why he seemed to think that wasn't good enough. I didn't understand it either way at the time.

  • Pat Maddox

    Pat Maddox October 21st, 2008 @ 12:30 AM

    • → State changed from “new” to “invalid”

    cleaning old tickets

Please Login or create a free account to add a new comment.

You can update this ticket by sending an email to from your email client. (help)

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Behaviour Driven Development for Ruby.

Shared Ticket Bins

People watching this ticket

Tags