crudley implements implied properties. needs more specs

This commit is contained in:
Jessica Lynn Suttles 2013-02-13 19:13:39 -08:00
parent 1d8e46ce95
commit 3f2a627816
8 changed files with 189 additions and 2 deletions

View file

@ -102,7 +102,7 @@ describe Microformats2::Collection do
end
end
describe ".h-entry .p-author.h-card nested" do
describe ".h-card .p-name .p-nickname nested" do
before do
html = "spec/support/hcard-pname-pnickname-nested.html"
@collection = Microformats2.parse(html)
@ -132,4 +132,39 @@ 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

View file

@ -0,0 +1,9 @@
<!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>