Search code examples
ruby-on-rails-4rake-tasksimplecov

Why does SimpleCov trigger when rake db:schema:load is executed?


If I have a .simplecov file, then when I run RAILS_ENV=test rake db:schema:load, I get a coverage report.

If I move the code from .simplecov to my test_helper.rb file (I use MiniTest), this does not happen.

I expect that this should never happen - loading the schema in the test environment is not a coverage test.

The reason this is annoying is that it causes my schema to load on CircleCI, generates a coverage below my threshold, and then fails the build.


Solution

  • I probably posted this question before a recent change to the simplecov readme... the change I needed to avoid this problem was to update my Gemfile to turn off auto-requiring of the simplecov gem:

    gem 'simplecov', require: false

    I then explicitly added Simplecov to my test/test_helper.rb as recommended in the README and that fixed this problem.