Skip to content

Instantly share code, notes, and snippets.

@tenderlove

tenderlove/test.rb

Created Aug 14, 2011
Embed
What would you like to do?
# 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
You can’t perform that action at this time.