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

Fix for defining groups based on a custom filter class. #85

Merged
merged 1 commit into from
Oct 12, 2011
Merged

Fix for defining groups based on a custom filter class. #85

merged 1 commit into from
Oct 12, 2011

Conversation

robinroestenburg
Copy link
Contributor

Problem

The following LineFilter example is mentioned in the documentation of SimpleCov. I tried this out and configured SimpleCov as follows:

class LineFilter < SimpleCov::Filter
  def passes?(source_file)
    source_file.lines.count < filter_argument
  end
end

SimpleCov.start 'rails' do
  add_group "Short files", LineFilter.new(5)
end

Instead of showing me the files that have less then 5 lines, the tab 'Short files' contains all files that are greater than or equal to 5 lines.

Fixes

The initial fix was removing the negation from the grouped method in lib/simplecov.rb. This led to some underlying problems in the SimpleCov::Filter classes.

I renamed the passes? method to matches? and also removed the negation that was present. The comments in the StringFilter and LineFilter class now match the code :) The changes made in test/test_filters.rb are trivial changes because of the removed negation.

I also had to change the filtered method in lib/simplecov.rb. This method now removes (or reject) all files that match the filter. This is functionally still the same.

I added a specific feature for testing the custom filter class (no existing one was present).

colszowka added a commit that referenced this pull request Oct 12, 2011
Fix for defining groups based on a custom filter class.
@colszowka colszowka merged commit f163edb into simplecov-ruby:master Oct 12, 2011
@colszowka
Copy link
Collaborator

Thanks, I've merged it in and updated the README accordingly. Also added a fallback passes? method to the filter baseclass including a deprecation warning so everyone's custom filter classes don't fail after the update. Release 0.5.4 in a couple minutes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants