Skip to content

Commit

Permalink
Cleared up the string specs a tad
Browse files Browse the repository at this point in the history
  • Loading branch information
soulcutter committed Apr 21, 2012
1 parent c18cafc commit 9c45d13
Showing 1 changed file with 29 additions and 10 deletions.
39 changes: 29 additions & 10 deletions spec/lib/saxerator_spec.rb
Expand Up @@ -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 = []
Expand All @@ -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
Expand Down

0 comments on commit 9c45d13

Please sign in to comment.