通过标签将 VCR 与 Cucumber 一起使用
我有一些 Cucumber 功能需要与 Google Maps Routing API 交互。我正在尝试使用 VCR 来消除这些交互。
我已经在我的功能中添加了一个 VCR 标签,如下所示:
@google_routing_api @javascript
Scenario: Creating a bus
Given I am on the buses page
When I follow "Get Started Now"
然后在 features/support/vcr.rb
中添加了我的 VCR 配置
require 'vcr'
VCR.config do |c|
# INFO: This is relative to the Rails.root
c.cassette_library_dir = 'features/fixtures/vcr_cassettes'
c.stub_with :fakeweb
end
# INFO: https://github.com/myronmarston/vcr/wiki/Usage-with-Cucumber
VCR.cucumber_tags do |t|
t.tag '@google_routing_api'
end
但是当我运行我的 cukes 时,我被告知..
Real HTTP connections are disabled. Unregistered request: GET http://127.0.0.1:54181/__identify__
I have some Cucumber features which need to interact with the Google Maps Routing API. I'm trying to stub out these interactions using VCR.
I have added a VCR tag to my features like so:
@google_routing_api @javascript
Scenario: Creating a bus
Given I am on the buses page
When I follow "Get Started Now"
And then added my VCR configuration in features/support/vcr.rb
require 'vcr'
VCR.config do |c|
# INFO: This is relative to the Rails.root
c.cassette_library_dir = 'features/fixtures/vcr_cassettes'
c.stub_with :fakeweb
end
# INFO: https://github.com/myronmarston/vcr/wiki/Usage-with-Cucumber
VCR.cucumber_tags do |t|
t.tag '@google_routing_api'
end
But when I run my cukes, I am told..
Real HTTP connections are disabled. Unregistered request: GET http://127.0.0.1:54181/__identify__
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须将 VCR 设置为忽略本地主机请求。否则,当水豚尝试从您的网站请求任何页面时,VCR 将阻止它。
将
c.ignore_localhost = true
添加到您的 VCR 配置块中。You have to set VCR to ignore localhost requests. Otherwise, when capybara tries to request any page from your website, VCR will block it.
Add
c.ignore_localhost = true
to your VCR config block.