class User < ActiveRecord::Base
attr_accessor :password, :password_confirmation
attr_accessible :password, :password_confirmation, ...
validates :password, :presence => true, :confirmation => true, :length =>
{ :within => 6..20 }
end
factory_girl:
Factory.define :user do |u|
u.user_name "test"
u.password "mypassword"
u.password_confirmation "mypassword"
end
user_spec.rb:
describe User do
before(:each) do
@valid_att = Factory.attributes_for(:user)
@user = Factory(:user)
end
end
Now all my user spec tests pass if I comment out the line 'validates
:password....' line in my User.rb model.
It seems that I can't set the attributes password and password_confirmation
in my factory_girl user factory.
I use both @valid_att and @user in my tests, so I need both to contain
correct values for user model.
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users