test with cucumber

12 views
Skip to first unread message

enrico

unread,
Feb 15, 2009, 7:01:35 AM2/15/09
to Authlogic
Hi,
I'm writing cucumber features for my app, and I can't find why
Authlogic isn't behaving as expected (by me).

This one is via webrat:
# visit ("/user_session/new")
# fill_in('Login', :with => @member.login)
# fill_in('Password', :with => "password")
# click_button("Login")

but even a simpler:
post "/user_sessions/create", :user_session => {:login =>
@member.login, :password => "password"}

returns error on the password. If I run a debug and check the content
of @user_session I get:
#<Authlogic::Session::Errors:0x3ba77c0 @errors={"password"=>["is not
valid"]}, @base=#<UserSession
{:password=>"<protected>", :login=>"enrico1"}>>

At first it looked like it was assigning a password "<protected>"
insted of the one I submitted. But I've found out it normally does
that when the real app runs:
@user_session = UserSession.new(params[:user_session])
if @user_session.save

anybody using cucumber have a clue?
Cheers,
Enrico

Ben Johnson

unread,
Feb 15, 2009, 1:51:41 PM2/15/09
to auth...@googlegroups.com
It's call valid_password? on your user model, do some debugger in
there to see what the deal is. Is "password" the correct password? Are
you storing this value in your fixtures correctly?

Authlogic::CryptoProviders::Sha512.encrypt("benrocks" + salt)



Ben Johnson
Binary Logic

W: www.binarylogic.com
E: bjoh...@binarylogic.com

1430 Broadway
7th Floor - NECO
New York, NY 10018

Enrico Teotti

unread,
Feb 16, 2009, 6:45:20 AM2/16/09
to auth...@googlegroups.com
it's all good, I am not using fixtures but Factories.
Factory.define :user do |u|
u.login Factory.next :login
u.password "password"
u.password_confirmation "password"
end
now it works fine.

I was adding (without any reason) the fields you have in the example
fixture (password_salt, crypted_password etc...) :P
Cheers,
Enrico

2009/2/16 Ben Johnson <bjoh...@binarylogic.com>:
--
Enrico Teotti
IT consultant, accessible web sites and web applications
Sydney, NSW, Australia
enrico...@gmail.com
mobile (IT) +393286590765
mobile (AU) +00610416748450

http://www.teotti.com
Reply all
Reply to author
Forward
0 new messages