[UPDATE] : Unfortunately, I have really odd results with this method. I'll post the right method when I find it ! Sorry !
Recently, I decided to give a chance to Authlogic. Authlogic is a very powerful auth framework. I must admin I miss the simplicity of Clearance, but nevermind.
Authlogic has a lot of doc, including for testing. Anyway, the testing doc is only about Test::Unit, and I mostly use cucumber + shoulda currently.
If you want to test authlogic with cucumber, just add to your step file (features/steps/authentication_steps.rb in my case) :
Before doAnd that's all !
include Authlogic::TestCase
activate_authlogic
end
Now, you can write a step like :
Given /^I am a signed in user$/ doand that's ALL. Don't require anything, config.gem is already loading everything for you.
@user = Factory(:user) # or use fixtures, mocks, whatever !
assert @user_session = UserSession.create(@user)
assert_equal controller.session["user_credentials"], @user.persistence_token
end
Can't understand why this simple wasn't on the net before :)
Happy testing !
0 comments:
Post a Comment