Move FactoryGirl.lint to rake task

This significantly improves start time of tests. It is also the recommended
way: https://github.com/thoughtbot/factory_girl/blob/master/GETTING_STARTED.md#linting-factories

Read more at: https://github.com/thoughtbot/factory_girl/issues/772
This commit is contained in:
Aditya Prakash 2016-02-19 10:59:50 +05:30
parent a8b270f6e1
commit f84150362b
2 changed files with 15 additions and 7 deletions

View file

@ -0,0 +1,15 @@
namespace :factory_girl do
desc "Verify that all FactoryGirl factories are valid"
task lint: :environment do
if Rails.env.test?
begin
DatabaseCleaner.start
FactoryGirl.lint
ensure
DatabaseCleaner.clean
end
else
system("bundle exec rake factory_girl:lint RAILS_ENV='test'")
end
end
end

View file

@ -1,7 +0,0 @@
RSpec.configure do |config|
config.before(:suite) do
FactoryGirl.lint
end
end