shard-ameba/spec/ameba/rule/lint/syntax_spec.cr

31 lines
695 B
Crystal
Raw Normal View History

require "../../../spec_helper"
2018-01-25 08:38:12 +00:00
module Ameba::Rule::Lint
2018-01-25 08:38:12 +00:00
describe Syntax do
subject = Syntax.new
it "passes if there is no invalid syntax" do
expect_no_issues subject, <<-CRYSTAL
2018-01-25 08:38:12 +00:00
def hello
puts "totally valid"
rescue e : Exception
2018-01-25 08:38:12 +00:00
end
CRYSTAL
2018-01-25 08:38:12 +00:00
end
it "fails if there is an invalid syntax" do
expect_issue subject, <<-CRYSTAL
2018-01-25 08:38:12 +00:00
def hello
puts "invalid"
rescue Exception => e
# ^ error: expecting any of these tokens: ;, NEWLINE (not '=>')
2018-01-25 08:38:12 +00:00
end
CRYSTAL
2018-01-25 08:38:12 +00:00
end
2019-04-13 19:38:37 +00:00
it "has highest severity" do
subject.severity.should eq Severity::Error
end
2018-01-25 08:38:12 +00:00
end
end