spec/saxomattic_spec.rb in saxomattic-0.0.1 vs spec/saxomattic_spec.rb in saxomattic-0.0.2

- old
+ new

@@ -14,19 +14,27 @@ attribute :embed attribute :foo, :type => Integer attribute :embedception, :class => SaxTesterEmbedception end +class SaxTesterChild + include Saxomattic + + attribute :name +end + class SaxTesterSomething include Saxomattic attribute :baz attribute :foo, :type => Integer attribute :iso_8701, :type => Date attribute :date, :type => Date attribute :datetime, :type => DateTime attribute :embedded, :elements => true, :class => SaxTesterEmbedded + attribute :child, :as => :children, :elements => true, :class => SaxTesterChild + attribute :CAPITALIZATION, :as => :capitalization end describe ::Saxomattic do let(:embedded_message) { "HERE!" } @@ -43,12 +51,21 @@ <embedded> <foo>2</foo> <embed>#{embedded_message}</embed> <embedception type="#{embedception_type}">#{embedception_value}</embedception> </embedded> + <parent> + <child> + <name>John</name> + </child> + <child> + <name>Paul</name> + </child> + </parent> <date>#{Date.today}</date> <foo>2</foo> + <CAPITALIZATION>cap</CAPITALIZATION> </test> XML } subject { SaxTesterSomething.parse(xml) } @@ -79,9 +96,15 @@ it "embeds values further" do subject.embedded.first.embedception?.should be_true subject.embedded.first.embedception.type.should eq(embedception_type) subject.embedded.first.embedception.value.should eq(embedception_value) subject.embedded.first.embedception.not_even_used?.should be_false + end + + it "extracts multiple children from a parent element" do + subject.children.size.should eq 2 + subject.children.first.name.should eq "John" + subject.children.last.name.should eq "Paul" end end end