mirror of
https://gitea.invidious.io/iv-org/shard-ameba.git
synced 2024-08-15 00:53:29 +00:00
Use issue expectation helpers in Lint::RandZero
rule spec
This commit is contained in:
parent
c58d4cc65a
commit
7f85434c85
1 changed files with 10 additions and 7 deletions
|
@ -5,22 +5,25 @@ module Ameba::Rule::Lint
|
||||||
subject = RandZero.new
|
subject = RandZero.new
|
||||||
|
|
||||||
it "passes if it is not rand(1) or rand(0)" do
|
it "passes if it is not rand(1) or rand(0)" do
|
||||||
s = Source.new %(
|
expect_no_issues subject, <<-CRYSTAL
|
||||||
rand(1.0)
|
rand(1.0)
|
||||||
rand(0.11)
|
rand(0.11)
|
||||||
rand(2)
|
rand(2)
|
||||||
)
|
CRYSTAL
|
||||||
subject.catch(s).should be_valid
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it "fails if it is rand(0)" do
|
it "fails if it is rand(0)" do
|
||||||
s = Source.new "rand(0)"
|
expect_issue subject, <<-CRYSTAL
|
||||||
subject.catch(s).should_not be_valid
|
rand(0)
|
||||||
|
# ^^^^^ error: rand(0) always returns 0
|
||||||
|
CRYSTAL
|
||||||
end
|
end
|
||||||
|
|
||||||
it "fails if it is rand(1)" do
|
it "fails if it is rand(1)" do
|
||||||
s = Source.new "rand(1)"
|
expect_issue subject, <<-CRYSTAL
|
||||||
subject.catch(s).should_not be_valid
|
rand(1)
|
||||||
|
# ^^^^^ error: rand(1) always returns 0
|
||||||
|
CRYSTAL
|
||||||
end
|
end
|
||||||
|
|
||||||
it "reports rule, location and a message" do
|
it "reports rule, location and a message" do
|
||||||
|
|
Loading…
Reference in a new issue