Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop handling string filters as regexps #616

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/simplecov/filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why id you remove this spec, shouldn't that still work?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes, missed that! Seems like it was meant to be "/fixtures/" indeed! Unless I missed that one as well :)


it "matches a new SimpleCov::RegexFilter /\/fixtures\//" do
expect(SimpleCov::RegexFilter.new(/\/fixtures\//)).to be_matches subject
end
Expand Down