Skip to content

Commit

Permalink
default output of XML on JRuby is no longer formatted due to inconsis…
Browse files Browse the repository at this point in the history
…tent whitespace handling. Closes sparklemotion#415
  • Loading branch information
flavorjones committed Mar 9, 2011
1 parent fa671aa commit 4337005
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.rdoc
Expand Up @@ -4,6 +4,11 @@

* extracted sets of Node::SaveOptions into Node::SaveOptions::DEFAULT_{X,H,XH}TML (refactor)

* Bugfixes

* default output of XML on JRuby is no longer formatted due to
inconsistent whitespace handling. #415

== 1.5.0 beta3 / 2010/12/02

* Notes
Expand Down
6 changes: 5 additions & 1 deletion lib/nokogiri/xml/node/save_options.rb
Expand Up @@ -20,7 +20,11 @@ class SaveOptions
AS_HTML = 64

# the default for XML documents
DEFAULT_XML = FORMAT | AS_XML
if Nokogiri.jruby?
DEFAULT_XML = AS_XML # https://github.com/tenderlove/nokogiri/issues/#issue/415
else
DEFAULT_XML = FORMAT | AS_XML
end
# the default for HTML document
DEFAULT_HTML = FORMAT | NO_DECLARATION | NO_EMPTY_TAGS | AS_HTML
# the default for XHTML document
Expand Down
12 changes: 10 additions & 2 deletions test/xml/node/test_save_options.rb
Expand Up @@ -5,14 +5,22 @@ module XML
class Node
class TestSaveOptions < Nokogiri::TestCase
SaveOptions.constants.each do |constant|
class_eval %{
class_eval <<-EOEVAL
def test_predicate_#{constant.downcase}
options = SaveOptions.new(SaveOptions::#{constant})
assert options.#{constant.downcase}?
assert SaveOptions.new.#{constant.downcase}.#{constant.downcase}?
end
}
EOEVAL
end

def test_default_xml_save_options
if Nokogiri.jruby?
assert_equal 0, (SaveOptions::DEFAULT_XML & SaveOptions::FORMAT)
else
assert_equal SaveOptions::FORMAT, (SaveOptions::DEFAULT_XML & SaveOptions::FORMAT)
end
end
end
end
Expand Down

0 comments on commit 4337005

Please sign in to comment.