Allow Unused HTTP Interactions
If set to false, this cassette option will cause VCR to raise an error when a cassette is ejected and there are unused HTTP interactions remaining, unless there is already an exception unwinding the callstack.
It verifies that all requests included in the cassette were made, and allows VCR to function a bit like a mock object at the HTTP layer.
The option defaults to true (mostly for backwards compatibility).
Background ()
Given a file named "vcr_config.rb" with:
And a previously recorded cassette file "cassettes/example.yml" with:
Unused HTTP interactions are allowed by default
Given a file named "allowed_by_default.rb" with:
When I run ruby allowed_by_default.rb
Then it should pass.
Error raised if option is false and there are unused interactions
Given a file named "disallowed_with_no_requests.rb" with:
When I run ruby disallowed_with_no_requests.rb
Then it should fail with an error like:
No error raised if option is false and all interactions are used
Given a file named "disallowed_with_all_requests.rb" with:
When I run ruby disallowed_with_all_requests.rb
Then it should pass.
Does not silence other errors raised in use_cassette
block
use_cassette
blockGiven a file named "does_not_silence_other_errors.rb" with:
When I run ruby does_not_silence_other_errors.rb
Then it should fail with "boom"
And the output should not contain "There are unused HTTP interactions".
Last updated