cleans up implied property and adds lots of specs for them
This commit is contained in:
parent
3f2a627816
commit
10ea0256fc
15 changed files with 339 additions and 62 deletions
|
@ -132,39 +132,4 @@ describe Microformats2::Collection do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe ".h-card implied properties simple" do
|
||||
before do
|
||||
html = "spec/support/hcard-implied-simple.html"
|
||||
@collection = Microformats2.parse(html)
|
||||
end
|
||||
|
||||
describe "#parse" do
|
||||
it "assigns .h-card .p-name to HCard#name" do
|
||||
@collection.first.name.first.value.should == "@jlsuttles"
|
||||
end
|
||||
it "assigns .h-card .p-photo to HCard#photo" do
|
||||
@collection.first.photo.first.value.should == "http://gravatar.com/jlsuttles"
|
||||
end
|
||||
it "assigns .h-card .p-url to HCard#url" do
|
||||
@collection.first.url.first.value.should == "http://twitter.com/jlsuttles"
|
||||
end
|
||||
end
|
||||
|
||||
describe "#to_hash" do
|
||||
it "returns the correct Hash" do
|
||||
hash = {
|
||||
:items => [{
|
||||
:type => ["h-card"],
|
||||
:properties => {
|
||||
:name => ["@jlsuttles"],
|
||||
:photo => ["http://gravatar.com/jlsuttles"],
|
||||
:url => ["http://twitter.com/jlsuttles"]
|
||||
}
|
||||
}]
|
||||
}
|
||||
@collection.to_hash.should == hash
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
29
spec/lib/microformats2/implied_property/name_spec.rb
Normal file
29
spec/lib/microformats2/implied_property/name_spec.rb
Normal file
|
@ -0,0 +1,29 @@
|
|||
require "spec_helper"
|
||||
require "microformats2"
|
||||
|
||||
describe Microformats2::ImpliedProperty::Name do
|
||||
describe "name-pass.html" do
|
||||
html = "spec/support/lib/microformats2/implied_property/name-pass.html"
|
||||
collection = Microformats2.parse(html)
|
||||
it "should have the correct number of formats" do
|
||||
collection.all.length.should == 6
|
||||
end
|
||||
collection.all.each_with_index do |format, index|
|
||||
it "passes case #{index+1}" do
|
||||
format.name.first.value.should == "Jessica"
|
||||
end
|
||||
end
|
||||
end
|
||||
describe "name-fail.html" do
|
||||
html = "spec/support/lib/microformats2/implied_property/name-fail.html"
|
||||
collection = Microformats2.parse(html)
|
||||
it "should have the correct number of formats" do
|
||||
collection.all.length.should == 8
|
||||
end
|
||||
collection.all.each_with_index do |format, index|
|
||||
it "fails case #{index+1}" do
|
||||
format.name.first.value.should == ""
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
29
spec/lib/microformats2/implied_property/photo_spec.rb
Normal file
29
spec/lib/microformats2/implied_property/photo_spec.rb
Normal file
|
@ -0,0 +1,29 @@
|
|||
require "spec_helper"
|
||||
require "microformats2"
|
||||
|
||||
describe Microformats2::ImpliedProperty::Photo do
|
||||
describe "photo-pass.html" do
|
||||
html = "spec/support/lib/microformats2/implied_property/photo-pass.html"
|
||||
collection = Microformats2.parse(html)
|
||||
it "should have the correct number of formats" do
|
||||
collection.all.length.should == 6
|
||||
end
|
||||
collection.all.each_with_index do |format, index|
|
||||
it "passes case #{index+1}" do
|
||||
format.photo.first.value.should == "http://gravatar.com/jlsuttles"
|
||||
end
|
||||
end
|
||||
end
|
||||
describe "photo-fail.html" do
|
||||
html = "spec/support/lib/microformats2/implied_property/photo-fail.html"
|
||||
collection = Microformats2.parse(html)
|
||||
it "should have the correct number of formats" do
|
||||
collection.all.length.should == 8
|
||||
end
|
||||
collection.all.each_with_index do |format, index|
|
||||
it "fails case #{index+1}" do
|
||||
format.photo.should be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
29
spec/lib/microformats2/implied_property/url_spec.rb
Normal file
29
spec/lib/microformats2/implied_property/url_spec.rb
Normal file
|
@ -0,0 +1,29 @@
|
|||
require "spec_helper"
|
||||
require "microformats2"
|
||||
|
||||
describe Microformats2::ImpliedProperty::Url do
|
||||
describe "url-pass.html" do
|
||||
html = "spec/support/lib/microformats2/implied_property/url-pass.html"
|
||||
collection = Microformats2.parse(html)
|
||||
it "should have the correct number of formats" do
|
||||
collection.all.length.should == 2
|
||||
end
|
||||
collection.all.each_with_index do |format, index|
|
||||
it "passes case #{index+1}" do
|
||||
format.url.first.value.should == "http://github.com/jlsuttles"
|
||||
end
|
||||
end
|
||||
end
|
||||
describe "url-fail.html" do
|
||||
html = "spec/support/lib/microformats2/implied_property/url-fail.html"
|
||||
collection = Microformats2.parse(html)
|
||||
it "should have the correct number of formats" do
|
||||
collection.all.length.should == 2
|
||||
end
|
||||
collection.all.each_with_index do |format, index|
|
||||
it "fails case #{index+1}" do
|
||||
format.url.should be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,9 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
<div class="h-card">
|
||||
<a href="http://twitter.com/jlsuttles">@jlsuttles</a>
|
||||
<img src="http://gravatar.com/jlsuttles">
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,60 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
|
||||
<div class="h-card">
|
||||
<img alt="Jessica">
|
||||
<img alt="Shane">
|
||||
</div>
|
||||
|
||||
<div class="h-card">
|
||||
<abbr title="Jessica" />
|
||||
<abbr title="Shane" />
|
||||
</div>
|
||||
|
||||
<div class="h-card">
|
||||
<div>
|
||||
<img alt="Jessica">
|
||||
<img alt="Shane">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="h-card">
|
||||
<div></div>
|
||||
<div>
|
||||
<img alt="Jessica">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="h-card">
|
||||
<div>
|
||||
<abbr title="Jessica" />
|
||||
<abbr title="Shane" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="h-card">
|
||||
<div></div>
|
||||
<div>
|
||||
<abbr title="Jessica" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="h-card">
|
||||
<div>
|
||||
<div>
|
||||
<img alt="Jessica">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="h-card">
|
||||
<div>
|
||||
<div>
|
||||
<abbr title="Jessica" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,30 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
|
||||
<img class="h-card" alt="Jessica">
|
||||
|
||||
<abbr class="h-card" title="Jessica" />
|
||||
|
||||
<div class="h-card">
|
||||
<img alt="Jessica">
|
||||
</div>
|
||||
|
||||
<div class="h-card">
|
||||
<abbr title="Jessica" />
|
||||
</div>
|
||||
|
||||
<div class="h-card">
|
||||
<div>
|
||||
<img alt="Jessica">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="h-card">
|
||||
<div>
|
||||
<abbr title="Jessica" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,60 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
|
||||
<div class="h-card">
|
||||
<img src="http://gravatar.com/jlsuttles">
|
||||
<img src="http://gravatar.com/veganstraightedge">
|
||||
</div>
|
||||
|
||||
<div class="h-card">
|
||||
<object data="http://gravatar.com/jlsuttles" />
|
||||
<object data="http://gravatar.com/veganstraightedge" />
|
||||
</div>
|
||||
|
||||
<div class="h-card">
|
||||
<div>
|
||||
<img src="http://gravatar.com/jlsuttles">
|
||||
<img src="http://gravatar.com/veganstraightedge">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="h-card">
|
||||
<div></div>
|
||||
<div>
|
||||
<img src="http://gravatar.com/jlsuttles">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="h-card">
|
||||
<div>
|
||||
<object data="http://gravatar.com/jlsuttles" />
|
||||
<object data="http://gravatar.com/veganstraightedge" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="h-card">
|
||||
<div></div>
|
||||
<div>
|
||||
<object data="http://gravatar.com/jlsuttles" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="h-card">
|
||||
<div>
|
||||
<div>
|
||||
<img src="http://gravatar.com/jlsuttles">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="h-card">
|
||||
<div>
|
||||
<div>
|
||||
<object data="http://gravatar.com/jlsuttles" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,30 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
|
||||
<img class="h-card" src="http://gravatar.com/jlsuttles">
|
||||
|
||||
<object class="h-card" data="http://gravatar.com/jlsuttles" />
|
||||
|
||||
<div class="h-card">
|
||||
<img src="http://gravatar.com/jlsuttles">
|
||||
</div>
|
||||
|
||||
<div class="h-card">
|
||||
<object data="http://gravatar.com/jlsuttles" />
|
||||
</div>
|
||||
|
||||
<div class="h-card">
|
||||
<div>
|
||||
<img src="http://gravatar.com/jlsuttles">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="h-card">
|
||||
<div>
|
||||
<object data="http://gravatar.com/jlsuttles" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,18 @@
|
|||
</html>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
|
||||
<div class="h-card">
|
||||
<a href="http://github.com/jlsuttles" />
|
||||
<a href="http://github.com/veganstraightedge" />
|
||||
</div>
|
||||
|
||||
<div class="h-card">
|
||||
<div>
|
||||
<a href="http://github.com/jlsuttles" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,12 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
|
||||
<a class="h-card" href="http://github.com/jlsuttles" />
|
||||
|
||||
<div class="h-card">
|
||||
<a href="http://github.com/jlsuttles" />
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue