Rails 3.1 capybara javascript测试访问被拒绝

时间:2011-09-05 06:29:48

标签: javascript cucumber ruby-on-rails-3.1 capybara

我刚刚升级到Rails 3.1,现在当我尝试使用@javascript标签运行我的黄瓜(水豚)测试时,我收到以下错误:

The requested URL could not be retrieved
While trying to retrieve the URL: http://127.0.0.1:9987/login

The following error was encountered
    * Access Denied

我在features / support / env.rb文件中定义了以下内容:

if defined?(ActiveRecord::Base)
  begin
    require 'database_cleaner'
    require 'database_cleaner/cucumber'
    DatabaseCleaner.strategy = :truncation
  rescue LoadError => ignore_if_database_cleaner_not_present
  end
end

Capybara.server_port = 9987 + ENV['TEST_ENV_NUMBER'].to_i

1 个答案:

答案 0 :(得分:1)

您是否已将此服务器端口明确应用于Capybara.app_host?

Capybara.app_host = "http://dev.local:#{Capybara.server_port}"

使用此配置我对当前的Rails 3.1和capybara-webkit没有任何问题。