使用 selenium 驱动程序时 authlogic 无法与水豚一起工作
我的所有水豚测试都使用默认驱动程序与我的 authlogic 成员区域一起工作,但是当我更改一个测试以使用 selenium 驱动程序(因为其中包含 ajax)时,它会给出我的论文错误:
You must activate the Authlogic::Session::Base.controller with a controller object before creating objects
事情正在使用 authlogic 的默认驱动程序工作,因此必须与硒有关吗?
我已将 Authlogic::TestCase 包含在我的 spec_helper 中以及
activate_authlogic
domain.user_sessions.create(user)
每个之前的内容中。
请有人帮我解决这个问题吗?
谢谢里克
I have all my capybara tests working with my authlogic members area using the default driver, but when i change one test to use selenium driver as it has ajax in it, it gives my theis error :
You must activate the Authlogic::Session::Base.controller with a controller object before creating objects
Things are working with default driver for authlogic so must be something to do with selenium ??
I have include Authlogic::TestCase in my spec_helper and
activate_authlogic
domain.user_sessions.create(user)
in a before each.
Any one help me with this please ?
thanks rick
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我在这里发布了一个黄瓜解决方案: 通过 authlogic 登录,无需每次都填写表单
对于 RSpec 集成测试,情况类似。
在您的spec_helper.rb中:
显然,如果您的站点不是仅登录的,您可能需要将 config.before 中的两行移动到登录规范的特定测试中的 before 块中。如果您保持原样,您可以使用
UserSession.find.destroy
删除会话,或者直接点击注销链接(如果这在您的规范中更有意义)。I posted a cucumber solution here: Log-in through authlogic without having to fill in form every time
For RSpec integration tests it's similar.
In your
spec_helper.rb
:Obviously, if your site is not login only you may want to move the two lines in config.before into a before block in your specific test for logged in specs. If you leave as is you can delete the session with
UserSession.find.destroy
or obviously follow the logout link (if this makes more sense in your spec).我认为以下代码将用于激活 authlogic:
话虽如此,我更喜欢定义一个实际进入登录表单、填写并登录的步骤。它速度较慢,但我很少手动运行整个集成测试套件,通常持续集成服务器会处理这个问题。
I think the following code will work to activate authlogic:
Having said that, I prefer defining a step that actually goes to the login form, fills it out, and logs in. It's slower, but I rarely run my entire integration test suite manually, usually the continuous integration server takes care of that.
这对我有用(Rails 3.2.1):
在spec_helper.rb中
在我的controller_specs中:
享受!
This work for me (Rails 3.2.1) :
In spec_helper.rb
In In my controller_specs :
Enjoy!