This would be the same functionality as Webmock. Except it would take a cassette instead of a string.
Something like expect(Webmock)to receive...
There is a config for this: match_requests_on
.
Defaults to [:method, :uri]
VCR.configure do |config|
config.default_cassette_options[:match_requests_on] = [:method, :uri, :body, :headers]
end
There is one more use case. Even if you match method, uri, body and headers, the spec will still pass even if the app does not make the expected requests.
To handle this, I write the url, headers and body as JSON to a file.
Then, in the spec use Webmock to validate it:
message = JSON.parse(File.read(f), symbolize_names: true)
expect(WebMock).to have_requested(:post, message[:url])
.with(headers: message[:headers], body: message[:body])