(I'm at the Golden Gate Ruby Conference. If you use authlogic and we
could chat, I'd love to find you.)
I'm having difficulty getting my integration tests working. My site
uses open-id, and I like to NOT test open-id. In my integration test,
I want the test case to set the user. I've modified the spec_helper so
that in the integration test, the current_user is properly set, yet,
my controller shows that current_user is nil. It's my understanding
that these are separate processes. My open-id provider is google.
example test:
let(:user) { Factory(:student_sam) }
it 'only shows content to a logged in user' do
login_user(user)
visit people_path
page.should have_content('Phone book')
end
spec_helper.rb
module LoginHelper
include Authlogic::TestCase
def login_user person
activate_authlogic
@current_user = User.find(
person.id)
UserSession.create(@current_user)
end
def current_user(stubs = {})
#current user could get set when being login_user gets called,
otherwise use a generic mock model
@current_user ||= mock_model("User", stubs)
end
end
include LoginHelper