forked from stringer-rss/stringer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfind_new_stories_spec.rb
More file actions
49 lines (40 loc) · 1.75 KB
/
find_new_stories_spec.rb
File metadata and controls
49 lines (40 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
require "spec_helper"
app_require "commands/feeds/find_new_stories"
describe FindNewStories do
describe "#new_stories" do
context "the feed has not been updated" do
it "should find zero new stories" do
feed = stub(last_modified: Time.new(2013, 1, 1))
result = FindNewStories.new(feed, Time.new(2013, 1, 2)).new_stories
result.should be_empty
end
end
context "the feed has been updated" do
it "should return stories that are new based on published date" do
new_story = stub(published: Time.new(2013, 1, 5))
old_story = stub(published: Time.new(2013, 1, 1))
feed = stub(last_modified: Time.new(2013, 1, 5), entries: [new_story, old_story])
result = FindNewStories.new(feed, Time.new(2013, 1, 3)).new_stories
result.should eq [new_story]
end
end
context "the feed does not report last_modified" do
it "should check all stories and compare published time" do
new_story = stub(published: Time.new(2013, 1, 5))
old_story = stub(published: Time.new(2013, 1, 1))
feed = stub(last_modified: nil, entries: [new_story, old_story])
result = FindNewStories.new(feed, Time.new(2013, 1, 3)).new_stories
result.should eq [new_story]
end
end
context "the feed has no timekeeping" do
it "should scan until matching the last url" do
new_story = stub(published: nil, url: "http://blog.com/new-story")
old_story = stub(published: nil, url: "http://blog.com/old-story")
feed = stub(last_modified: nil, entries: [new_story, old_story])
result = FindNewStories.new(feed, Time.new(2013, 1, 3), "http://blog.com/old-story").new_stories
result.should eq [new_story]
end
end
end
end