From d0e0c9b825d39fb6156778cc991e932c23df09e3 Mon Sep 17 00:00:00 2001 From: Yuji Nakayama Date: Thu, 17 Aug 2017 14:53:25 +0900 Subject: [PATCH 1/2] Remove duplicated spec https://github.com/colszowka/simplecov/blob/v0.15.0/spec/filters_spec.rb#L26 --- spec/filters_spec.rb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/spec/filters_spec.rb b/spec/filters_spec.rb index 6cdaa84b..e58b5fbc 100644 --- a/spec/filters_spec.rb +++ b/spec/filters_spec.rb @@ -31,10 +31,6 @@ 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 From 52f982e94e7c6e5e75fc9c996be4375ecc70793e Mon Sep 17 00:00:00 2001 From: Yuji Nakayama Date: Thu, 17 Aug 2017 14:54:08 +0900 Subject: [PATCH 2/2] Stop handling string filters as regexps Previously, filter strings passed to `add_filter` have been handled as regexps. It means, for example, `add_filter '.pl'` matches against 'sample.rb' because `.` is handled as _any character_ in regexp. As now we have [regexp filter](https://github.com/colszowka/simplecov/pull/589), there's no reason to handle filter strings as regexps. However we need to think about semver with this change. If this behavior was intentional, we cannot introduce this change until next major version bump. Or we can do if this was a _bug_. --- lib/simplecov/filter.rb | 2 +- spec/filters_spec.rb | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) 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 e58b5fbc..4a3abf57 100644 --- a/spec/filters_spec.rb +++ b/spec/filters_spec.rb @@ -26,6 +26,10 @@ 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