ruby on rails - capybara,地址已经在使用- bind(2)为127.0.0.1:3000



我正在运行一个特性规范来测试一些Rails代码。规范运行良好,然而,有一些js需要测试。

根据文档,我在场景中添加了:js => true标志。但是,当我这样做时,我得到以下错误:

Failures:
  1) User can check off items as being owned user can check off an item on the checklist
     Failure/Error: Unable to find matching line from backtrace
     Errno::EADDRINUSE:
       Address already in use - bind(2) for 127.0.0.1:3000
     # /Users/agazoom/.rvm/gems/ruby-2.2.1@kollista/gems/rack-1.6.0/lib/rack/handler/webrick.rb:32:in `new'
     # /Users/agazoom/.rvm/gems/ruby-2.2.1@kollista/gems/rack-1.6.0/lib/rack/handler/webrick.rb:32:in `run'
     # /Users/agazoom/.rvm/gems/ruby-2.2.1@kollista/gems/capybara-2.4.4/lib/capybara.rb:173:in `run_default_server'
     # /Users/agazoom/.rvm/gems/ruby-2.2.1@kollista/gems/capybara-2.4.4/lib/capybara.rb:359:in `block (2 levels) in <top (required)>'
     # /Users/agazoom/.rvm/gems/ruby-2.2.1@kollista/gems/capybara-2.4.4/lib/capybara/server.rb:70:in `call'
     # /Users/agazoom/.rvm/gems/ruby-2.2.1@kollista/gems/capybara-2.4.4/lib/capybara/server.rb:70:in `block in boot'

测试列在下面。这很奇怪,因为当我删除js标志时,事情运行良好:

scenario "user can check off an item on the checklist", :js => true do
   visit root_path
   expect(page).to have_title("agazoom")
end

我做了一些实验,发现当我关闭webkit时,测试工作。基本上,看起来Capybara试图使用与webkit相同的端口,但在使用js时失败了。不要问我为什么或怎么做的细节。

所以,我只是改变了Capybara在'rails_helper'中运行的端口:

Capybara.configure do |config|
  .
  .
  config.server_port = 3001
end

相关内容

  • 没有找到相关文章

最新更新