Excluded relative path path

This commit is contained in:
Vitalii Elenhaupt 2017-12-18 13:06:19 +02:00
parent 63eda4e820
commit eca0d28692
No known key found for this signature in database
GPG key ID: 7558EF3A4056C706
5 changed files with 65 additions and 3 deletions

View file

@ -28,5 +28,35 @@ module Ameba::Rule
NoProperties.new.enabled.should be_true
end
end
describe "#excluded?" do
it "returns false if a rule does no have a list of excluded source" do
DummyRule.new.excluded?(Source.new "", "source.cr").should_not be_true
end
it "returns false if source is not excluded from this rule" do
rule = DummyRule.new
rule.excluded = %w(some_source.cr)
rule.excluded?(Source.new "", "another_source.cr").should_not be_true
end
it "returns true if source is excluded from this rule" do
rule = DummyRule.new
rule.excluded = %w(source.cr)
rule.excluded?(Source.new "", "source.cr").should be_true
end
pending "returns true if source matches the wildcard" do
rule = DummyRule.new
rule.excluded = %w(**/*.cr)
rule.excluded?(Source.new "", "source.cr").should be_true
end
it "returns false if source does not match the wildcard" do
rule = DummyRule.new
rule.excluded = %w(*_spec.cr)
rule.excluded?(Source.new "", "source.cr").should be_false
end
end
end
end

View file

@ -23,5 +23,17 @@ module Ameba
error.message.should eq "Error!"
end
end
describe "#fullpath" do
it "returns a relative path of the source" do
s = Source.new "", "./source_spec.cr"
s.fullpath.should contain "source_spec.cr"
end
it "returns fullpath if path is blank" do
s = Source.new "", ""
s.fullpath.should_not be_nil
end
end
end
end