[rspec-devel] RSpec mocks running when Flexmock is configured
jim.weirich at gmail.com
Fri May 23 19:20:32 EDT 2008
On May 22, 2008, at 11:37 PM, Jim Weirich wrote:
> I've been debugging a problem with mocks in RSpec. I've configured
> RSpec to use flexmock, but the RSpec mocking framework still adds
> its should_receive method onto every object in the system, including
> flexmock objects. These RSpec mocks are never torn down because the
> teardown mechanism is invoking flexmock's teardown.
Ok, I've investigated the problem further. The issue is caused in
spec/rails by the inclusion of the render_observer file.
Render_observer unconditionally loads the rspec mocks file without
checking for configured mock library.
This is problematic in two areas:
(1) RSpec mock teardown facility only supports a single mock library
(AFAIK, I recall being told this was a design decision). Once a
different mock library is configured, RSpec mocks will not be torn down.
(2) The RSpec mock library globally installs a should_receive method
on every object in the system, interfering with other mock libraries.
Solutions I see are:
(A) Fix render_observer to work with the configured mock library.
(B) Allow RSpec to support multiple simultaneous mocking frameworks.
-- Jim Weirich
-- jim.weirich at gmail.com
More information about the rspec-devel