Sha256: dfd849a9828db9a44a83c5254b9d3ff47a1e4d4031b5c965351cc571330995c2
Contents?: true
Size: 1.83 KB
Versions: 1
Compression:
Stored size: 1.83 KB
Contents
require 'hentry_consumer' describe HentryConsumer::HFeed do let(:feed) { HentryConsumer.parse(File.open("spec/support/example.html")) } describe "caching" do let(:time_feed) { HentryConsumer::HFeed.new("spec/support/example.html", last_modified_at: "8:09pm on August 25th, 2012") } it "returns false on 304" do HentryConsumer::HFeed.any_instance.stub(:open). with("spec/support/example.html", "If-Modified-Since" => "Sun, 26 Aug 2012 03:09:00 GMT"). and_raise( OpenURI::HTTPError.new("304 Not Modified", nil) ) lambda { HentryConsumer::HFeed.new("spec/support/example.html", last_modified_at: Time.parse("8:09pm on August 25th, 2012")) }. should raise_error OpenURI::HTTPError, "304 Not Modified" end it "doesn't add old entries" do time_feed.entries.should have(1).thing end it "header has last modified since" do time_feed.headers.should eq({"If-Modified-Since" => "Sun, 26 Aug 2012 03:09:00 GMT"}) end it "header has last modified since" do feed.headers.should eq({}) end end describe "#to_json" do let(:json) { JSON.parse(feed.to_json) } it { json["items"].first["type"].should include 'h-feed'} it { json["items"].first["properties"]["entries"].should be_an_instance_of Array } it { json["items"].first["properties"]["entries"].should be_an_instance_of Array } it { json["items"].first["properties"]["entries"].first["type"].should include "h-entry" } end describe "#to_s" do let(:string) { feed.to_s } it "should have nicely formatted content" do string.should match feed.to_html end end describe "#to_html" do let(:html) { feed.to_html } it "should match the example html" do html.gsub(/\\n|\s/, '').should eq File.open("spec/support/example.html").read.gsub(/\\n|\s/, '') end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
hentry_consumer-0.8.0 | spec/lib/hentry_consumer/h_feed_spec.rb |