Specs for XML::Element#text.

This commit is contained in:
Yorick Peterse 2014-07-04 09:45:16 +02:00
parent a15c19c4af
commit 8f2ecf62c6
1 changed files with 18 additions and 0 deletions

View File

@ -28,6 +28,24 @@ describe Oga::XML::Element do
end end
end end
context '#text' do
before do
t1 = Oga::XML::Text.new(:text => 'Foo')
t2 = Oga::XML::Text.new(:text => 'Bar')
@n1 = described_class.new(:children => [t1])
@n2 = described_class.new(:children => [@n1, t2])
end
example 'return the text of the parent node and its child nodes' do
@n2.text.should == 'FooBar'
end
example 'return the text of the child node' do
@n1.text.should == 'Foo'
end
end
context '#to_xml' do context '#to_xml' do
example 'generate the corresponding XML' do example 'generate the corresponding XML' do
described_class.new(:name => 'p').to_xml.should == '<p></p>' described_class.new(:name => 'p').to_xml.should == '<p></p>'