使用Webmock,我希望简单地返回被调用的身体参数。例如,我调用Mandrill API并传递options
哈希。
我试过这个,但它给了我一个错误:
@mandrill = stub_request(:any, "https://mandrillapp.com/api/1.0/").to_return(body: *)
我怎样才能做到这一点?
解决了!
module ApiStubs
def stub_apis
@mandrill = stub_request(:any, "https://mandrillapp.com/api/1.0/").to_return { |request| {body: request.body} }
end
end