Open IceDragon200 opened 6 years ago
Is it possible to use
match_request_on :headers
, but then specify which headers it should match?If not then I suggest something like:
use_cassette "my_cassette", match_requests_on: [headers: [only: ["content-type", "soapaction"]]] do # do stuff end
@type t :: [ {:match_requests_on, [ :headers | {:headers [ only: [String.t], except: [String.t] ]} ]} ]
The default
:headers
option would still be kept if no filtering is required.The reasoning behind this request is to ignore some dynamic headers that would be difficult to remove/disable just for testing (e.g. a
user-agent
which uses the current application version), but always invalidates recorded cassettes because of their nature.
Good for testing ETag / "If-None-Match" interactions
I've hit this as well - I would have like to have verified this worked - it's pretty essential to the project (github event poller).
test "list events etag " do
ExVCR.Config.filter_request_headers("Authorization")
use_cassette "list_events_etag" , match_requests_on: [ :headers, :query , :request_body ] do
x = ExGithubPoller.events("bryanhuntesl", "test_repo", %ExGithubPoller.Param{} )
assert length(x.events) == 152
y = ExGithubPoller.events("bryanhuntesl", "test_repo", %ExGithubPoller.Param{etag: x.etag} )
assert length(y.events) == 0
assert y.limit_remaining == x.limit_remaining
end
end
Is it possible to use
match_request_on :headers
, but then specify which headers it should match?If not then I suggest something like:
The default
:headers
option would still be kept if no filtering is required.The reasoning behind this request is to ignore some dynamic headers that would be difficult to remove/disable just for testing (e.g. a
user-agent
which uses the current application version), but always invalidates recorded cassettes because of their nature.