Skip to content

error running rake test after removing all fixtures files #1

Description

@benhutton

Hey,

I just tracked down a bug in our system that prevented us from running rake test (could still run the individual rake test:units, test:functionals, etc.).

I had gone through and completely removed my fixtures (such that there were no files in the fixtures folder). In the rails_core_ext.rb file, you put the FactoryData.delete_preload_data! function into rails' delete_existing_fixtures function. This in turn gets called at line 511 in activerecord-2.3.5/lib/active_record/fixtures.rb, which is inside the "unless table_names_to_fetch.empty?" block, which will never be executed if there are no fixtures in the test/fixtures directory. This means that the factories would never get unloaded, so the next time they were loaded, I would get all sorts of validation errors ("username already exists", etc.). Does that make sense?

My solution is to just create a blank fixture file (profiles.yml) in the fixtures directory, which causes the loop to be executed, which allows the factories to be unloaded, which allows me to run rake test (and rake rcov).

Maybe my solution is good enough. Just wanted to document it here in case somebody else has the same problem.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions