[rspec-users] set_fixture_class works on individual test, but test suite fails
steve at rentmineonline.com
Tue Nov 8 11:52:43 EST 2011
I have a bug in my code that I have been unable to track down that
deals with the set_fixture_class statement. Basically,
set_fixture_class (and my tests) are working fine when I test one
controller in isolation, but they are failing when I run all my
controller specs together.
My project use both a local database and Amazon Rds, and the tables on
Amazon are namespaced with Rds::TableName.
My controller spec looks something like:
describe MyFirstController do
set_fixture_class :users => Rds::User
describe 'my test' do
it 'should do something' do
joe = users(:joe)
This works fine when running just this controller's spec. But when I
run all the controller specs, the error I get is:
Failure/Error: joe = users(:joe)
No class attached to find.
I have isolated the problem to the interaction between two controller
specs, MyFirstController (which contains set_fixture_class) and
MySecondController (which does not contain set_fixture_class). When
the tests for MyFirstController are run before the tests for
MySecondController, everything works fine. But when the order is
reversed, I get the above errors.
Any ideas on what I might be able to do to fix this (besides requiring
MyFirstController to run first)?
More information about the rspec-users