#429 new
Chris McGrath (octopod)

stub_model breaks in 1.1.4 when using mocha

Reported by Chris McGrath (octopod) | June 5th, 2008 @ 07:13 PM | in No-Milestone-Assigned

undefined method `stub!' for #

This was working fine in the trunk version I was using that contained stub_model before.

I'm guessing 2a881bfdaebe107946258889ed651941f413adbd is the cause of this.

Is having (mock|stub)_model support other mocking frameworks on the cards or was the fact it worked before a happy accident?

Comments and changes to this ticket

  • Chris McGrath (octopod)

    Chris McGrath (octopod) June 6th, 2008 @ 10:13 AM

    The following workround sorted things out for me. In my spec/spec_helper.rb

    # So stub_model works with mocha
    module Spec
      module Rails
        module Mocks
          def add_stubs(object, stubs = {}) #:nodoc:
            m = [String, Symbol].index(object.class) ? mock(object.to_s) : object
            stubs.each {|k,v| m.stubs(k).returns(v)}
            m
          end
        end
      end
    end
    

    I assume this is somewhat related to #275 also

  • David Chelimsky

    David Chelimsky June 6th, 2008 @ 03:36 PM

    • → Assigned user changed from “” to “David Chelimsky”

    #275 is definitely the same issue and http://github.com/dchelimsky/rsp... is the commit that broke it.

    Having RSpec support mock_model in the other frameworks is not in the plan. I can see how this would be useful, but this would head us down a rats-nest of maintenance problems in the long run.

    What I would very much like to do, however, is turn off all of RSpec's own mocking conveniences when you're using another framework (i.e. not even define mock_model and stub_model) and formalize a consistent plugin API for situations like this.

    I'll keep you posted on that - it's something that's been on my mind quite a bit lately.

    Cheers,

    David

  • Chris McGrath (octopod)

    Chris McGrath (octopod) June 6th, 2008 @ 04:36 PM

    Sounds sensible, I'll look forward to seeing what you come up with.

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