0

我的 Cucumber 场景用于测试来自第三方提供商的身份验证。发生的情况是,当在我的注册页面上单击 facebook 连接按钮时,重定向会转到 Facebook,当凭据由 Facebook 授权时,重定向会返回到我的网站。

在我的 selenium 测试中,它使用重定向的开发数据库。我知道这一点,因为它最终出现在一个页面上,其中有数据,因为测试数据库是空的,所以不应该出现这种情况。

功能/身份验证。功能:

  @javascript
  Scenario: Signup through Facebook
    When I am on the signup page
    And I click the Facebook authentication link
    And I fill and submit the Facebook form
    Then I should be on the Add additional information page

I should be on the Add additional information page一步失败了,因为我从来没有到达那里。这意味着 facebook 用户存在一个数据行,这意味着它使用开发数据库。有没有我缺少的设置?

功能/支持/env.rb

require 'cucumber/rails'

ENV["RAILS_ENV"] ||= 'test'
require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')
Capybara.default_selector = :css
Capybara.javascript_driver = :webkit
Capybara.app_host = "http://localhost:3000"

# factory_girl Factory definitions
Dir[(Rails.root + "spec/factories/**/*.rb").to_s].each {|factory| require factory}

ActionController::Base.allow_rescue = false

Cucumber::Rails::Database.javascript_strategy = :truncation
Cucumber::Rails::World.use_transactional_fixtures = true
4

2 回答 2

0

删除Capybara.app_host = "http://localhost:3000" 您正在开发环境中运行服务器并让 Capybara 使用它。

于 2012-05-17T03:51:56.867 回答
0

如果这是 facebook 回调的必要性,那么请确保您的开发服务器正在测试环境中运行

   Capybara.app_host = 'http://localhost:3000'
   Capybara.always_include_port = false

使用

rails s --environment=test
于 2013-05-31T07:01:04.690 回答