ruby-on-rails - Rake 统计数据和 Cucumber

标签 ruby-on-rails rspec cucumber

我在 Rails 项目中使用 Cucumber 和 RSpec。
当我使用“rake stats”任务时,我得到以下信息:

+----------------------+-------+-------+---------+---------+-----+-------+
| 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 添加了它的统计信息(参见模型、 View 、 Controller 和帮助器规范)。
但是我没有 cucumber 的。我如何将它们添加到我的佣金统计数据中?

最佳答案

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

你只需要在任务结束之前在那里添加你的 cucumber 功能目录。
#
# 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')

关于ruby-on-rails - Rake 统计数据和 Cucumber,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1613655/

相关文章:

ruby-on-rails - 如何调试未定义的方法 form_with 错误

ruby-on-rails - 设计 + RSpec : How to authenticate a user?

selenium - 使用 Screenplay 模式而不是 Page 对象的优点/缺点是什么?

java Cucumber,如何在失败时继续

ruby - 从步骤中的嵌套类访问 Cucumbers 实例变量的最佳方法是什么?

mysql - 更新记录时出错

javascript - rails 4 : coffeescript only works when there is a post request or when i reload the page

ruby-on-rails - rails : How to restart sidekiq?

ruby-on-rails - Devise + RSpec - 注册验证错误

javascript - 测试单击输入字段并生成文本选择