Compare commits
4 Commits
63be60ce96
...
107c6e0ea6
Author | SHA1 | Date |
---|---|---|
Sijawusz Pur Rahnama | 107c6e0ea6 | |
Sijawusz Pur Rahnama | a661cf10fc | |
Sijawusz Pur Rahnama | a2c9aa67cc | |
Sijawusz Pur Rahnama | e2d6c69039 |
|
@ -4,6 +4,16 @@ module Ameba::Rule::Lint
|
|||
subject = SpecFilename.new
|
||||
|
||||
describe SpecFilename do
|
||||
it "passes if relative file path does not start with `spec/`" do
|
||||
expect_no_issues subject, code: "", path: "src/spec/foo.cr"
|
||||
expect_no_issues subject, code: "", path: "src/spec/foo/bar.cr"
|
||||
end
|
||||
|
||||
it "passes if file extension is not `.cr`" do
|
||||
expect_no_issues subject, code: "", path: "spec/foo.json"
|
||||
expect_no_issues subject, code: "", path: "spec/foo/bar.json"
|
||||
end
|
||||
|
||||
it "passes if filename is correct" do
|
||||
expect_no_issues subject, code: "", path: "spec/foo_spec.cr"
|
||||
expect_no_issues subject, code: "", path: "spec/foo/bar_spec.cr"
|
||||
|
|
|
@ -8,6 +8,8 @@ module Ameba::Rule::Lint
|
|||
# ```
|
||||
# Lint/SpecFilename:
|
||||
# Enabled: true
|
||||
# IgnoredDirs: [spec/support spec/fixtures spec/data]
|
||||
# IgnoredFilenames: [spec_helper]
|
||||
# ```
|
||||
class SpecFilename < Base
|
||||
properties do
|
||||
|
@ -26,8 +28,10 @@ module Ameba::Rule::Lint
|
|||
name = path_.stem
|
||||
path = path_.to_s
|
||||
|
||||
# check files only within spec/ directory
|
||||
# check only files within spec/ directory
|
||||
return unless path.starts_with?("spec/")
|
||||
# check only files with `.cr` extension
|
||||
return unless path.ends_with?(".cr")
|
||||
# ignore files having `_spec` suffix
|
||||
return if name.ends_with?("_spec")
|
||||
|
||||
|
|
Loading…
Reference in New Issue