diff --git a/lib/simplecov/filter.rb b/lib/simplecov/filter.rb index 3acc4f29..d53770dc 100644 --- a/lib/simplecov/filter.rb +++ b/lib/simplecov/filter.rb @@ -49,7 +49,7 @@ class StringFilter < SimpleCov::Filter # Returns true when the given source file's filename matches the # string configured when initializing this Filter with StringFilter.new('somestring) def matches?(source_file) - (source_file.project_filename =~ /#{filter_argument}/) + source_file.project_filename.include?(filter_argument) end end diff --git a/spec/filters_spec.rb b/spec/filters_spec.rb index 6cdaa84b..4a3abf57 100644 --- a/spec/filters_spec.rb +++ b/spec/filters_spec.rb @@ -26,15 +26,15 @@ expect(SimpleCov::StringFilter.new("sample.rb")).to be_matches subject end + it "doesn't match a new SimpleCov::StringFilter '.pl'" do + expect(SimpleCov::StringFilter.new(".pl")).not_to be_matches subject + end + it "doesn't match a parent directory with a new SimpleCov::StringFilter" do parent_dir_name = File.basename(File.expand_path("..", File.dirname(__FILE__))) expect(SimpleCov::StringFilter.new(parent_dir_name)).not_to be_matches subject end - it "matches a new SimpleCov::StringFilter '/fixtures/'" do - expect(SimpleCov::StringFilter.new("sample.rb")).to be_matches subject - end - it "matches a new SimpleCov::RegexFilter /\/fixtures\//" do expect(SimpleCov::RegexFilter.new(/\/fixtures\//)).to be_matches subject end