Rake 统计数据和 Cucumber [英] Rake stats and Cucumber
问题描述
我在 Rails 项目中使用 Cucumber 和 RSpec.当我使用rake stats"任务时,我得到以下信息:
I'm using Cucumber with RSpec in a Rails project. When I use the "rake stats" task, I get the following :
+----------------------+-------+-------+---------+---------+-----+-------+
| Name | Lines | LOC | Classes | Methods | M/C | LOC/M |
+----------------------+-------+-------+---------+---------+-----+-------+
| Controllers | 948 | 761 | 21 | 87 | 4 | 6 |
| Helpers | 212 | 175 | 0 | 24 | 0 | 5 |
| Models | 912 | 741 | 28 | 72 | 2 | 8 |
| Libraries | 305 | 211 | 1 | 25 | 25 | 6 |
| Model specs | 978 | 797 | 0 | 1 | 0 | 795 |
| View specs | 270 | 227 | 0 | 0 | 0 | 0 |
| Controller specs | 1144 | 944 | 0 | 4 | 0 | 234 |
| Helper specs | 154 | 116 | 0 | 0 | 0 | 0 |
+----------------------+-------+-------+---------+---------+-----+-------+
| Total | 4923 | 3972 | 50 | 213 | 4 | 16 |
+----------------------+-------+-------+---------+---------+-----+-------+
Code LOC: 1888 Test LOC: 2084 Code to Test Ratio: 1:1.1
因此 rspec 添加了其统计信息(请参阅模型、视图、控制器和帮助程序规范).
但我没有黄瓜的.我如何将它们添加到我的佣金统计数据中?
So rspec adds its stats (see the model, view, controller and helper specs).
But I don't have the cucumber ones. How could I add them to my rake stats ?
推荐答案
RSpec 创建一个 lib/tasks/rspec.rake
文件.并重新定义其中的stats目录.
RSpec creates a lib/tasks/rspec.rake
file. And redefines the stats directories inside of it.
在该文件的第 108 行,您会看到:
At the line 108 of that file, you'll see :
# Setup specs for stats
task :statsetup do
require 'code_statistics'
::STATS_DIRECTORIES << %w(Model specs spec/models) if File.exist?('spec/models')
::STATS_DIRECTORIES << %w(View specs spec/views) if File.exist?('spec/views')
....
end
您只需要在任务结束前将您的黄瓜功能目录添加到那里即可.
You just need to add your cucumber features directory there, right before the end of the task.
#
# Adding Cucumber features to the stats
#
::STATS_DIRECTORIES << %w(Cucumber features features) if File.exist?('features')
::CodeStatistics::TEST_TYPES << "Cucumber features" if File.exist?('features')
这篇关于Rake 统计数据和 Cucumber的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!