From de2e09e0bcf61fa54572feb6ed2e432ac003fe3d Mon Sep 17 00:00:00 2001 From: kou Date: Sun, 28 Oct 2012 05:59:59 +0000 Subject: * lib/rexml/document.rb (REXML::Document#write): Accept options Hash as argument. * test/rexml/test_document.rb: Add tests for the above change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37353 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/rexml/test_document.rb | 95 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) (limited to 'test/rexml/test_document.rb') diff --git a/test/rexml/test_document.rb b/test/rexml/test_document.rb index ab0b1e4e96..e8ca2e1c24 100644 --- a/test/rexml/test_document.rb +++ b/test/rexml/test_document.rb @@ -106,4 +106,99 @@ EOX doc = REXML::Document.new('') assert_equal('no', doc.stand_alone?, bug2539) end + + class WriteTest < Test::Unit::TestCase + def setup + @document = REXML::Document.new(<<-EOX) + +Hello world! +EOX + end + + class ArgumentsTest < self + def test_output + output = "" + @document.write(output) + assert_equal(<<-EOX, output) + +Hello world! +EOX + end + + def test_indent + output = "" + indent = 2 + @document.write(output, indent) + assert_equal(<<-EOX.chomp, output) + + + Hello world! + +EOX + end + + def test_transitive + output = "" + indent = 2 + transitive = true + @document.write(output, indent, transitive) + assert_equal(<<-EOX, output) + +Hello world! +EOX + end + + def test_ie_hack + output = "" + indent = -1 + transitive = false + ie_hack = true + document = REXML::Document.new("") + document.write(output, indent, transitive, ie_hack) + assert_equal("", output) + end + end + + class OptionsTest < self + def test_output + output = "" + @document.write(:output => output) + assert_equal(<<-EOX, output) + +Hello world! +EOX + end + + def test_indent + output = "" + @document.write(:output => output, :indent => 2) + assert_equal(<<-EOX.chomp, output) + + + Hello world! + +EOX + end + + def test_transitive + output = "" + @document.write(:output => output, :indent => 2, :transitive => true) + assert_equal(<<-EOX, output) + +Hello world! +EOX + end + + def test_ie_hack + output = "" + document = REXML::Document.new("") + document.write(:output => output, :ie_hack => true) + assert_equal("", output) + end + end + end end -- cgit v1.2.3