Using global_fixtures prevents use of set_fixture_class #853

ajh opened this Issue Nov 21, 2013 · 2 comments

4 participants


I'm finding that if you

  1. have a model that has a module name or otherwise violates the standard active record naming conventions,
  2. and its fixtures are global,

then I'll get an error like this (for a tags.yml fixture file for

Unable to load tag, underlying cause No such file to load -- tag
activesupport-3.2.12/lib/active_support/dependencies.rb:317:in `rescue in depend_on'
activesupport-3.2.12/lib/active_support/dependencies.rb:312:in `depend_on'
activesupport-3.2.12/lib/active_support/dependencies.rb:225:in `require_dependency'
activerecord-3.2.12/lib/active_record/fixtures.rb:767:in `try_to_load_dependency'
activerecord-3.2.12/lib/active_record/fixtures.rb:782:in `block in require_fixture_classes'
activerecord-3.2.12/lib/active_record/fixtures.rb:779:in `each'
activerecord-3.2.12/lib/active_record/fixtures.rb:779:in `require_fixture_classes'
activerecord-3.2.12/lib/active_record/fixtures.rb:762:in `fixtures'
rspec-rails-2.14.0/lib/rspec/rails/fixture_support.rb:26:in `block in <module:FixtureSupport>'

Normally when a model runs contrary to the naming conventions, active record fixtures can be told the class name of a fixture file using ActiveRecord::TestFixtures.set_fixture_class. This is documented here:

And I think this would work in rspec if I weren't using global fixtures. However with global fxitures there doesn't seem to be a way to use this api between when Rspec::Rails::Rails::FixtureSupport is included and when line #26 of lib/rspec/rails/fixture_support.rb is run which loads all the fixtures.

Seems like a solution would be to have rspec configuration for set fixture class similar to fixture_path, use_transactional_fixtures and use_instantiated_fixtures?

@cupakromer cupakromer removed this from the 3.0.0 milestone Apr 28, 2014


RSpec member

@cupakromer is this still valid? @ajh can you provide a reproduction case against RSpec rails master and a rails 4.x version?

Specifically for a repro case we'd look for

1) a rails app you generate with "rails new" and then commit
2) a second commit which adds all the things that demonstrate the bug.

@samphippen samphippen closed this Apr 2, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment