Skip to content

Commit

Permalink
Merge pull request #616 from yujinakayama/stop-handling-filter-string…
Browse files Browse the repository at this point in the history
…-as-regexp

Stop handling string filters as regexps
  • Loading branch information
PragTob authored Oct 21, 2017
2 parents ebc0bac + 52f982e commit e1fc172
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/simplecov/filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,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

Expand Down
8 changes: 4 additions & 4 deletions spec/filters_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,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
Expand Down

0 comments on commit e1fc172

Please sign in to comment.