我正在设置我的所有rspec测试,它们工作正常,但其中一些包括对API的调用。因此,对于这些测试,我存根请求。
不幸的是,请求看起来像这样:
stub_request(:get, "https://api.sandbox.mangopay.c['my datas']").
with(:body => "{}",
:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'', 'Content-Type'=>'application/json', 'User-Agent'=>'Ruby', 'X-Mangopay-Client-User-Agent'=>'{"bindings_version":"3.0.21","lang":"ruby","lang_version":"2.3.0 p0 (2015-12-25)","platform":"x86_64-linux","uname":"Linux wolf-N751JK 4.4.0-45-generic #66-Ubuntu SMP Wed Oct 19 14:12:37 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux"}'})
stub_request(:post, "https://api.sandbox.mangopay.com/v2.01/oauth/token").
with(:body => "grant_type=client_credentials",
:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'Basic a3Jhd2RzYXM6eWtVdEdiUHU5NzJBRjc2cEx0YjBLRHJoQTZrMTBCTDVvY3I2ZFBRalpqS1p1RDBlWm4=', 'User-Agent'=>'Ruby'})
请注意这一部分:
Linux wolf-N751JK 4.4.0-45-generic #66-Ubuntu SMP Wed Oct 19 14:12:37 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
我认为它与我的ubunutu版本相关联,这意味着每次我更新我的软件时,我都必须更改每个存根。有没有办法绕过这个?
答案 0 :(得分:0)
您是否尝试过不指定X-Mangopay-Client-User-Agent
标题?