Search code examples
ruby-on-railsrspecwebmock

Webmock stub request with any body and header


How to use Webmock to stub request with any body and header? I tried to use regex

WebMock.stub_request(:post, 'api.quickblox.com/').with(:body => /.*?/, :headers => /.*?/).to_return(:status => 201, :body => "", :headers => {})

in rspec but it doesn't work, it has

NoMethodError:
   undefined method `map' for /.*?/:Regexp

Solution

  • Check out the Webmock docs on headers. You need to provide it a hash with further details on what you are matching.