簡體   English   中英

Rails 4和SimpleCov:SimpleCov的覆蓋率報告中包含lib / tasks / cucumber.rake嗎?

[英]Rails 4 & SimpleCov: lib/tasks/cucumber.rake included in coverage report for SimpleCov?

我在spec/spec_helper.rbfeatures/support/env.rb的頂部具有以下代碼(SimpleCov合並RSpec和Cucumber覆蓋結果):

require 'simplecov'

我在項目根目錄的.simplecov文件中也包含以下代碼:

SimpleCov.start 'rails'

但是,由於某種原因, lib/tasks/cucumber.rake包含在本文中...

在此處輸入圖片說明

有任何想法嗎?

在spec文件夾中有文件rcov.opts,在此文件中,我們有–exclude選項。

我們可以將文件路徑附加到此。 例如我想排除helpers,sweepers文件夾,所以只需添加/修改

–exclude “helpers/*,app/sweepers/*”. 

在RSpec-1中,rake任務將從rcov.opts文件中讀取rcov選項。

RSpec-2忽略了這一點。 現在,可以直接在Rake任務上設置RCov選項:

RSpec::Core::RakeTask.new(:rcov) do |t| 
    t.rcov_opts = %q[--exclude "spec/,gems/,features/*"] 
end

我以前沒有在RSpec中使用SimpleCov,但是通常我會通過在調用start之后向SimpleCov添加一個過濾器來處理這種情況。 在您的情況下,這可能意味着更改.simplecov的開始調用

SimpleCov.start "rails"

SimpleCov.start("rails") do
  add_filter "lib/tasks/cucumber.rake"
end

希望這可以幫助!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM