Skip to content

Commit

Permalink
fixed find and added test/fixture because hCards passed in via the :t…
Browse files Browse the repository at this point in the history
…ext option were missing postal_code
  • Loading branch information
Ben Kerney committed May 13, 2008
1 parent 1a737bc commit e9d951e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/microformat.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def find(*args)


extract_base_url! target extract_base_url! target


@doc = build_doc(@options[:text] ? @options : target) @doc = target.kind_of?(Hpricot::Elem) ? target : build_doc(@options[:text] ? @options : target)


microformats = find_occurences(@doc) microformats = find_occurences(@doc)
raise MicroformatNotFound if @options[:strict] && microformats.empty? raise MicroformatNotFound if @options[:strict] && microformats.empty?
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/upcoming_single.html
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ <h1>
<span class="fn org"><a href="/venue/3804/">Calvin College: Fine Arts Centre</a></span><br /> <span class="fn org"><a href="/venue/3804/">Calvin College: Fine Arts Centre</a></span><br />
<div class="address adr"> <div class="address adr">
<span class="street-address">3210 Burton SE</span><br /> <span class="street-address">3210 Burton SE</span><br />
<span class="locality">Grand Rapids</span>, <span class="region">Michigan</span> <span class="postal-code"></span> <span class="locality">Grand Rapids</span>, <span class="region">Michigan</span> <span class="postal-code">49546</span>


</div> </div>
<span class="geo" style="display: none"> <span class="geo" style="display: none">
Expand Down
19 changes: 19 additions & 0 deletions test/hcard_test.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -29,6 +29,25 @@
end end
end end


context "The hCard found in the upcoming_single page" do
setup do
$upcoming_text = HCard.find(:text => open(fixture(:upcoming_single)).read)
$upcoming_find = HCard.find(fixture(:upcoming_single))
end

specify "should be identical whether passed as :text or found with default method" do
$upcoming_text.fn.should.equal $upcoming_find.fn
$upcoming_text.org.should.equal $upcoming_find.org
$upcoming_text.adr.base_url.should.equal $upcoming_find.adr.base_url
$upcoming_text.adr.postal_code.should.equal $upcoming_find.adr.postal_code
$upcoming_text.adr.locality.should.equal $upcoming_find.adr.locality
$upcoming_text.adr.region.should.equal $upcoming_find.adr.region
$upcoming_text.adr.street_address.should.equal $upcoming_find.adr.street_address
$upcoming_text.geo.longitude.should.equal $upcoming_find.geo.longitude
$upcoming_text.geo.latitude.should.equal $upcoming_find.geo.latitude
end
end

context "The parsed fauxtank hCard object" do context "The parsed fauxtank hCard object" do
setup do setup do
$fauxtank ||= HCard.find(:first => fixture(:fauxtank)) $fauxtank ||= HCard.find(:first => fixture(:fauxtank))
Expand Down

0 comments on commit e9d951e

Please sign in to comment.