mirror of
https://gitea.invidious.io/iv-org/shard-ameba.git
synced 2024-08-15 00:53:29 +00:00
Utilize Source#spec?
This commit is contained in:
parent
ecad80a96b
commit
f8c22a6e77
3 changed files with 19 additions and 2 deletions
|
@ -23,6 +23,18 @@ module Ameba
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "#spec?" do
|
||||||
|
it "returns true if the source is a spec file" do
|
||||||
|
s = Source.new "", "./source_spec.cr"
|
||||||
|
s.spec?.should be_true
|
||||||
|
end
|
||||||
|
|
||||||
|
it "returns false if the source is not a spec file" do
|
||||||
|
s = Source.new "", "./source.cr"
|
||||||
|
s.spec?.should be_false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe "#matches_path?" do
|
describe "#matches_path?" do
|
||||||
it "returns true if source's path is matched" do
|
it "returns true if source's path is matched" do
|
||||||
s = Source.new "", "source.cr"
|
s = Source.new "", "source.cr"
|
||||||
|
|
|
@ -53,7 +53,7 @@ module Ameba::Rule::Lint
|
||||||
SPEC_ITEM_NAMES = %w(describe context it pending)
|
SPEC_ITEM_NAMES = %w(describe context it pending)
|
||||||
|
|
||||||
def test(source)
|
def test(source)
|
||||||
return unless source.path.ends_with?("_spec.cr")
|
return unless source.spec?
|
||||||
|
|
||||||
AST::NodeVisitor.new self, source
|
AST::NodeVisitor.new self, source
|
||||||
end
|
end
|
||||||
|
|
|
@ -53,7 +53,12 @@ module Ameba
|
||||||
File.expand_path(path)
|
File.expand_path(path)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns true if *filepath* matches the source's path, false if it does not.
|
# Returns `true` if the source is a spec file, `false` otherwise.
|
||||||
|
def spec?
|
||||||
|
path.ends_with?("_spec.cr")
|
||||||
|
end
|
||||||
|
|
||||||
|
# Returns `true` if *filepath* matches the source's path, `false` if it does not.
|
||||||
def matches_path?(filepath)
|
def matches_path?(filepath)
|
||||||
path == filepath || path == File.expand_path(filepath)
|
path == filepath || path == File.expand_path(filepath)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue