I'm trying to test features of my Rails 3 app for which a user should be signed in.
I use authlogic_rpx for authenticating users through Facebook and Twitter, but I don't want to test that process. What I am looking for is to programmatically create a user session.
I tried to add this to my acceptance_helper.rb file:
require "authlogic/test_case"
Spec::Runner.configure do |config|
config.include Authlogic::TestCase, :type => :acceptance
config.before(:each, :type => :acceptance) do
activate_authlogic
end
end
And test like this:
scenario "Sign in" do
user = Factory(:user)
UserSession.create(user)
visit root_path
save_and_open_page
end
But then the @current_user variable looks empty. (I use it everywhere to see if the user ha开发者_StackOverflow社区s signed in.)
Any idea?
Kevin
精彩评论