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.save
u.errors.on(:email).should_not be_nil
end.should_not change(User, :count)
end
returns:
ActiveRecord::RecordInvalid in 'User requires email'
Validation failed: Email is too short (minimum is 6 characters), Email
should look like an email address.
./spec/models/user_spec.rb:34:
./spec/models/user_spec.rb:33:
However:
it 'requires email' do
lambda do
u = Factory.build(:valid_user, {:email => nil})
u.save
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."]
./spec/models/user_spec.rb:36:
./spec/models/user_spec.rb:33:
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.
Thanks
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users