带有任何正文和标题的 Webmock 存根请求 [英] Webmock stub request with any body and header
本文介绍了带有任何正文和标题的 Webmock 存根请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用 Webmock 存根带有任何正文和标头的请求?我尝试使用正则表达式
How to use Webmock to stub request with any body and header? I tried to use regex
WebMock.stub_request(:post, 'api.quickblox.com/').with(:body => /.*?/, :headers => /.*?/).to_return(:status => 201, :body => "", :headers => {})
在 rspec 但它不起作用,它有
in rspec but it doesn't work, it has
NoMethodError:
undefined method `map' for /.*?/:Regexp
推荐答案
查看 Webmock
文档关于 headers
.您需要向它提供一个哈希值,其中包含有关您匹配的内容的更多详细信息.
Check out the Webmock
docs on headers
. You need to provide it a hash with further details on what you are matching.
这篇关于带有任何正文和标题的 Webmock 存根请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文