From 7f85434c85484ee292f7dbef596537c60c1720fe Mon Sep 17 00:00:00 2001 From: Sijawusz Pur Rahnama Date: Mon, 4 Apr 2022 21:14:45 +0200 Subject: [PATCH] Use issue expectation helpers in `Lint::RandZero` rule spec --- spec/ameba/rule/lint/rand_zero_spec.cr | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/spec/ameba/rule/lint/rand_zero_spec.cr b/spec/ameba/rule/lint/rand_zero_spec.cr index a86d30f2..cb5cc6d4 100644 --- a/spec/ameba/rule/lint/rand_zero_spec.cr +++ b/spec/ameba/rule/lint/rand_zero_spec.cr @@ -5,22 +5,25 @@ module Ameba::Rule::Lint subject = RandZero.new it "passes if it is not rand(1) or rand(0)" do - s = Source.new %( + expect_no_issues subject, <<-CRYSTAL rand(1.0) rand(0.11) rand(2) - ) - subject.catch(s).should be_valid + CRYSTAL end it "fails if it is rand(0)" do - s = Source.new "rand(0)" - subject.catch(s).should_not be_valid + expect_issue subject, <<-CRYSTAL + rand(0) + # ^^^^^ error: rand(0) always returns 0 + CRYSTAL end it "fails if it is rand(1)" do - s = Source.new "rand(1)" - subject.catch(s).should_not be_valid + expect_issue subject, <<-CRYSTAL + rand(1) + # ^^^^^ error: rand(1) always returns 0 + CRYSTAL end it "reports rule, location and a message" do