webmock icon indicating copy to clipboard operation
webmock copied to clipboard

Include documentation RegEx hash_including matcher

Open ChrisBr opened this issue 5 years ago • 1 comments

I just learned about this really cool feature that you can match agains a RegEx in hash_including so I added some documentation for it.

stub_request(:post, "www.example.com").
  with(body: hash_including(id: /\d/))

RestClient.post('www.example.com', "id=1",
:content_type => 'application/x-www-form-urlencoded')    # ===> Success

ChrisBr avatar Jul 31 '20 12:07 ChrisBr

@ChrisBr this only works if we are inside RSpec. WebMock has own limited implementation of hash_including in case hash_including is not already available. Perhaps it's better to mention that in the documentation, that people can take advantage of all RSpec's hash_including goodies as long as it's Rspec.

bblimke avatar Sep 11 '20 10:09 bblimke