Skip to content

Instantly share code, notes, and snippets.

@tenderlove
Created August 14, 2011 01:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tenderlove/1144463 to your computer and use it in GitHub Desktop.
Save tenderlove/1144463 to your computer and use it in GitHub Desktop.
# coding: cp932
gem 'psych', '~> 1.2.0'
require 'psych'
require 'yaml'
require 'minitest/autorun'
class TestEnc < MiniTest::Unit::TestCase
def setup
@oldenc = Encoding.default_internal
@v = {"a"=>"‚ "}
end
def teardown
Encoding.default_internal = @oldenc
end
def test_no_default
hash = YAML.load YAML.dump @v
assert_equal @v['a'], hash['a'].encode('CP932')
assert_equal @v['a'].encode('UTF-8'), hash['a']
end
def test_with_default
Encoding.default_internal = Encoding::CP932
hash = YAML.load YAML.dump @v
assert_equal @v['a'], hash['a']
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment