@@ -11,8 +11,8 @@ def cannot_auth
11
11
{ api_version : 3 , auth : 0 }
12
12
end
13
13
14
- def last_response_as_object
15
- JSON . parse ( last_response . body , symbolize_names : true )
14
+ def response_as_object
15
+ JSON . parse ( response . body , symbolize_names : true )
16
16
end
17
17
18
18
def params ( user : create ( :user ) , **overrides )
@@ -23,29 +23,29 @@ def params(user: create(:user), **overrides)
23
23
it "authenticates request with correct api_key" do
24
24
get ( "/fever" , params :)
25
25
26
- expect ( last_response_as_object ) . to include ( standard_answer )
26
+ expect ( response_as_object ) . to include ( standard_answer )
27
27
end
28
28
29
29
it "does not authenticate request with incorrect api_key" do
30
30
get "/fever" , params : params ( api_key : "foo" )
31
31
32
- expect ( last_response_as_object ) . to include ( cannot_auth )
32
+ expect ( response_as_object ) . to include ( cannot_auth )
33
33
end
34
34
35
35
it "does not authenticate request when api_key is not provided" do
36
36
create ( :user )
37
37
38
38
get "/fever" , params : params ( api_key : nil )
39
39
40
- expect ( last_response_as_object ) . to include ( cannot_auth )
40
+ expect ( response_as_object ) . to include ( cannot_auth )
41
41
end
42
42
end
43
43
44
44
describe "#get" do
45
45
it "returns standard answer" do
46
46
get ( "/fever" , params :)
47
47
48
- expect ( last_response_as_object ) . to include ( standard_answer )
48
+ expect ( response_as_object ) . to include ( standard_answer )
49
49
end
50
50
51
51
it "returns groups and feeds by groups when 'groups' header is provided" do
@@ -54,7 +54,7 @@ def params(user: create(:user), **overrides)
54
54
get ( "/fever" , params : params ( groups : nil ) )
55
55
56
56
groups = [ { group_id : feed . group_id , feed_ids : feed . id . to_s } ]
57
- expect ( last_response_as_object ) . to include ( standard_answer )
57
+ expect ( response_as_object ) . to include ( standard_answer )
58
58
. and include ( groups : [ feed . group . as_fever_json ] , feeds_groups : groups )
59
59
end
60
60
@@ -64,15 +64,15 @@ def params(user: create(:user), **overrides)
64
64
get ( "/fever" , params : params ( feeds : nil ) )
65
65
66
66
groups = [ { group_id : feed . group_id , feed_ids : feed . id . to_s } ]
67
- expect ( last_response_as_object ) . to include ( standard_answer )
67
+ expect ( response_as_object ) . to include ( standard_answer )
68
68
. and include ( feeds : [ feed . as_fever_json ] , feeds_groups : groups )
69
69
end
70
70
71
71
it "returns favicons hash when 'favicons' header provided" do
72
72
get ( "/fever" , params : params ( favicons : nil ) )
73
73
74
74
favicon = { id : 0 , data : a_string_including ( "image/gif;base64" ) }
75
- expect ( last_response_as_object ) . to include ( standard_answer )
75
+ expect ( response_as_object ) . to include ( standard_answer )
76
76
. and include ( favicons : [ favicon ] )
77
77
end
78
78
@@ -82,7 +82,7 @@ def params(user: create(:user), **overrides)
82
82
83
83
get ( "/fever" , params : params ( items : nil , since_id : 5 ) )
84
84
85
- expect ( last_response_as_object ) . to include ( standard_answer )
85
+ expect ( response_as_object ) . to include ( standard_answer )
86
86
. and include ( items : [ story_two . as_fever_json ] , total_items : 2 )
87
87
end
88
88
@@ -91,7 +91,7 @@ def params(user: create(:user), **overrides)
91
91
92
92
get ( "/fever" , params : params ( items : nil ) )
93
93
94
- expect ( last_response_as_object ) . to include ( standard_answer )
94
+ expect ( response_as_object ) . to include ( standard_answer )
95
95
. and include ( items : stories . map ( &:as_fever_json ) , total_items : 2 )
96
96
end
97
97
@@ -100,14 +100,14 @@ def params(user: create(:user), **overrides)
100
100
101
101
get ( "/fever" , params : params ( items : nil , with_ids : story . id ) )
102
102
103
- expect ( last_response_as_object ) . to include ( standard_answer )
103
+ expect ( response_as_object ) . to include ( standard_answer )
104
104
. and include ( items : [ story . as_fever_json ] , total_items : 1 )
105
105
end
106
106
107
107
it "returns links as empty array when 'links' header is provided" do
108
108
get ( "/fever" , params : params ( links : nil ) )
109
109
110
- expect ( last_response_as_object ) . to include ( standard_answer )
110
+ expect ( response_as_object ) . to include ( standard_answer )
111
111
. and include ( links : [ ] )
112
112
end
113
113
@@ -116,7 +116,7 @@ def params(user: create(:user), **overrides)
116
116
117
117
get ( "/fever" , params : params ( unread_item_ids : nil ) )
118
118
119
- expect ( last_response_as_object ) . to include ( standard_answer )
119
+ expect ( response_as_object ) . to include ( standard_answer )
120
120
. and include ( unread_item_ids : stories . map ( &:id ) . join ( "," ) )
121
121
end
122
122
@@ -125,7 +125,7 @@ def params(user: create(:user), **overrides)
125
125
126
126
get ( "/fever" , params : params ( saved_item_ids : nil ) )
127
127
128
- expect ( last_response_as_object ) . to include ( standard_answer )
128
+ expect ( response_as_object ) . to include ( standard_answer )
129
129
. and include ( saved_item_ids : stories . map ( &:id ) . join ( "," ) )
130
130
end
131
131
end
@@ -136,31 +136,31 @@ def params(user: create(:user), **overrides)
136
136
137
137
post ( "/fever" , params : params ( mark : "item" , as : "read" , id : story . id ) )
138
138
139
- expect ( last_response_as_object ) . to include ( standard_answer )
139
+ expect ( response_as_object ) . to include ( standard_answer )
140
140
end
141
141
142
142
it "commands to mark story as unread" do
143
143
story = create ( :story , :read )
144
144
145
145
post ( "/fever" , params : params ( mark : "item" , as : "unread" , id : story . id ) )
146
146
147
- expect ( last_response_as_object ) . to include ( standard_answer )
147
+ expect ( response_as_object ) . to include ( standard_answer )
148
148
end
149
149
150
150
it "commands to save story" do
151
151
story = create ( :story )
152
152
153
153
post ( "/fever" , params : params ( mark : "item" , as : "saved" , id : story . id ) )
154
154
155
- expect ( last_response_as_object ) . to include ( standard_answer )
155
+ expect ( response_as_object ) . to include ( standard_answer )
156
156
end
157
157
158
158
it "commands to unsave story" do
159
159
story = create ( :story , :starred )
160
160
161
161
post ( "/fever" , params : params ( mark : "item" , as : "unsaved" , id : story . id ) )
162
162
163
- expect ( last_response_as_object ) . to include ( standard_answer )
163
+ expect ( response_as_object ) . to include ( standard_answer )
164
164
end
165
165
166
166
it "commands to mark group as read" do
@@ -170,7 +170,7 @@ def params(user: create(:user), **overrides)
170
170
171
171
post ( "/fever" , params : params ( mark : "group" , as : "read" , id :, before :) )
172
172
173
- expect ( last_response_as_object ) . to include ( standard_answer )
173
+ expect ( response_as_object ) . to include ( standard_answer )
174
174
end
175
175
176
176
it "commands to mark entire feed as read" do
0 commit comments