From a661cf10fc408e2c5b63e2db86e2dbea769645f4 Mon Sep 17 00:00:00 2001 From: Sijawusz Pur Rahnama Date: Sat, 9 Mar 2024 22:38:47 +0100 Subject: [PATCH] Ignore files with extensions other than `.cr` --- spec/ameba/rule/lint/spec_filename_spec.cr | 5 +++++ src/ameba/rule/lint/spec_filename.cr | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/spec/ameba/rule/lint/spec_filename_spec.cr b/spec/ameba/rule/lint/spec_filename_spec.cr index 8ef8bfe7..30a2c57d 100644 --- a/spec/ameba/rule/lint/spec_filename_spec.cr +++ b/spec/ameba/rule/lint/spec_filename_spec.cr @@ -9,6 +9,11 @@ module Ameba::Rule::Lint 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" diff --git a/src/ameba/rule/lint/spec_filename.cr b/src/ameba/rule/lint/spec_filename.cr index 87f9274a..32492a6f 100644 --- a/src/ameba/rule/lint/spec_filename.cr +++ b/src/ameba/rule/lint/spec_filename.cr @@ -28,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")