From 3f817764e24eb05aceef884e213d4a7043c292fa Mon Sep 17 00:00:00 2001 From: kou Date: Sat, 3 Nov 2012 03:53:09 +0000 Subject: * lib/rexml/document.rb (REXML::Document#write): Document encoding option. Now different encoding between XML file's encoding and XML declaration's encodiong is support. [Feature #4872] (work in progress) * lib/rexml/xmldecl.rb (REXML::XMLDecl#write): Always use XMLDecl's encoding. * test/rexml/test_document.rb: Update tests for the above change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37440 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/rexml/test_document.rb | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'test/rexml') diff --git a/test/rexml/test_document.rb b/test/rexml/test_document.rb index 2725235907..b78b310f00 100644 --- a/test/rexml/test_document.rb +++ b/test/rexml/test_document.rb @@ -165,11 +165,16 @@ EOX indent = -1 transitive = false ie_hack = false - encoding = "Shift_JIS" + encoding = "Windows-31J" + + xml_declaration_encoding = "Shift_JIS" + @document.xml_decl.encoding = xml_declaration_encoding + japanese_text = "こんにちは" + @document.root.text = japanese_text @document.write(output, indent, transitive, ie_hack, encoding) - assert_equal(<<-EOX, output) - -Hello world! + assert_equal(<<-EOX.encode(encoding), output) + +#{japanese_text} EOX end end @@ -215,10 +220,15 @@ EOX def test_encoding output = "" - @document.write(:output => output, :encoding => "Shift_JIS") - assert_equal(<<-EOX, output) - -Hello world! + encoding = "Windows-31J" + xml_declaration_encoding = "Shift_JIS" + @document.xml_decl.encoding = xml_declaration_encoding + japanese_text = "こんにちは" + @document.root.text = japanese_text + @document.write(:output => output, :encoding => encoding) + assert_equal(<<-EOX.encode(encoding), output) + +#{japanese_text} EOX end end -- cgit v1.2.3