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
VCR is a tool which I'd classify as useful in snapshot testing. You record a snapshot of an interaction with a System Under Test. Once recorded, these interactions are replayed from stored files — snapshots. VCR specifically records HTTP interactions and stores results of such in YAML files called “tapes”.
Testing external APIs can be a time-consuming task, VCR is a ruby gem that allows you to record test suite's HTTP interactions and replay them during future test runs for fast, deterministic, accurate tests.
From the google forum link that Cleyton supplied (I would leave a comment if I had the rep), the following change in spec_helper.rb
works for me:
VCR.configure do |c|
c.before_record do |i|
i.response.body.force_encoding('UTF-8')
end
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With