Skip to content

Instantly share code, notes, and snippets.

@yhirano55
Last active January 16, 2020 19:30
Show Gist options
  • Save yhirano55/9a062e35f79fc27a3ddbcde3572e77d8 to your computer and use it in GitHub Desktop.
Save yhirano55/9a062e35f79fc27a3ddbcde3572e77d8 to your computer and use it in GitHub Desktop.
Run in CI: RAILS_ENV=test bundle exec rails db:seed_fu:lint
# lib/tasks/seed_fu/lint.rake
namespace :db do
namespace :seed_fu do
desc 'Verify that all fixtures are valid'
task lint: :environment do
if Rails.env.test?
conn = ActiveRecord::Base.connection
%w[development test production].each do |env|
conn.transaction do
SeedFu.seed("db/fixtures/#{env}")
raise ActiveRecord::Rollback
end
end
else
system("bundle exec rails db:seed_fu:lint RAILS_ENV='test'")
fail if $?.exitstatus.nonzero?
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment