summaryrefslogtreecommitdiff
path: root/test/rexml/test_document.rb
diff options
context:
space:
mode:
authorkou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-10-28 06:43:38 +0000
committerkou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-10-28 06:43:38 +0000
commitaf83fcfe4de5d0497e78789efdfb7e7daf251805 (patch)
tree96c6190cd863b7597cdb57aae78fd15f878a5fe5 /test/rexml/test_document.rb
parent292c659b5ce2b8e01d59f87713450e6c66ca14a0 (diff)
* lib/rexml/document.rb (REXML::Document#write): Add :encoding option
to support custom XML encoding. [Feature #4872] (work in progress) * test/rexml/test_document.rb: Add tests for the above change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37355 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rexml/test_document.rb')
-rw-r--r--test/rexml/test_document.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/rexml/test_document.rb b/test/rexml/test_document.rb
index e8ca2e1..72d0ff6 100644
--- a/test/rexml/test_document.rb
+++ b/test/rexml/test_document.rb
@@ -159,6 +159,19 @@ EOX
document.write(output, indent, transitive, ie_hack)
assert_equal("<empty />", output)
end
+
+ def test_encoding
+ output = ""
+ indent = -1
+ transitive = false
+ ie_hack = false
+ encoding = "Shift_JIS"
+ @document.write(output, indent, transitive, ie_hack, encoding)
+ assert_equal(<<-EOX, output)
+<?xml version='1.0' encoding='SHIFT_JIS'?>
+<message>Hello world!</message>
+EOX
+ end
end
class OptionsTest < self
@@ -199,6 +212,15 @@ EOX
document.write(:output => output, :ie_hack => true)
assert_equal("<empty />", output)
end
+
+ def test_encoding
+ output = ""
+ @document.write(:output => output, :encoding => "Shift_JIS")
+ assert_equal(<<-EOX, output)
+<?xml version='1.0' encoding='SHIFT_JIS'?>
+<message>Hello world!</message>
+EOX
+ end
end
end
end