配置Webmock以返回传递的主体哈希

问题描述 投票:0回答:1

使用Webmock,我希望简单地返回被调用的身体参数。例如,我调用Mandrill API并传递options哈希。

我试过这个,但它给了我一个错误:

@mandrill = stub_request(:any, "https://mandrillapp.com/api/1.0/").to_return(body: *)

我怎样才能做到这一点?

ruby-on-rails minitest webmock
1个回答
1
投票

解决了!

module ApiStubs

  def stub_apis
    @mandrill = stub_request(:any, "https://mandrillapp.com/api/1.0/").to_return { |request| {body: request.body} }
  end

end
© www.soinside.com 2019 - 2024. All rights reserved.