“未找到”使用 Capybara 测试omniauth Facebook 身份验证时
我在我的项目中实现了 facebook Omniauth 身份验证系统。我在浏览器中工作得很好,直到今天我已经使用 Capybara 编写并通过了一整套集成测试。
但今天,我运行了测试套件,所有相关测试都失败了。
问题源于此帮助程序模块,该模块在几乎所有测试中都用于模拟 facebook(或其他)身份验证:
module IntegrationSpecHelper
def login_with_oauth service
visit "/auth/#{service}"
save_and_open_page
end
end
这似乎不再起作用,即使它在 2 天前起作用,并且仍然在我的开发服务器上起作用。 “save_and_open_page”显示的页面实际上包含“Not Found”行,仅包含其他内容。
有谁知道这会是什么原因造成的?
I have a facebook Omniauth authentication system implemented in my project. I works fine for me in the browser and up until today I had a full set of integration tests written and passing using Capybara.
Today though, I ran the test suite and all the related tests fail.
The problem stems from this helper module which is used in pretty much all the tests to simulate facebook (or otherwise) authentication:
module IntegrationSpecHelper
def login_with_oauth service
visit "/auth/#{service}"
save_and_open_page
end
end
This doesn't seem to work any more, even though it did 2 days ago, and still works on my development server. The "save_and_open_page" displays a page which literally contains the line "Not Found" and nothing else.
Anyone know what would cause this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
最后我自己想出了这个办法。
基本上我是根据omniauth配置初始值设定项中的环境设置我的身份验证提供程序。我有这样的设置:
如您所见,我忘记提供测试环境的设置,因此我的所有测试都失败了。
Figured this out myself in the end.
Basically I was setting my auth providers based on environment in my omniauth config initializer. I has this setup:
As you can see I forgot to provide a settings for the test environment hence all my tests were failing.
在rails 3中,您可以将每个omniauth配置初始值设定项放入config/environments文件夹中的相应环境文件中,即development.rb、test.rb和Production.rb
In rails 3, you can put each omniauth config initializer in the respective environment file in the config/environments folder i.e. development.rb, test.rb, and production.rb