markbates/cover_me

Custom CoverMe.config settings are ignored

Opened this issue · 4 comments

I created a file cover_me.rb and put it in /initializers

cover_me ignores these settings and always uses defaults.

I can get it to work if I change c.project.root (I'm changing it to "test")

cimm commented

I am no expert and just discovering CoverMe but I think you have to add your configuration in your test configuration file (like spec_helper.rb for RSpec). Otherwise it would be loaded when you load Rails and I don't see why you would want to load the CoverMe configuration in a production environment for example.

I have it surrounded by an: if Rails.env.test?

This worked for me.
I put the config into the cover_me rake task.

lib/tasks/cover_me.rake ...

task :report do
require 'cover_me'
CoverMe.config.exclude_file_patterns = [
/(#{CoverMe.config.project.root}/app/admin/.+.rb)/i # ignore active admin section
]
CoverMe.complete!
end