On 16 May 2011 16:29, S Ahmed <sahmed1...@gmail.com> wrote:
> 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.

It would be easier to help if you could share the error you get when
your validation line is left in.

Also, there is a factory_girl mailing list that might be more
appropriate for this question (assuming the problem is indeed with
factory_girl):

  https://groups.google.com/forum/#!forum/factory_girl

Chris
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to