You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(Started as a bug report, but realized it might be more of a feature request).
In Rails context, if you have
a cassette with a json request like {"key": "<%= var %>"}
you pass it { erb: { var: '>' } }
your code uses Rails' to_json to create the request body
then VCR will show you that it's trying to find body with {"key": "\u003e"}, and therefore cannot find a matching request. That's because Rails' to_json automatically escapes html-unsafe symbols, which should be okay in most situations. However, VCR will not recognize that it's technically the same json.
This can currently be remedied by using match_requests_on: [:body_as_json].
However, what do you think about VCR automatically using :body_as_json based on request and response content type?
Having to reconfigure matching by hand each time json is involved seems a bit tedious and error prone. The problem is, most json requests work without using :body_as_json, making it unclear why it exists, but then when you run into something like this, you spend quite a while debugging, and then go "ahhh, now it makes sense". What are your thoughts? Potential downsides?
The text was updated successfully, but these errors were encountered:
(Started as a bug report, but realized it might be more of a feature request).
In Rails context, if you have
{"key": "<%= var %>"}
{ erb: { var: '>' } }
to_json
to create the request bodythen VCR will show you that it's trying to find body with
{"key": "\u003e"}
, and therefore cannot find a matching request. That's because Rails' to_json automatically escapes html-unsafe symbols, which should be okay in most situations. However, VCR will not recognize that it's technically the same json.This can currently be remedied by using
match_requests_on: [:body_as_json]
.However, what do you think about VCR automatically using
:body_as_json
based on request and response content type?Having to reconfigure matching by hand each time json is involved seems a bit tedious and error prone. The problem is, most json requests work without using
:body_as_json
, making it unclear why it exists, but then when you run into something like this, you spend quite a while debugging, and then go "ahhh, now it makes sense". What are your thoughts? Potential downsides?The text was updated successfully, but these errors were encountered: