2018-09-03 20:48:28 +02:00
|
|
|
namespace :factory_bot do
|
2018-09-03 20:44:39 +02:00
|
|
|
desc "Verify that all FactoryBot factories are valid"
|
2016-02-19 10:59:50 +05:30
|
|
|
task lint: :environment do
|
|
|
|
|
if Rails.env.test?
|
2021-08-18 14:05:19 +02:00
|
|
|
conn = ActiveRecord::Base.connection
|
|
|
|
|
conn.transaction do
|
2018-09-03 20:44:39 +02:00
|
|
|
FactoryBot.lint
|
2021-08-18 14:05:19 +02:00
|
|
|
raise ActiveRecord::Rollback
|
2016-02-19 10:59:50 +05:30
|
|
|
end
|
|
|
|
|
else
|
2021-08-18 14:05:19 +02:00
|
|
|
raise "\nERROR: You should not run this outside the test environment...\n\n"
|
2016-02-19 10:59:50 +05:30
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|