Initially I thought this was a bug in the built-in mocking framework(and
still may be), but I better hash it out on the mailing list before I
file/reopen the ticket:
I thought my example illustrated my problem, but obviously I was passing
wrong arguments to the mock. I revised my example to more clearly state
This is a snip of a some code from a library I’m writing. When I run
spec I get the following:
Spec::Mocks::MockExpectationError in ‘Migration should find the records’
Mock ‘MyModel Class’ received unexpected message :count with (no args)
Finished in 0.009164 seconds
2 examples, 1 failure
I want to mock out MyModel completely because it’s an ActiveRecord
As suggested, if I define the MyModel class, this whole spec will pass.
But, I don’t think I should need to do that, should I? So it seems to
occur when I assign the mock to a constant.
So, even though MyModel.count is stubbed in the before block, the mock
reports an unexpected message. Note however the first example passes.
I had difficulty figuring out the cause of this, so I just gave FlexMock
shot (since it’s so easy to swap out). FlexMock passed both
that, that alone signifies a bug in rSpec).
So, my question: Is this a bug in the built in mocking framework, or am
doing it wrong?