Skip to content

Instantly share code, notes, and snippets.

@gkop
Created June 11, 2015 19:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gkop/e6cd075fe2d41780ba27 to your computer and use it in GitHub Desktop.
Save gkop/e6cd075fe2d41780ba27 to your computer and use it in GitHub Desktop.
seeds_spec.rb
require 'rails_helper'
describe "seeds.rb script" do
def count_all_tables
ActiveRecord::Base.descendants
.sort_by(&:to_s).map(&:count)
end
it "is idempotent" do
load Rails.root.join("db", "seeds.rb")
counts = count_all_tables
load Rails.root.join("db", "seeds.rb")
expect(count_all_tables).to eq(counts)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment