Added XML::Document#root_node

This commit is contained in:
Yorick Peterse 2015-07-08 01:26:58 +02:00
parent a7744b7a5c
commit 94f7f85dc3
2 changed files with 20 additions and 0 deletions

View File

@ -54,6 +54,18 @@ module Oga
end end
end end
##
# Returns self.
#
# This method exists to make this class compatible with Element, which in
# turn makes it easier to use both in the XPath compiler.
#
# @return [Oga::XML::Document]
#
def root_node
self
end
## ##
# Converts the document and its child nodes to XML. # Converts the document and its child nodes to XML.
# #

View File

@ -34,6 +34,14 @@ describe Oga::XML::Document do
end end
end end
describe '#root_node' do
it 'returns self' do
doc = described_class.new
doc.root_node.should == doc
end
end
describe '#to_xml' do describe '#to_xml' do
before do before do
child = Oga::XML::Comment.new(:text => 'foo') child = Oga::XML::Comment.new(:text => 'foo')