makes simple case slightly more complex
This commit is contained in:
parent
8344b85938
commit
7bda1aaae6
3 changed files with 11 additions and 10 deletions
|
@ -10,7 +10,7 @@ describe Microformats2::Collection do
|
||||||
@collection = Microformats2.parse(html)
|
@collection = Microformats2.parse(html)
|
||||||
end
|
end
|
||||||
describe "#to_json" do
|
describe "#to_json" do
|
||||||
it "returns the correct JSON" do
|
it "should match simple.js" do
|
||||||
json = "spec/support/lib/microformats2/simple.js"
|
json = "spec/support/lib/microformats2/simple.js"
|
||||||
json = open(json).read
|
json = open(json).read
|
||||||
JSON.parse(@collection.to_json).should == JSON.parse(json)
|
JSON.parse(@collection.to_json).should == JSON.parse(json)
|
||||||
|
@ -43,10 +43,11 @@ describe Microformats2::Collection do
|
||||||
@collection.first.bday.first.should be_kind_of Microformats2::Property::DateTime
|
@collection.first.bday.first.should be_kind_of Microformats2::Property::DateTime
|
||||||
end
|
end
|
||||||
it "assigns datetime attribute to Property#string_value" do
|
it "assigns datetime attribute to Property#string_value" do
|
||||||
@collection.first.bday.first.value.to_s.should == "1990-10-15T20:45:33-08:00"
|
@collection.first.bday.first.string_value.should == "1990-10-15"
|
||||||
end
|
end
|
||||||
it "assigns DateTime object to Property#value" do
|
it "assigns DateTime object to Property#value" do
|
||||||
@collection.first.bday.first.value.should be_kind_of DateTime
|
@collection.first.bday.first.value.should be_kind_of DateTime
|
||||||
|
@collection.first.bday.first.value.to_s.should == "1990-10-15T00:00:00+00:00"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
describe "HCard#content parsed from '.h-card .p-content'" do
|
describe "HCard#content parsed from '.h-card .p-content'" do
|
||||||
|
@ -54,7 +55,7 @@ describe Microformats2::Collection do
|
||||||
@collection.first.content.first.should be_kind_of Microformats2::Property::Embedded
|
@collection.first.content.first.should be_kind_of Microformats2::Property::Embedded
|
||||||
end
|
end
|
||||||
it "assigns inner_text to Property#value" do
|
it "assigns inner_text to Property#value" do
|
||||||
@collection.first.content.first.value.should == "Vegan. Cat lover. Coder."
|
@collection.first.content.first.value.should == "<p>Vegan. Cat lover. Coder.</p>"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -65,7 +66,7 @@ describe Microformats2::Collection do
|
||||||
@collection = Microformats2.parse(html)
|
@collection = Microformats2.parse(html)
|
||||||
end
|
end
|
||||||
describe "#to_json" do
|
describe "#to_json" do
|
||||||
it "returns the correct JSON" do
|
it "should match nested-property.js" do
|
||||||
json = "spec/support/lib/microformats2/nested-property.js"
|
json = "spec/support/lib/microformats2/nested-property.js"
|
||||||
json = open(json).read
|
json = open(json).read
|
||||||
JSON.parse(@collection.to_json).should == JSON.parse(json)
|
JSON.parse(@collection.to_json).should == JSON.parse(json)
|
||||||
|
@ -84,7 +85,7 @@ describe Microformats2::Collection do
|
||||||
@collection.first.name.first.value.should == "jlsuttles"
|
@collection.first.name.first.value.should == "jlsuttles"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
describe "HCard#nickname parsed from '.h-card .p-nickname'" do
|
describe "HCard#nickname parsed from '.h-card .p-name .p-nickname'" do
|
||||||
it "assigns Property from '.h-card .p-nickname' to HCard#nickname[]" do
|
it "assigns Property from '.h-card .p-nickname' to HCard#nickname[]" do
|
||||||
@collection.first.nickname.first.should be_kind_of Microformats2::Property::Text
|
@collection.first.nickname.first.should be_kind_of Microformats2::Property::Text
|
||||||
end
|
end
|
||||||
|
@ -100,7 +101,7 @@ describe Microformats2::Collection do
|
||||||
@collection = Microformats2.parse(html)
|
@collection = Microformats2.parse(html)
|
||||||
end
|
end
|
||||||
describe "#to_json" do
|
describe "#to_json" do
|
||||||
it "returns the correct JSON" do
|
it "should match nested-format-with-property.js" do
|
||||||
json = "spec/support/lib/microformats2/nested-format-with-property.js"
|
json = "spec/support/lib/microformats2/nested-format-with-property.js"
|
||||||
json = open(json).read
|
json = open(json).read
|
||||||
JSON.parse(@collection.to_json).should == JSON.parse(json)
|
JSON.parse(@collection.to_json).should == JSON.parse(json)
|
||||||
|
|
|
@ -8,11 +8,11 @@
|
||||||
<a href="http://twitter.com/jlsuttles" class="u-url">
|
<a href="http://twitter.com/jlsuttles" class="u-url">
|
||||||
@jlsuttles
|
@jlsuttles
|
||||||
</a>
|
</a>
|
||||||
<time class="dt-bday" datetime="1990-10-15T20:45:33-08:00">
|
<time class="dt-bday" datetime="1990-10-15">
|
||||||
October 15, 1990
|
October 15, 1990
|
||||||
</time>
|
</time>
|
||||||
<div class="e-content">
|
<div class="e-content">
|
||||||
Vegan. Cat lover. Coder.
|
<p>Vegan. Cat lover. Coder.</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
"properties": {
|
"properties": {
|
||||||
"url": ["http://flickr.com/jlsuttles", "http://twitter.com/jlsuttles"],
|
"url": ["http://flickr.com/jlsuttles", "http://twitter.com/jlsuttles"],
|
||||||
"name": ["Jessica Lynn Suttles"],
|
"name": ["Jessica Lynn Suttles"],
|
||||||
"bday": ["1990-10-15T20:45:33-08:00"],
|
"bday": ["1990-10-15"],
|
||||||
"content": ["Vegan. Cat lover. Coder."]
|
"content": ["<p>Vegan. Cat lover. Coder.</p>"]
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue