Skip to content

Commit

Permalink
* Nokogiri::XML::Text#to_ary returns an array with the node text. fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tenderlove committed May 15, 2012
1 parent ce2895a commit 96baf08
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
* JRuby 1.9 mode causes dead lock while running rake #571
* HTML::Document#meta_encoding does not raise exception on docs with
malformed content-type. #655
* Nokogiri::XML::Text#to_ary returns an array with the node text. #679


== 1.5.2 / 2012-03-09
Expand Down
4 changes: 4 additions & 0 deletions lib/nokogiri/xml/text.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ class Text < Nokogiri::XML::CharacterData
def content=(string)
self.native_content = string.to_s
end

def to_ary
[self.text]
end
end
end
end
6 changes: 6 additions & 0 deletions test/xml/test_text.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
module Nokogiri
module XML
class TestText < Nokogiri::TestCase
def test_ary
doc = Nokogiri.XML "<root> foo <a>something</a> bar bazz </root>"
node = doc.root.children[2]
assert_equal [node.text], Array(node)
end

def test_css_path
doc = Nokogiri.XML "<root> foo <a>something</a> bar bazz </root>"
node = doc.root.children[2]
Expand Down

0 comments on commit 96baf08

Please sign in to comment.