Expect to raise error should use a block (#17131)
* Expect to raise error should use a block This is kind of pedantic, since we _had_ been using a lambda, and calling as a value. Now explicitly call the proc in a block and expect the block to raise error. * Replace lambda with block Replace lambda passed as a value to an implicit block with a block.
This commit is contained in:
parent
bd980c3dd7
commit
76470febb7
2 changed files with 4 additions and 4 deletions
|
|
@ -62,7 +62,7 @@ RSpec.describe "/admin/reactions", type: :request do
|
|||
put admin_reaction_path(reaction.id), params: { id: reaction.id, status: "confirmed" }
|
||||
end
|
||||
|
||||
expect(invalid_request).to raise_error(Pundit::NotAuthorizedError)
|
||||
expect { invalid_request.call }.to raise_error(Pundit::NotAuthorizedError)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -27,17 +27,17 @@ RSpec.describe AnalyticsService, type: :service do
|
|||
|
||||
describe "initialization" do
|
||||
it "raises an error if start date is invalid" do
|
||||
expect(-> { described_class.new(user, start_date: "2000-") }).to raise_error(ArgumentError)
|
||||
expect { described_class.new(user, start_date: "2000-") }.to raise_error(ArgumentError)
|
||||
end
|
||||
|
||||
it "raises an error if end date is invalid" do
|
||||
expect(-> { described_class.new(user, end_date: "2000-") }).to raise_error(ArgumentError)
|
||||
expect { described_class.new(user, end_date: "2000-") }.to raise_error(ArgumentError)
|
||||
end
|
||||
|
||||
it "raises an error if an article does not belong to the user" do
|
||||
other_user = create(:user)
|
||||
article = create(:article, user: other_user)
|
||||
expect(-> { described_class.new(user, article_id: article.id) }).to raise_error(ArgumentError)
|
||||
expect { described_class.new(user, article_id: article.id) }.to raise_error(ArgumentError)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue