Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/unit-testing/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby 如何让工作服忽略gem中作为依赖项的代码?_Ruby_Unit Testing_Testing_Code Coverage_Coveralls - Fatal编程技术网

Ruby 如何让工作服忽略gem中作为依赖项的代码?

Ruby 如何让工作服忽略gem中作为依赖项的代码?,ruby,unit-testing,testing,code-coverage,coveralls,Ruby,Unit Testing,Testing,Code Coverage,Coveralls,我制作了一个小gem(),它目前有100%的代码覆盖率(根据SimpleCov) 然而,根据工作服,它只有41%的覆盖率() 造成这种差异的原因似乎是工作服将我的gem依赖项中的代码作为我的代码的一部分,并抱怨没有涵盖这些内容 我还没有在我研究过的任何其他gems中看到过这种情况,在那些gems的代码库中也没有任何特殊的工作服配置 我称之为工作服的方式是在我的Rakefile中有: require 'coveralls/rake/task' Coveralls::RakeTask.new tas

我制作了一个小gem(),它目前有100%的代码覆盖率(根据SimpleCov)

然而,根据工作服,它只有41%的覆盖率()

造成这种差异的原因似乎是工作服将我的gem依赖项中的代码作为我的代码的一部分,并抱怨没有涵盖这些内容

我还没有在我研究过的任何其他gems中看到过这种情况,在那些gems的代码库中也没有任何特殊的工作服配置

我称之为工作服的方式是在我的Rakefile中有:

require 'coveralls/rake/task'
Coveralls::RakeTask.new
task :test_with_coveralls => ["test", "coveralls:push"]
让Travis evecute“用工作服测试”:

哪一种是正确的添加方式


你知道为什么会发生这种情况吗?

需要两个步骤

一方面,根据工作服文档,将SimpleCov格式化程序设置为工作服:

require "simplecov"
require "coveralls"
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
    SimpleCov::Formatter::HTMLFormatter,
    Coveralls::SimpleCov::Formatter
]

但这并不能解决问题,这是未记录的部分:

调用SimpleCov.start时,请确保过滤掉“/gemfiles/vendor”目录

SimpleCov.start do
    add_filter "/gemfiles/vendor"
end

太好了,就是这样!更新了您的回复,以便更多地应用于我的问题,以备将来提问。非常感谢。
SimpleCov.formatter = Coveralls::SimpleCov::Formatter
SimpleCov.start do
    add_filter "/gemfiles/vendor"
end