Normalize u-* property values for implied properties

This commit is contained in:
jessicard 2013-11-04 16:03:24 -08:00
parent 249fc1ef74
commit 0eb04480f5
6 changed files with 73 additions and 4 deletions

View file

@ -15,6 +15,33 @@ describe Microformats2::ImpliedProperty::Url do
end
end
end
describe "url-relative.html" do
html = "spec/support/lib/microformats2/implied_property/url-relative.html"
collection = Microformats2.parse(html)
it "should have 2 microformats" do
collection.all.length.should == 2
end
collection.all.each_with_index do |format, index|
it "implies url to be 'http://example.org/' in case #{index+1}" do
format.url.to_s.should == "http://example.org/"
end
end
end
describe "url-unnormalized.html" do
html = "spec/support/lib/microformats2/implied_property/url-unnormalized.html"
collection = Microformats2.parse(html)
it "should have 2 microformats" do
collection.all.length.should == 2
end
collection.all.each_with_index do |format, index|
it "implies url to be 'http://github.com/' in case #{index+1}" do
format.url.to_s.should == "http://github.com/"
end
end
end
describe "url-fail.html" do
html = "spec/support/lib/microformats2/implied_property/url-fail.html"
collection = Microformats2.parse(html)
@ -22,8 +49,8 @@ describe Microformats2::ImpliedProperty::Url do
collection.all.length.should == 2
end
collection.all.each_with_index do |format, index|
it "implies url to be '' in case #{index+1}" do
expect {format.url.to_s.should == ""}.to raise_error(NoMethodError)
it "does not imply url in case #{index+1}" do
expect {format.url}.to raise_error(NoMethodError)
end
end
end

View file

@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<body>
<base href="http://example.org/">
<a class="h-card" href="/" />
<div class="h-card">
<a href="/" />
</div>
</body>
</html>

View file

@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>
<body>
<a class="h-card" href="http://github.com" />
<div class="h-card">
<a href="http://github.com" />
</div>
</body>
</html>