Search code examples
ruby-on-railsvcr

How to edit response body returned by VCR gem?


I'm using VCR to record responses from other systems that i'm integrating with.

But, this response get a huge JSON an VCR is saving it in a binary format:

body:
  encoding: ASCII-8BIT
  string: !binary |-
    eyJsaXN0IjpbXSwiZmFjZXRzIjpbeyJuYW1lIjoiU2FsZXNDaGFubmVsTmFt
    ZSIsInR5cGUiOi...

Is there a way where I can save ONLY the response body as JSON?

I want to do this to edit the returned JSON in order to make other scenarios for my tests,

Thanks


Solution

  • Looking in VCR google forum, I was told to do my own serializer in order to get a pretty json return.

    So, i've found this code. With some minor modifications, it solved my problem, formatting the response body to not be encoded as binary.