【发布时间】:2017-11-08 20:34:17
【问题描述】:
SimpleCov 在其他文件成功覆盖 (100%) 时忽略一些文件 (0%)。
我使用框架的测试工具 (Rails 5.1.4) 运行我的测试。
这是我的test_helper.rb 文件。
require 'simplecov'
# save to CircleCI's artifacts directory if we're on CircleCI
if ENV['CIRCLE_ARTIFACTS']
dir = File.join(ENV['CIRCLE_ARTIFACTS'], 'coverage')
SimpleCov.coverage_dir(dir)
end
SimpleCov.start 'rails'
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
这是一个文件已成功覆盖 (100%),SimpleCov 使用Connection.types:
class Connection < ApplicationRecord
validates :type_of, inclusion: { in: proc { Connection.types.map(&:to_s) } }
TYPES = %i[
friend
industry
investor
].freeze
belongs_to :project
belongs_to :user
def self.types
TYPES
end
end
这是一个文件未成功覆盖 (0%),SimpleCov 使用Kpi.types:
class Kpi < ApplicationRecord
REGEX = {
float: "^\d+(\.?\d)?$"
}.freeze
TYPES = [
{ id: :buyers, name: 'Number of buyers', unit: 'users', example: '1000', regex: :float },
{ id: :sellers, name: 'Number of sellers', unit: 'users', example: '1000', regex: :float },
].freeze
belongs_to :project
def self.types
TYPES
end
end
我没有看到这里的模式......你呢?
【问题讨论】:
标签: ruby-on-rails testing simplecov