Skip to content
This repository was archived by the owner on Oct 13, 2025. It is now read-only.

Commit 0cf3536

Browse files
committed
refactor: use new assertion format
Use the new assertion format to modernise the code.
1 parent 0d0c087 commit 0cf3536

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

spec/api/comment_spec.rb

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -253,68 +253,68 @@ def test_unicode_data(text)
253253

254254
it "doesn't allow retrieving all comments" do
255255
get "/api/v1/comments"
256-
last_response.should_not be_ok
256+
expect(last_response).not_to be_ok
257257
end
258258

259259
let(:user) { User.first }
260260

261261
it "does not allow filtering only by user" do
262262
get "/api/v1/comments", user_id: user.id
263-
last_response.should_not be_ok
263+
expect(last_response).not_to be_ok
264264
end
265265

266266
it "does not allow filtering only by course" do
267267
get "/api/v1/comments", course_id: "abc"
268-
last_response.should_not be_ok
268+
expect(last_response).not_to be_ok
269269
end
270270

271271
it "allows filtering by course and user" do
272272
get "/api/v1/comments", user_id: user.id, course_id: "abc"
273-
last_response.should be_ok
273+
expect(last_response).to be_ok
274274
parsed = parse last_response.body
275-
parsed["comment_count"].should == 25
275+
expect(parsed["comment_count"]).to eq(25)
276276
for item in parsed["collection"]
277-
item["username"].should == user.username
278-
item["course_id"].should == "abc"
277+
expect(item["username"]).to eq(user.username)
278+
expect(item["course_id"]).to eq("abc")
279279
end
280280
end
281281

282282
it "allows filtering by flagged status" do
283283
get "/api/v1/comments", user_id: user.id, course_id: "abc", flagged: true
284-
last_response.should be_ok
284+
expect(last_response).to be_ok
285285
parsed = parse last_response.body
286-
parsed["comment_count"].should == 5
286+
expect(parsed["comment_count"]).to eq(5)
287287
for item in parsed["collection"]
288-
item["abuse_flaggers"].should_not be_empty
288+
expect(item["abuse_flaggers"]).not_to be_empty
289289
end
290290
end
291291

292292
it "paginates the comments with default values" do
293293
get "/api/v1/comments", user_id: user.id, course_id: "abc"
294294
parsed = parse last_response.body
295-
parsed["page"].should == 1
296-
parsed["collection"].length.should == DEFAULT_PER_PAGE
297-
parsed["num_pages"].should == (25 / DEFAULT_PER_PAGE.to_f).ceil
295+
expect(parsed["page"]).to eq(1)
296+
expect(parsed["collection"].length).to eq(DEFAULT_PER_PAGE)
297+
expect(parsed["num_pages"]).to eq((25 / DEFAULT_PER_PAGE.to_f).ceil)
298298
end
299299

300300
it "allows specifying a page size" do
301301
get "/api/v1/comments", user_id: user.id, course_id: "abc", per_page: 5
302-
last_response.should be_ok
302+
expect(last_response).to be_ok
303303
parsed = parse last_response.body
304-
parsed["collection"].length.should == 5
305-
parsed["num_pages"].should == 5
304+
expect(parsed["collection"].length).to eq(5)
305+
expect(parsed["num_pages"]).to eq(5)
306306
end
307307

308308
it "allows specifying a page number" do
309309
get "/api/v1/comments", user_id: user.id, course_id: "abc", page: 2
310310
parsed = parse last_response.body
311-
parsed["page"].should == 2
311+
expect(parsed["page"]).to eq(2)
312312
end
313313

314314
it "handles the end of pagination correctly" do
315315
get "/api/v1/comments", user_id: user.id, course_id: "abc", page: 2
316316
parsed = parse last_response.body
317-
parsed["collection"].length.should == 5
317+
expect(parsed["collection"].length).to eq(5)
318318
end
319319

320320
it "returns the correct items for each page" do
@@ -331,7 +331,7 @@ def test_unicode_data(text)
331331
page_3 = parse last_response.body
332332

333333

334-
all_items["collection"].should == (
334+
expect(all_items["collection"]).to eq(
335335
page_1["collection"] +
336336
page_2["collection"] +
337337
page_3["collection"]

0 commit comments

Comments
 (0)