Sign in through GitHub

Please read for an updated status on RailsCasts:

Learn more or hide this

mariobischof's Profile

GitHub User: mariobischof

Comments by

Avatar

hi there, I had some problems with factory_girl, actual versions syntax is a bit different (Link). This factories.rb accomplished the same job (as in the screencast):

ruby
FactoryGirl.define do
  sequence :email do |n|
    "email#{n}@factory.com"
  end
  factory :user do
    email
    password "secret"
    password_confirmation "secret"
  end
end

you can create a user in your specs with:

ruby
user = FactoryGirl.create :user

I'm also using database_cleaner to get my db into a clean state for the tests (Link), because some of the changes to the database weren't rolled back after the tests when using factory_girl and I got failures in further test-runs (I needed version 1.0.1, because 1.1.1 generates a bug if using sqlite-db Link).
Adding this line to my Gemfile under the test group definition does the fix:

ruby
gem "database_cleaner", '1.0.1'

Database_cleaner is quite easy to setup and seems to work pretty neat.

Maybe someone runs into the same problems, it took me quite a bit of googling to get everything together with the current sw-versions, so I thought I'd post it here. Cheers!