spec/feedzirra/feed_spec.rb in feedzirra-0.1.3 vs spec/feedzirra/feed_spec.rb in feedzirra-0.2.0.rc1
- old
+ new
@@ -41,39 +41,39 @@
describe "#parse" do # many of these tests are redundant with the specific feed type tests, but I put them here for completeness
context "when there's an available parser" do
it "should parse an rdf feed" do
feed = Feedzirra::Feed.parse(sample_rdf_feed)
feed.title.should == "HREF Considered Harmful"
- feed.entries.first.published.to_s.should == "Tue Sep 02 19:50:07 UTC 2008"
+ feed.entries.first.published.should == Time.parse_safely("Tue Sep 02 19:50:07 UTC 2008")
feed.entries.size.should == 10
end
it "should parse an rss feed" do
feed = Feedzirra::Feed.parse(sample_rss_feed)
feed.title.should == "Tender Lovemaking"
- feed.entries.first.published.to_s.should == "Thu Dec 04 17:17:49 UTC 2008"
+ feed.entries.first.published.should == Time.parse_safely("Thu Dec 04 17:17:49 UTC 2008")
feed.entries.size.should == 10
end
it "should parse an atom feed" do
feed = Feedzirra::Feed.parse(sample_atom_feed)
feed.title.should == "Amazon Web Services Blog"
- feed.entries.first.published.to_s.should == "Fri Jan 16 18:21:00 UTC 2009"
+ feed.entries.first.published.should == Time.parse_safely("Fri Jan 16 18:21:00 UTC 2009")
feed.entries.size.should == 10
end
it "should parse an feedburner atom feed" do
feed = Feedzirra::Feed.parse(sample_feedburner_atom_feed)
feed.title.should == "Paul Dix Explains Nothing"
- feed.entries.first.published.to_s.should == "Thu Jan 22 15:50:22 UTC 2009"
+ feed.entries.first.published.should == Time.parse_safely("Thu Jan 22 15:50:22 UTC 2009")
feed.entries.size.should == 5
end
it "should parse an itunes feed as a standard RSS feed" do
feed = Feedzirra::Feed.parse(sample_itunes_feed)
feed.title.should == "All About Everything"
- feed.entries.first.published.should == Time.parse("Wed, 15 Jun 2005 19:00:00 GMT")
+ feed.entries.first.published.should == Time.parse_safely("Wed, 15 Jun 2005 19:00:00 GMT")
# Since the commit 621957879, iTunes feeds will be parsed as standard RSS, so this
# entry should now not have a method for itunes_author.
feed.entries.first.should_not respond_to(:itunes_author)
feed.entries.size.should == 3
@@ -89,11 +89,11 @@
end
it "should parse an feedburner rss feed" do
feed = Feedzirra::Feed.parse(sample_rss_feed_burner_feed)
feed.title.should == "TechCrunch"
- feed.entries.first.published.to_s.should == "Wed Nov 02 17:25:27 UTC 2011"
+ feed.entries.first.published.should == Time.parse_safely("Wed Nov 02 17:25:27 UTC 2011")
feed.entries.size.should == 20
end
end
describe "#determine_feed_parser_for_xml" do
@@ -165,11 +165,11 @@
before(:each) do
@header = "HTTP/1.0 200 OK\r\nDate: Thu, 29 Jan 2009 03:55:24 GMT\r\nServer: Apache\r\nX-FB-Host: chi-write6\r\nLast-Modified: Wed, 28 Jan 2009 04:10:32 GMT\r\nETag: ziEyTl4q9GH04BR4jgkImd0GvSE\r\nP3P: CP=\"ALL DSP COR NID CUR OUR NOR\"\r\nConnection: close\r\nContent-Type: text/xml;charset=utf-8\r\n\r\n"
end
it "should return the last modified date from the header if it exists" do
- Feedzirra::Feed.last_modified_from_header(@header).should == Time.parse("Wed, 28 Jan 2009 04:10:32 GMT")
+ Feedzirra::Feed.last_modified_from_header(@header).should == Time.parse_safely("Wed, 28 Jan 2009 04:10:32 GMT")
end
it "should return nil if there is no last modified date in the header" do
Feedzirra::Feed.last_modified_from_header("foo").should be_nil
end
@@ -202,11 +202,11 @@
Feedzirra::Feed.fetch_raw(@paul_feed[:url])
@curl.headers['User-Agent'].should == Feedzirra::Feed::USER_AGENT
end
it "should set if modified since as an option if passed" do
- Feedzirra::Feed.fetch_raw(@paul_feed[:url], :if_modified_since => Time.parse("Wed, 28 Jan 2009 04:10:32 GMT"))
+ Feedzirra::Feed.fetch_raw(@paul_feed[:url], :if_modified_since => Time.parse_safely("Wed, 28 Jan 2009 04:10:32 GMT"))
@curl.headers["If-Modified-Since"].should == 'Wed, 28 Jan 2009 04:10:32 GMT'
end
it "should set if none match as an option if passed" do
Feedzirra::Feed.fetch_raw(@paul_feed[:url], :if_none_match => 'ziEyTl4q9GH04BR4jgkImd0GvSE')
@@ -256,10 +256,11 @@
end
end
describe "#add_url_to_multi" do
before(:each) do
+ allow_message_expectations_on_nil
@multi = Curl::Multi.get([@paul_feed[:url]], {:follow_location => true}, {:pipeline => true})
@multi.stub!(:add)
@easy_curl = Curl::Easy.new(@paul_feed[:url])
Curl::Easy.should_receive(:new).and_yield(@easy_curl)
@@ -274,11 +275,11 @@
Feedzirra::Feed.add_url_to_multi(@multi, @paul_feed[:url], [], {}, {})
@easy_curl.headers["User-Agent"].should == Feedzirra::Feed::USER_AGENT
end
it "should set if modified since as an option if passed" do
- Feedzirra::Feed.add_url_to_multi(@multi, @paul_feed[:url], [], {}, :if_modified_since => Time.parse("Jan 25 2009 04:10:32 GMT"))
+ Feedzirra::Feed.add_url_to_multi(@multi, @paul_feed[:url], [], {}, :if_modified_since => Time.parse_safely("Jan 25 2009 04:10:32 GMT"))
@easy_curl.headers["If-Modified-Since"].should == 'Sun, 25 Jan 2009 04:10:32 GMT'
end
it 'should set follow location to true' do
@easy_curl.should_receive(:follow_location=).with(true)
@@ -398,10 +399,11 @@
end
end
describe "#add_feed_to_multi" do
before(:each) do
+ allow_message_expectations_on_nil
@multi = Curl::Multi.get([@paul_feed[:url]], {:follow_location => true}, {:pipeline => true})
@multi.stub!(:add)
@easy_curl = Curl::Easy.new(@paul_feed[:url])
@feed = Feedzirra::Feed.parse(sample_feedburner_atom_feed)
@@ -417,11 +419,11 @@
Feedzirra::Feed.add_feed_to_multi(@multi, @feed, [], {}, {})
@easy_curl.headers["User-Agent"].should == Feedzirra::Feed::USER_AGENT
end
it "should set if modified since as an option if passed" do
- modified_time = Time.parse("Wed, 28 Jan 2009 04:10:32 GMT")
+ modified_time = Time.parse_safely("Wed, 28 Jan 2009 04:10:32 GMT")
Feedzirra::Feed.add_feed_to_multi(@multi, @feed, [], {}, {:if_modified_since => modified_time})
modified_time.should be > @feed.last_modified
@easy_curl.headers["If-Modified-Since"].should == modified_time
end
@@ -538,10 +540,10 @@
it 'should slice the feeds into groups of thirty for processing'
it "should return a feed object if a single feed is passed in"
it "should return an return an array of feed objects if multiple feeds are passed in"
it "should set if modified since as an option if passed" do
- modified_time = Time.parse("Wed, 28 Jan 2009 04:10:32 GMT")
+ modified_time = Time.parse_safely("Wed, 28 Jan 2009 04:10:32 GMT")
Feedzirra::Feed.should_receive(:add_url_to_multi).with(anything, anything, anything, anything, {:if_modified_since => modified_time}).any_number_of_times
@feed = Feedzirra::Feed.fetch_and_parse(sample_feedburner_atom_feed, {:if_modified_since => modified_time})
end