加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – 使用selenium驱动程序时authlogic不能与capyba

发布时间:2020-12-17 03:35:02 所属栏目:百科 来源:网络整理
导读:我使用默认驱动程序与我的authlogic成员区域进行了所有的capybara测试,但是当我更改一个测试以使用selenium驱动程序,因为它有ajax,它给出了我的theis错误: You must activate the Authlogic::Session::Base.controller with a controller object before cre
我使用默认驱动程序与我的authlogic成员区域进行了所有的capybara测试,但是当我更改一个测试以使用selenium驱动程序,因为它有ajax,它给出了我的theis错误:

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

事情正在使用authlogic的默认驱动程序,所以必须与selenium有关?

我在spec_helper中包含了Authlogic :: TestCase

activate_authlogic
    domain.user_sessions.create(user)

在每个之前.

有人帮我这个吗?

谢谢里克

解决方法

我在这里贴了一个黄瓜解决方案: Log-in through authlogic without having to fill in form every time

对于RSpec集成测试,它是类似的.

在您的spec_helper.rb中:

require "authlogic/test_case"
RSpec.configure do |config|
  ...
  config.include Authlogic::TestCase
  ApplicationController.skip_before_filter :activate_authlogic
  config.before(:each,:type => :request) do
    activate_authlogic
    UserSession.create(User.find_by_email!(email))
  end
  ...
end

显然,如果您的站点不是仅登录,您可能希望将config.before中的两行移动到特定测试中的before块中以获取登录的规范.如果您保持原样,您可以使用UserSession.find.destroy删除会话,或者显然遵循注销链接(如果这在您的规范中更有意义).

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读