我已经用split_client gem做了AB测试的split io(https:/help.split.iohcen-usarticles360020673251-Ruby-SDK。但是当我尝试运行测试时,我得到了以下错误信息
stub_request(:post, "https://events.split.io/api/metrics/time").
with(
body: "{\"name\":\"splitChangeFetcher.time\",\"latencies\":[292.122]}",
headers: {
'Accept'=>'*/*',
'Accept-Encoding'=>'gzip,deflate',
'Authorization'=>'Bearer 4354t',
'Connection'=>'keep-alive',
'Content-Type'=>'application/json',
'Keep-Alive'=>'30',
'Splitsdkmachineip'=>'0.0.0.1',
'Splitsdkmachinename'=>'local',
'Splitsdkversion'=>'ruby-7.0.3',
'User-Agent'=>'Ruby'
}).
to_return(status: 200, body: "", headers: {})
我试着在spec_helper中像下面这样支管这个请求
config.before :each do
stub_request(:any, /events.split.io/)
.to_return(status: 200, body: "", headers: {})
end
但在运行测试后,我还是会随机出现错误。那么是什么原因导致了这个问题,有什么替代方案或解决办法。
我认为你应该明确地禁用http请求。在我的例子中,我使用了 webmock
和我写的。
setup do
WebMock.enable!
end
这只是对下一次搜索解决方案的建议。