首页 > 解决方案 > Capybara 测试:VCR::Errors::UnhandledHTTPRequestError:如何解决有关 VCR 的错误?请指导

问题描述

单击“添加新位置”之前触发了一个错误,因为它使用的是 ajax,所以我将 selenium 驱动程序添加到修复了错误的测试中。但是然后单击链接会导致 vcr 错误

Profiles Locations tab shows location data
     Failure/Error: visit new_user_session_path

     VCR::Errors::UnhandledHTTPRequestError:

 An HTTP request has been made that VCR does not know how to handle:
         GET http://127.0.0.1:54745/__identify__

为了解决这个错误,我在 VCR 配置中添加了 c.ignore_localhost = true

VCR.configure do |c|
  c.cassette_library_dir = 'spec/vcr'
  c.hook_into :webmock
  c.configure_rspec_metadata!
  # c.debug_logger = STDOUT
  c.ignore_localhost = true

并将 VCR.use_cassette('your_service_response') 添加到我的位置测试中。然后这导致了另一个错误

An error occurred in a `before(:suite)` hook.
Failure/Error: Requesty::Physical::Request.__elasticsearch__.create_index!

Faraday::ConnectionFailed:
  Failed to open TCP connection to localhost:9200 (Connection refused - connect(2) for "localhost" port 9200)

关于我如何解决这个问题的任何建议?

标签: ruby-on-railsrubyselenium-webdriverrspeccapybara

解决方案


推荐阅读