[rspec-users] factory girl rspec and authlogic

Don French dhf0820 at gmail.com
Sat Oct 3 20:41:49 EDT 2009

I am trying some simple test using the above items. Using the
Factory.create(...) gives Active Record errors and not the failure of
the test. Change it to u = Factory.build(...) then u.save, I do not
get the Active record error but the proper test failure message.

  it 'requires email' do
    lambda do
      u = Factory.create(:valid_user, {:email => nil})
      u.errors.on(:email).should_not be_nil
    end.should_not change(User, :count)

ActiveRecord::RecordInvalid in 'User requires email'
Validation failed: Email is too short (minimum is 6 characters), Email
should look like an email address.

  it 'requires email' do
    lambda do
      u = Factory.build(:valid_user, {:email => nil})
      u.errors.on(:email).should be_nil
    end.should change(User, :count)
fails properly with
'User requires email' FAILED
expected nil, got ["is too short (minimum is 6 characters)", "should
look like an email address."]

It does not matter whether the first test above is above is set up as
a failing or passing test  I get the same results, ActiveRecord errors
instead of Rspec messages.

I am not sure if this is a FactoryGirl issue or Rspec issue, or me
screwing up.


More information about the rspec-users mailing list