Permalink
Browse files

fixed find and added test/fixture because hCards passed in via the :t…

…ext option were missing postal_code
  • Loading branch information...
1 parent 1a737bc commit e9d951e07094409feff2c69d8c89406332bd9c16 Ben Kerney committed May 13, 2008
Showing with 21 additions and 2 deletions.
  1. +1 −1 lib/microformat.rb
  2. +1 −1 test/fixtures/upcoming_single.html
  3. +19 −0 test/hcard_test.rb
View
@@ -18,7 +18,7 @@ def find(*args)
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)
raise MicroformatNotFound if @options[:strict] && microformats.empty?
@@ -143,7 +143,7 @@ <h1>
<span class="fn org"><a href="/venue/3804/">Calvin College: Fine Arts Centre</a></span><br />
<div class="address adr">
<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>
<span class="geo" style="display: none">
View
@@ -29,6 +29,25 @@
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
setup do
$fauxtank ||= HCard.find(:first => fixture(:fauxtank))

0 comments on commit e9d951e

Please sign in to comment.