Simple cov gem missing untested files in Rails

一个人想着一个人 提交于 2019-11-27 13:07:29

Try to edit your config/environments/test.rb and set this line:

config.eager_load = false

to true in this way the whole app is loaded and simplecov reads it.

Eager load the whole Rails app when running tests suite with code coverage. Add Rails.application.eager_load! to spec_helper.rb.

Simplecov slows down tests that's why I use shell environment variable to turn it on. Usually my spec_helper.rb/rails_helper.rb looks something like this:

if ENV['COVERAGE']
  require 'simplecov'
  # some SimpleCov setup, e.g. formatters
  SimpleCov.start 'rails'
end

ENV['RAILS_ENV'] ||= 'test'
require 'spec_helper'
require File.expand_path('../../config/environment', __FILE__)
require 'rspec/rails'

Rails.application.eager_load! if ENV['COVERAGE']
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!