【发布时间】:2018-07-26 10:47:02
【问题描述】:
我正在尝试在我的规范中阻止 URL,以实现我在使用 capybara_webkit 时所做的事情:
Capybara::Webkit.configure do |config|
config.block_url("*google*")
config.allow_url('*my_website.com')
end
阅读this article后,我尝试做类似的事情:
require 'webmock/rspec'
module WebmockConfig
def self.default_disabled_urls
[
'*google*'
]
end
end
WebMock.disable_net_connect!(allow_localhost: true)
WebMock.disable_net_connect!(allow: WebmockConfig.default_disabled_urls)
但我得到了
真正的 HTTP 连接被禁用。未注册请求:POST http://127.0.0.1/session
即使这应该由WebMock.disable_net_connect!(allow_localhost: true) 解决。
在没有WebMock.disable_net_connect!(allow: WebmockConfig.default_disabled_urls) 的情况下运行规范时,一切正常。
【问题讨论】:
标签: ruby testing rspec capybara webmock