Rspec 将多个请求存根到同一uri

Rspec 将多个请求存根到同一uri,rspec,webmock,Rspec,Webmock,我想对不同的请求参数使用相同的uri,我如何才能做到这一点? 下面的示例似乎不起作用( 从文档中可以看出,with子句是不正确的(您应该使用body:{email:foo@bar.de“}或类似内容) 根据文档所述,with子句不正确(您应该使用正文:{email:foo@bar.de“}或类似内容) stub_request(:post, "http://tests/1/users/create"). with({email: 'wrong_format'}).

我想对不同的请求参数使用相同的uri,我如何才能做到这一点? 下面的示例似乎不起作用(


从文档中可以看出,with子句是不正确的(您应该使用
body:{email:foo@bar.de“}
或类似内容)


根据文档所述,with子句不正确(您应该使用
正文:{email:foo@bar.de“}
或类似内容)

  stub_request(:post, "http://tests/1/users/create").
      with({email: 'wrong_format'}).
      to_return(status: 400, body: {msg: 'Bad request'}.to_json, headers: {})

  stub_request(:post, "http://tests/1/users/create").
      with(email: "test@mail.com").
      to_return(status: 200, body: {msg: 'Thanks for signing up for us'}.to_json, headers: {})