[rspec-users] How to keep mocks consistent?
dchelimsky at gmail.com
Mon Dec 18 17:49:03 EST 2006
On 12/18/06, Coda Hale <coda.hale at gmail.com> wrote:
> Hey all,
> Here's a question for everyone: how do you keep your mocks and stubs
> consistent with your real objects?
> I'm dipping my toes into the RSpec world, and it's absolutely
> delightful (running dozens of tests in less than a second is nice as
> well), but I'm concerned about my ability to keep the mocks in my
> specs consistent with the behavior of their real-world equivalents.
> I'm writing specs for a controller in a Rails application, and I've
> got stuff like this:
> If I change ComplicatedObject.execute down the line to return
> something besides a float, this spec will still pass, and the
> controller will only fail in real life. So I could have full test
> coverage, green lights across the board, and massive amounts of bugs
> in the way my classes interact.
> Is there any mechanism in RSpec to keep this from happening? Any
> methodology beyond "be careful"? Should I even be mocking my own
> How do you manage this?
The isolated unit level testing that you're getting from using mocks
should (MUST) be coupled with some level of integration testing.
Right now I'm using either rails integration testing and/or selenium.
> Coda Hale
> rspec-users mailing list
> rspec-users at rubyforge.org
More information about the rspec-users