These tests seem to be very similar to each other. Maybe we can do something like: 

[Encoding::UTF_8, Encoding::ISO_8859_1 ...].each do
    ...
end