RailsCasts Pro episodes are now free!

Learn more or hide this

mariobischof's Profile

GitHub User: mariobischof

Comments by


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):

FactoryGirl.define do
  sequence :email do |n|
  factory :user do
    password "secret"
    password_confirmation "secret"

you can create a user in your specs with:

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:

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!