4

I'm using Rails 3 rc, Factory Girl, and Rspec, and Authlogic. Is there any way or reason why this would happen:

When I create a user like this:

@user = Factory(:user)

I get an issue with password confirmation being "too short".

my factories.rb is

  Factory.define :user do |u| 
      u.username   "Test User"
      u.email      "TestUser@gmail.com"
      u.password   "aoeuaoeu"
      u.password_confirmation   "aoeuaoeu"
      #u.password_confirmation {|u| u.password}
  end

But when I create one as I pass in :password and :password_confirmation manually, it works just fine.

@user = Factory(:user, :password => "aoeuaoeu", 
                       :password_confirmation => "aoeuaoeu")

Does anyone have any idea what could be causing this?

iwasrobbed
  • 46,496
  • 21
  • 150
  • 195
user384021
  • 51
  • 3

1 Answers1

0

This seems similar to the problem the person here had:

Authlogic and password and password confirmation attributes - inaccessible?

The password and confirmation must be passed in the attributes hash like so:

before(:each) do  
    @attr = {  
    :name => "Example User",  
    :email => "user@example.com",  
    :password => "foobar",  
    :password_confirmation => "foobar"  
    }  
end  

For more info see:

http://railstutorial.org/chapters/modeling-and-viewing-users-two#top

Community
  • 1
  • 1
minikomi
  • 8,363
  • 3
  • 44
  • 51