Webmock: Documentation: Stubbing a request with any query

Created on 9 Mar 2017  路  4Comments  路  Source: bblimke/webmock

I haven't found how to do this in the examples, so I'm filing this as a documentation issue.

How do I stub a request to a particular URL ("example.com/a/b"), not caring about the query string?

If I only stub the URL, it doesn't hit the stub.

Most helpful comment

@joallard alternatively .with(query: hash_including({}) but it's also a workaround.

WebMock treats query as part of the url (well, it is), therefore if it's empty, it expects it to be empty.
Perhaps that should be changed in the future.

All 4 comments

How about regular expression?
https://github.com/bblimke/webmock#matching-uris-using-regular-expressions

That's how I worked around it. I thought there'd be a first class way to do this, okay then

@joallard alternatively .with(query: hash_including({}) but it's also a workaround.

WebMock treats query as part of the url (well, it is), therefore if it's empty, it expects it to be empty.
Perhaps that should be changed in the future.

Thanks @bblimke !

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Integralist picture Integralist  路  5Comments

majioa picture majioa  路  4Comments

Morred picture Morred  路  14Comments

lokenmakwana picture lokenmakwana  路  6Comments

Watson1978 picture Watson1978  路  4Comments