Skip to content

Cassettes recorded in Ruby 1.8 won't work with Ruby 1.9 #149

nirvdrum opened this Issue Mar 18, 2012 · 2 comments

2 participants


It appears that cassettes recorded with Ruby 1.8 won't work with Ruby 1.9. It may be more nuanced than that because my 1.8 specs are run in JRuby and my 1.9 specs are run in MRI.

The core problem seems to be the cassette will not record an encoding value on 1.8. Since everything is implicitly UTF-8, this makes sense. However, in 1.9, a String does have an encoding, so the check on lib/vcr/structs.rb:36 fails, allowing line 37 to execute, which raises a nil error because the encoding is nil.

This seems fixable by changing line 24 to try_encode_string(hash['string'], hash['encoding'] || 'UTF-8').

@myronmarston myronmarston added a commit that closed this issue Mar 19, 2012
@myronmarston myronmarston Don't try to encode to a nil encoding.
This should allow cassettes recorded on 1.8 to work on 1.9.

Closes #149.
VCR member

Thanks for reporting this. I just pushed a fix that should take care of it for you.


Thanks. That's a cleaner fix. I wasn't sure of the full ramifications of my suggestion so I wanted to evaluate more before issuing a pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.