shard-ameba/spec/ameba/rule/lint/debugger_statement_spec.cr
fn ⌃ ⌥ 7b437fbd2f
Remove normalize parameter from expect_issue (#249)
* Add `normalize` parameter to `expect_correction`

* Convert Style/IsAFilter spec

* Revert "Add `normalize` parameter to `expect_correction`"

This reverts commit 4b67e4b900.

* Remove `normalize` parameter from `expect_issue`

* Require indentation if multiple issues on a single line

* Update `Style/IsAFilter` spec

* Update `ExpectIssue` documentation

* Add missing `expect_no_corrections`

* Use carets and space with issues at column 1 or 2

* Update `expect_issue` docs
2021-11-06 15:15:19 +02:00

46 lines
1.1 KiB
Crystal

require "../../../spec_helper"
module Ameba::Rule::Lint
subject = DebuggerStatement.new
describe DebuggerStatement do
it "passes if there is no debugger statement" do
expect_no_issues subject, <<-CRYSTAL
"this is not a debugger statement"
s = "debugger"
def debugger(program)
end
debugger ""
class A
def debugger
end
end
A.new.debugger
CRYSTAL
end
it "fails if there is a debugger statement" do
source = expect_issue subject, <<-CRYSTAL
a = 2
debugger
# ^^^^^^ error: Possible forgotten debugger statement detected
a = a + 1
CRYSTAL
expect_no_corrections source
end
it "reports rule, pos and message" do
s = Source.new "debugger", "source.cr"
subject.catch(s).should_not be_valid
issue = s.issues.first
issue.rule.should_not be_nil
issue.location.to_s.should eq "source.cr:1:1"
issue.end_location.to_s.should eq "source.cr:1:8"
issue.message.should eq "Possible forgotten debugger statement detected"
end
end
end