Ruby on rails 将窗体切换到远程:真正中断VCR
我有一个像这样的测试Ruby on rails 将窗体切换到远程:真正中断VCR,ruby-on-rails,rspec,vcr,Ruby On Rails,Rspec,Vcr,我有一个像这样的测试 RSpec.describe 'Modify visit summary letters', type: :system do scenario 'with one correspondence relationship' do VCR.use_cassette 'correspondence/faxes/valid_number' do # test steps omitted for brevity end end end 这个测试
RSpec.describe 'Modify visit summary letters', type: :system do
scenario 'with one correspondence relationship' do
VCR.use_cassette 'correspondence/faxes/valid_number' do
# test steps omitted for brevity
end
end
end
这个测试通常通过得很好。但是,当我将某个表单从remote:false
更改为remote:true
(明确地说,我正在更改此表单,而没有其他内容)时,测试停止工作
当我在remote:true
更改后运行测试时,我得到:
VCR::Errors::UnhandledHTTPRequestError:
================================================================================
An HTTP request has been made that VCR does not know how to handle:
POST https://rest.interfax.net/outbound/faxes?faxNumber=%2B15555555555
There is currently no cassette in use.
上面说没有录音带在使用,尽管很明显,有
为什么会发生这种情况?我能做些什么来修复它
编辑:这是我的VCR配置
VCR.configure do |c|
c.cassette_library_dir = 'spec/cassettes'
c.hook_into :webmock
c.ignore_localhost = true
c.ignore_hosts 'chromedriver.storage.googleapis.com'
c.default_cassette_options = {
match_requests_on: [
:method,
VCR.request_matchers.uri_without_param('faxNumber')
]
}
end
该消息的一个原因是请求URL与磁带URL不匹配。我想不出为什么
remote:true
会影响到这一点,但至少需要对照磁带中的内容进行检查。您还可以通过在VCR配置块中粘贴c.debug_logger=$stderr
来打开VCR的调试。这也许能说明发生了什么。不幸的是,事实并非如此。URL是相同的。不幸的是,调试输出也没有透露任何有助于我理解的信息。这可能与请求是异步的并且在VCR处理的线程之外运行有关吗?@max我想到了这一点——也许是这样。不过,不确定从哪里开始。VCR不仅通过URI匹配磁带,还请提供您的VCR配置。