Permalink
Browse files

Cleared up the string specs a tad

  • Loading branch information...
1 parent c18cafc commit 9c45d136431b478df58ea23bbc43bf91d9a67075 @soulcutter committed Apr 21, 2012
Showing with 29 additions and 10 deletions.
  1. +29 −10 spec/lib/saxerator_spec.rb
View
@@ -12,7 +12,15 @@ def fixture_file(name)
let(:parser) { Saxerator.parser(xml) }
context "with a string with blurbs" do
- let(:xml) { "<blurbs><blurb>one</blurb><blurb>two</blurb><blurb>three</blurb></blurbs>" }
+ let(:xml) do
+ <<-eos
+ <blurbs>
+ <blurb>one</blurb>
+ <blurb>two</blurb>
+ <blurb>three</blurb>
+ </blurbs>
+ eos
+ end
it "should parse simple strings" do
results = []
@@ -23,19 +31,30 @@ def fixture_file(name)
it "should allow you to parse an entire document" do
subject.all.should == {'blurb' => ['one', 'two', 'three']}
end
+ end
+
+ context "a string with blurbs and one non-blurb" do
+ let(:xml) do
+ <<-eos
+ <blurbs>
+ <blurb>one</blurb>
+ <blurb>two</blurb>
+ <blurb>three</blurb>
+ <notablurb>four</notablurb>
+ </blurbs>
+ eos
+ end
- context "and one non-blurb" do
- let(:xml) { "<blurbs><blurb>one</blurb><blurb>two</blurb><blurb>three</blurb><notablurb>four</notablurb></blurbs>" }
- it "should only parse the requested tag" do
- results = []
- subject.for_tag(:blurb).each { |x| results << x }
- results.should == ['one', 'two', 'three']
- subject.for_tag(:notablurb).each { |x| results << x }
- results.should == ['one', 'two', 'three', 'four']
- end
+ it "should only parse the requested tag" do
+ results = []
+ subject.for_tag(:blurb).each { |x| results << x }
+ results.should == ['one', 'two', 'three']
+ subject.for_tag(:notablurb).each { |x| results << x }
+ results.should == ['one', 'two', 'three', 'four']
end
end
+
context "with a string with an element at multiple depths" do
let(:xml) do
<<-eos

0 comments on commit 9c45d13

Please sign in to comment.