Sunday, 15 February 2015

ruby on rails - simplecov custom filter group to report ignored code -



ruby on rails - simplecov custom filter group to report ignored code -

i trying create study in simplecov study on rogue actions within application. want tab reports , files utilize :nocov: parameter prevent simplecov reporting it. now, know these may not bad, want filter them tab , not impact overall score.

currently have custom tab setup, filter not filter files correctly. can point me in right direction?

sample simple cov ignored method:

# :nocov: def my_debug_method do_something end # :nocov:

here current .simplecov setup:

class ignoredcodefilter < simplecov::filter def matches?(src_file) src_file.grep(/:nocov:/).size > 0 end end simplecov.start add_group "ignored code" |src_file| ignoredcodefilter.new(src_file) end end

current error message:

formatter simplecov::formatter::htmlformatter failed nomethoderror: undefined method `grep' #<simplecov::sourcefile:0x007f920e166fa0> (.simplecov:13:in `block (2 levels) in <top (required)>')

here how solved issue in case others looking it.

just add together .simplecov configuration file:

simplecov.start add_group "ignored code" |src_file| open(src_file.filename).grep(/:nocov:/).any? end end

ruby-on-rails ruby tdd simplecov

No comments:

Post a Comment