parroty / exvcr

HTTP request/response recording library for elixir, inspired by VCR.
MIT License
720 stars 131 forks source link

UTF-8 characters are being serialized incorrectly #125

Open mauricioszabo opened 6 years ago

mauricioszabo commented 6 years ago

I'm using ExVCR to mock a REST API that renders JSON descriptions with UTF-8 charset. When serializing cassetes, ExVCR is saving descriptions with wrong charset, which makes my tests fail. If I don't use ExVCR, my test passes, but using it, I'm having errors such as:

     Assertion with == failed
     code:  assert Plans.get_all() == %{"plans" => [%{"name" => "Plan3", "description" => "Comprar cartões"}]}
     left:  %{"plans" => [%{"name" => "Plan3", "description" => "Comprar cartões"}]}
     right: %{"plans" => [%{"name" => "Plan3", "description" => "Comprar cartões"}]}

Opening my cassete file, I can see the text "Comprar cartões" being saved.

mauricioszabo commented 6 years ago

In a simple debugging, I found out that :ibrowse is bringing just a list of bytes - not the UTF-8 string. Probably we can work from there, either assuming that a string is always UTF-8 or checking headers to find encoding and use Codepagex or something to coerce the list into the correct encoding, WDYT?