Running lint in spec_helper/test_helper vs each test suite #620

Closed
garysweaver opened this Issue Feb 20, 2014 · 0 comments

Comments

Projects
None yet
2 participants

The suggestion in the getting started doc is to run FactoryGirl.lint before each suite, which may help with #619 if DatabaseCleaner is automatically wrapping suites to rollback changes that might be inadvertently persisted via builds that called creates.

However, since the factories should only need to be validated once for all tests, maybe instead the suggested practice should be to put the following in spec_helper or test_helper (as mentioned in #619):

begin
  DatabaseCleaner.start
  FactoryGirl.lint
ensure
  DatabaseCleaner.clean
end

That method is rspec/minitest agnostic and limits the number of times build needs to be called, which is a concern for those with a lot of factories.

joshuaclayton added a commit that referenced this issue Feb 26, 2014

Include DatabaseCleaner usage when demoing FactoryGirl.lint
Because built factories create associated records, the database may not
be empty when the suite is run. This encourages developers to start
DatabaseCleaner and clean after linting is complete to ensure a clean
database.

Closes #619, #611, #620
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment