Last active
October 4, 2015 09:10
-
-
Save ecoologic/8ec356ca7053ed3e9bb7 to your computer and use it in GitHub Desktop.
Rails seeds specs example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Wrap in transaction, it's quicker | |
# and if something fails it will be easier to re-run them separately | |
ActiveRecord::Base.transaction do | |
User.create!(email: "[email protected]", etc: :etc) # Don't use FactoryGirl | |
end | |
# And they can be tested as follows | |
# spec/db/seed_spec.rb | |
require "rails_helper" | |
describe "Seeds" do | |
before { require "#{Rails.root}/db/seeds.rb" } | |
it "creats the seeds" do | |
expect(User.count).to eq 1 | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment