如何使用Authlogic_RPX和Steak测试用户特征?
我正在尝试测试用户应登录的 Rails 3 应用程序的功能。
我使用 authlogic_rpx 通过 Facebook 和 Twitter 对用户进行身份验证,但我不想测试该过程。我正在寻找的是以编程方式创建用户会话。
我尝试将其添加到我的 Acceptance_helper.rb 文件中:
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
并像这样进行测试:
scenario "Sign in" do
user = Factory(:user)
UserSession.create(user)
visit root_path
save_and_open_page
end
但是 @current_user 变量看起来为空。 (我在任何地方都使用它来查看用户是否已登录。)
有什么想法吗?
凯文
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 has signed in.)
Any idea?
Kevin
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论