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
|
||||
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue