Same requests are recorded only once in vcr Show archive.org snapshot . Replaying a test fails, if you trigger the same request multiple times. The error message is somehow confusing, as your cassette contains the request:
An HTTP request has been made that VCR does not know how to handle
If you want to allow to match a request multiple times, you need to configure this explicit with allow_playback_repeats: true Show archive.org snapshot . Some example configurations:
# specific cassette only
VCR.use_cassette('example', :allow_playback_repeats => true) do
puts response_body_for(:get, 'http://example.com/foo')
puts response_body_for(:get, 'http://example.com/foo')
puts response_body_for(:get, 'http://example.com/foo')
end
# cucumber only
VCR.cucumber_tags do |t|
t.tag '@vcr',
use_scenario_name: true,
allow_playback_repeats: true
end
# globally
VCR.configure do |config|
config.default_casette_options = { allow_playback_repeats: true }
end
Use this option with caution, as there are many scenarios where the response changes for the same request!
If this doesn't help, you might find these topics useful:
VCR has different matchers Show archive.org snapshot (:method (default enabled), :uri (default enabled), :body, :headers, :host, :path, :query). If e.g. your params have a different order, this might fail in the comparison of equality:
Using javascript in integration tests might cause issues that AJAX requests are not recorded or bleed in other scenarios: