Authlogic: Trying to login in my Cucumber test - Authlogic::Session::Activation::NotActivatedError

In a Cucumber step definition, I'm trying to login, but I keep getting this error:

You must activate the Authlogic::Session::Base.controller with a controller object before creating objects (Authlogic::Session::Activation::NotActivatedError)

My code:

Given /^I am the logged in (.+) "(.+)"$/ do |role, login|   user = User.create!(     :login => login,     :password => "some_password",     :password_confirmation => "some_password",     :role => role,     :email => "some_email@somewhere.com"   )   #Authlogic::Session::Base.controller = Authlogic::ControllerAdapters::RailsAdapter.new(self)   UserSession.create(     :login => login,     :password => "some_password"   ) end

I found that commented out bit - Authlogic::Session::Base.controller = Authlogic::ControllerAdapters::RailsAdapter.new(self) - online, but it leads to "save" not working.

Assistance greatly appreciated!

daze <dmonopoly10@...> writes:

In a Cucumber step definition, I'm trying to login, but I keep getting this error:

You must activate the Authlogic::Session::Base.controller with a controller object before creating objects (Authlogic::Session::Activation::NotActivatedError)

Are you using confirmable? It looks like the user is not confirmed. Luckily, devise has a trick for that:

My code:

Given /^I am the logged in (.+) "(.+)"$/ do |role, login|   user = User.create!(     :login => login,     :password => "some_password",     :password_confirmation => "some_password",     :role => role,     :email => "some_email@..."   )

Try

Given /^I am the logged in (.+) "(.+)"$/ do |role, login|    user = User.create!(      :login => login,      :password => "some_password",      :password_confirmation => "some_password",      :role => role,      :email => "some_email@..."    ).confirm!

Note the "confirm!" method call.

Thanks, but I'm not using Devise; I'm using Authlogic, so I get the error,

undefined method 'confirm!'

There must be a straight-forward way to do this with Authlogic...