From 8f2ecf62c60b35437804f621d569224ff082db86 Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Fri, 4 Jul 2014 09:45:16 +0200 Subject: [PATCH] Specs for XML::Element#text. --- spec/oga/xml/element_spec.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/spec/oga/xml/element_spec.rb b/spec/oga/xml/element_spec.rb index 3515547..b6d60f0 100644 --- a/spec/oga/xml/element_spec.rb +++ b/spec/oga/xml/element_spec.rb @@ -28,6 +28,24 @@ describe Oga::XML::Element do 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 example 'generate the corresponding XML' do described_class.new(:name => 'p').to_xml.should == '

'