forked from stringer-rss/stringer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathread_items_spec.rb
More file actions
64 lines (57 loc) · 1.75 KB
/
read_items_spec.rb
File metadata and controls
64 lines (57 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
require "spec_helper"
app_require "fever_api/read_items"
describe FeverAPI::ReadItems do
let(:story_repository) { double('repo') }
subject do
FeverAPI::ReadItems.new(story_repository: story_repository)
end
it "returns a list of unread items including total count" do
story_repository.should_receive(:unread).twice.and_return([
double('story', as_fever_json: { id: 5 } ),
double('story', as_fever_json: { id: 7 } ),
double('story', as_fever_json: { id: 11 } )
])
subject.call('items' => nil).should == {
items: [
{ id: 5 },
{ id: 7 },
{ id: 11 }
],
total_items: 3
}
end
it "returns a list of unread items since id including total count" do
story_repository.should_receive(:unread_since_id).with(3).and_return([
double('story', as_fever_json: { id: 5 } ),
double('story', as_fever_json: { id: 7 } ),
])
story_repository.should_receive(:unread).and_return([
double('story', as_fever_json: { id: 2 } ),
double('story', as_fever_json: { id: 5 } ),
double('story', as_fever_json: { id: 7 } ),
])
subject.call('items' => nil, since_id: 3).should == {
items: [
{ id: 5 },
{ id: 7 },
],
total_items: 3
}
end
it "returns a list of specified items including total count" do
story_repository.should_receive(:fetch_by_ids).with(['5', '11']).twice.and_return([
double('story', as_fever_json: { id: 5 } ),
double('story', as_fever_json: { id: 11 } )
])
subject.call('items' => nil, with_ids: '5,11').should == {
items: [
{ id: 5 },
{ id: 11 }
],
total_items: 2
}
end
it "returns an empty hash otherwise" do
subject.call.should == {}
end
end