require 'spec_helper' describe HentryConsumer::HEntry do describe "example.html" do let(:result) { HentryConsumer.parse("spec/support/example.html") } let(:entry) { result.entries.first } it "should have an array of entries" do entry.should be_an_instance_of HentryConsumer::HEntry end it "has a name" do entry.name.should eq ["Senior Cat Living"] end it "has a summary" do entry.summary.should eq ["Signed up with 3 locations"] end it "has a time" do entry.published_at.should eq ["2012-08-24 20:09-0700"] end it "is older than now" do entry.older_than(Time.now).should be_true end it "is not older than 2010" do entry.older_than(Time.parse("Jan 1 2010")).should be_false end it "has a bookmark" do entry.bookmark.should eq "http://g5.com/feed/entries/2012-08-26-20-09-0700" end it "should have 2 authors as HCards" do entry.authors.should have(2).things HentryConsumer::HCard end describe "categories" do it "is a hash" do entry.categories.should be_an_instance_of Hash end it "has a key of the category and value of it's UID" do entry.categories["New Customer"].should eq "http://g5.com/tag/new-customer" end end describe "content" do let(:content) { entry.content } it "should be a blob of html" do content.first.should match /Locations/ end it "should be a blob of html" do content.first.should match /\/ end it "should be a blob of html" do content.first.should_not match /time/ end end describe "json" do let(:json) { JSON.parse(entry.to_json) } it { json.should be_an_instance_of Hash } it { json["type"].should include 'h-entry'} it { json["properties"]["name"].should eq ['Senior Cat Living']} it { json["properties"]["content"].first.should match /Locations/ } it { json["properties"]["author"].should be_an_instance_of Array } it { json["properties"]["author"].first["type"].should include "h-card" } it { json["properties"]["bookmark"].should eq "http://g5.com/feed/entries/2012-08-26-20-09-0700" } it { json["properties"]["published_at"].should eq ["2012-08-24 20:09-0700"] } it { json["properties"]["summary"].should be_an_instance_of Array } end end describe "nested_example.html" do let(:result) { HentryConsumer.parse("spec/support/nested_example.html") } let(:entry) { result.entries.first } it "should have an array of entries" do entry.should be_an_instance_of HentryConsumer::HEntry end it "has a name" do entry.name.should eq ["Wabi Sabi Town"] end it "has a summary" do entry.summary.should eq ["Signed up with 2 locations"] end it "has a time" do entry.published_at.should eq ["2012-10-10T19:11:17Z"] end it "has a bookmark" do entry.bookmark.should eq "http://localhost:3000/customers/3" end it "should have 1 author as an HCard" do entry.authors.should have(1).things HentryConsumer::HCard end describe "categories" do it "is a Hash" do entry.categories.should be_an_instance_of Hash end it "has a key of the category and value of it's UID" do entry.categories["Some Category"].should eq "#" end end describe "content" do let(:content) { entry.content } it "should be a blob of html" do content.first.should match /Locations/ end it "should be a blob of html" do content.first.should match /\/ end it "should be a blob of html" do content.first.should_not match /time/ end end describe "json" do let(:json) { JSON.parse(entry.to_json) } it { json.should be_an_instance_of Hash } it { json["type"].should include 'h-entry'} it { json["properties"]["name"].should eq ['Wabi Sabi Town']} it { json["properties"]["content"].first.should match /Locations/ } it { json["properties"]["author"].should be_an_instance_of Array } it { json["properties"]["author"].first["type"].should include "h-card" } it { json["properties"]["bookmark"].should eq "http://localhost:3000/customers/3" } it { json["properties"]["published_at"].should eq ["2012-10-10T19:11:17Z"] } it { json["properties"]["summary"].should be_an_instance_of Array } end end end