Skip to content

Instantly share code, notes, and snippets.

@patrickt
Created May 21, 2010 21:17
Show Gist options
  • Save patrickt/409449 to your computer and use it in GitHub Desktop.
Save patrickt/409449 to your computer and use it in GitHub Desktop.
# Here's the current version, taken from core/encoding/converter/convpath_spec.rb
it "returns multiple encoding pairs when direct conversion is impossible" do
ec = Encoding::Converter.new('ascii','Big5')
ec.convpath.size.should == 2
ec.convpath.first.should == [Encoding::US_ASCII, Encoding::UTF_8]
ec.convpath.last.should == [Encoding::UTF_8, Encoding::Big5]
end
# That spec seems to imply that the internal encoding for Strings is UTF-8,
# which is the case on MRI but not on other implementations.
# This is a version without that assumption:
it "returns multiple encoding pairs when direct conversion is impossible" do
ec = Encoding::Converter.new('ascii','Big5')
ec.convpath.size.should == 2
ec.convpath.first.first.should == Encoding::US_ASCII
ec.convpath.first.last.should == ec.convpath.last.first
ec.convpath.last.last.should == Encoding::Big5
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment