webmock icon indicating copy to clipboard operation
webmock copied to clipboard

Stubbing a request with any query

Open ghost opened this issue 5 years ago • 3 comments

Currently, when I stub a request with any query, below code.

stub_request(:get, 'example.com/search')
  .with(query: hash_including({}))
  .and_return(status: 200)

I suggest below interface. How do you think? If you think it is not sure, please feel free to close.

stub_request(:get, 'example.com/search')
  .with(query: :any)
  .and_return(status: 200)

Reference

  • https://github.com/bblimke/webmock/issues/693

ghost avatar Feb 29 '20 17:02 ghost

I will close because it is inactive

ghost avatar May 15 '20 01:05 ghost

Thank you @taki

Yes, that sounds like much nicer code to read 👍 As long as people get a clear error message in case they provide non String query option and also different than :any. Does anyone fancy submitting a PR? ;)

bblimke avatar Sep 09 '20 14:09 bblimke

stub_request(:get, "some_url")
  .with(query: hash_including)

This works for me

dwy6626 avatar May 14 '21 07:05 dwy6626