xaviershay/rspec-fire — pull request #7 by myronmarston (2012-03-21 03:30:35+00:00)
Title: Use new TestDouble module to make class doubles true test doubles

rspec-mocks treat true test doubles a bit different than partial mocks. One difference is that on a pure mock object, it makes any stubbed or mocked method public. On a partial mock, it doesn't change the method visibility.

I was using a fire_class_double on a project that also loaded sinatra. The class I was using the double in place of had a public `#use` method, but sinatra adds a private `#use` method (for middleware) to the top-level object, and this caused my test to fail in a very surprising way. It took me a bit to track it back to the source (i.e. the fact that with my recent changes to use a module for a fire_class_double, RSpec no longer treated it as a pure mock). You can see an example of this bug [here](https://gist.github.com/2042094).

I've just [committed a change](https://github.com/rspec/rspec-mocks/commit/af3f296ed24b25cb014b3e0b1afa9f0e90db8635) to rspec-mocks to extract the code from `RSpec::Mocks::Mock` into a module (`RSpec::Mocks::TestDouble`). This is the corresponding change here to extend our class double modules with this module so that rspec treats it as a pure mock object.

Let me know if you have any questions.