[rspec-users] odd fixture behavior

Ben Mabey ben at benmabey.com
Tue Apr 29 23:14:43 EDT 2008

Ben Mabey wrote:
> Hello all,
> I am upgrading an older app from rails 1.2.3 to rails 2.0.2 and am 
> upgrading rspec and rspec-on-rails to 1.1.3 in the process.
> After upgrading I am getting some weird errors relating to fixtures.  
> Most of the model example groups have fixtures declared at the top.  
> What is odd is that I can run any given spec file individually with 
> the spec command and they run just fine.  However, when I run all the 
> specs with rake spec certain spec groups fail due to fixtures not 
> being loaded properly.  Meaning, the DB should of been populated by 
> the fixtures but in the specs the tables are empty.  I have ran 
> './script/generate rspec' and in my spec_helper.rb I have:
> Spec::Runner.configure do |config|
>  config.use_transactional_fixtures = true
>  config.use_instantiated_fixtures  = false
> I know that rspec just relies on the test::unit fixture framework that 
> rails provides so this isn't really a rspec issue but I'm hoping that 
> someone on this list may have some ideas on what could be going wrong 
> here.  Were there changes to the way fixtures worked in rails 2.0 that 
> would effect how I am doing things?  I haven't used fixtures for ever 
> (switched to a factory instead) so I haven't really kept up with there 
> changes.... Any ideas on what could be wrong or how I could 
> troubleshoot this problem would be greatly appreciated.  Thanks,
> Ben
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users

Okay.. nm... I resolved the issue.  I don't know exactly what was wrong 
and I don't want to take the time/energy to figure it out... but 
something with my before(:all)'s were not playing well with the 
fixtures.  By changing some of them to before(:each)'s it seemed to fix 
the problem.  My best guess is that my before all's were dependent on 
the fixtures already being loaded when they were ran but that is not the 
case anymore.
Sorry for the spam... Thanks,

More information about the rspec-users mailing list