我正在寻找帮助测试黄瓜的omniauth认证.我尝试过一个教程(http://samuelmullen.com/2011/05/simple-integration-testing-with-cucumber-and-omniauth/),但似乎根本没有调用会话控制器.
这是我到目前为止:
功能/支持/ env.rb:
Capybara.default_host = 'example.org' OmniAuth.config.test_mode = true OmniAuth.config.add_mock(:twitter, { :uid => '12345', :info => { :name => 'twitteruser', } }) OmniAuth.config.add_mock(:facebook, { :uid => '12345', :info => { :name => 'facebookuser' } })
步骤定义:
Given /^I am signed in with provider "(.*)"$/ do |provider| visit "/auth/#{provider.downcase}" end
场景:
Scenario: a user can log into facebook Given I am signed in with provider "facebook" And I am on the profile page for "facebookuser" Then I should see "facebookuser"
任何线索为什么这不起作用?:/.谢谢!
将env.rb的内容更改为此,现在可以正常工作.
Before('@omniauth_test') do OmniAuth.config.test_mode = true Capybara.default_host = 'http://example.com' OmniAuth.config.add_mock(:twitter, { :uid => '12345', :info => { :name => 'twitteruser', } }) OmniAuth.config.add_mock(:facebook, { :uid => '12345', :info => { :name => 'facebookuser' } }) end After('@omniauth_test') do OmniAuth.config.test_mode = false end