ruby轨道 – 耙状态和黄瓜
发布时间:2020-12-16 21:37:48 所属栏目:百科 来源:网络整理
导读:我在Rails项目中使用了RSpec的黄瓜. 当我使用“耙子统计”任务时,我得到以下内容: +----------------------+-------+-------+---------+---------+-----+-------+| Name | Lines | LOC | Classes | Methods | M/C | LOC/M |+----------------------+-------
我在Rails项目中使用了RSpec的黄瓜.
当我使用“耙子统计”任务时,我得到以下内容: +----------------------+-------+-------+---------+---------+-----+-------+ | 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添加了它的统计信息(参见model,view,controller和helper specs). 解决方法
RSpec创建一个lib / tasks / rspec.rake文件.并重新定义其中的stats目录.
在该文件的第108行,您将看到: # 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 您只需要在任务结束之前添加黄瓜功能目录. # # 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') (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |