[Rspec-devel] Spec stats

Nick Sieger nicksieger at gmail.com
Thu Aug 17 15:44:47 EDT 2006


I'm starting a new Rails project all BDD with RSpec, and one thing I noticed
is that "rake stats" includes tests but not specs.  Adding this to your
rspec.rake fixes that:

namespace :spec do
  desc "Setup specs for stats"
  task :statsetup do
    require 'code_statistics'
    ::STATS_DIRECTORIES << %w(Model\ specs spec/models)
    ::STATS_DIRECTORIES << %w(Controller\ specs spec/controllers)
    ::CodeStatistics::TEST_TYPES << "Model specs"
    ::CodeStatistics::TEST_TYPES << "Controller specs"
    ::STATS_DIRECTORIES.delete_if {|a| a[0] =~ /test/}
  end
end

task :stats => "spec:statsetup"

Patch in tracker [1].

$ rake stats
(in /Users/nicksieger/Work/rapids)
+----------------------+-------+-------+---------+---------+-----+-------+
| Name                 | Lines |   LOC | Classes | Methods | M/C | LOC/M |
+----------------------+-------+-------+---------+---------+-----+-------+
| Helpers              |     5 |     4 |       0 |       0 |   0 |     0 |
| Controllers          |    23 |    19 |       2 |       2 |   1 |     7 |
| Models               |    14 |    12 |       1 |       1 |   1 |    10 |
| Libraries            |     0 |     0 |       0 |       0 |   0 |     0 |
|   Model specs        |    27 |    22 |       0 |       0 |   0 |     0 |
|   Controller specs   |    33 |    26 |       0 |       1 |   0 |    24 |
+----------------------+-------+-------+---------+---------+-----+-------+
| Total                |   102 |    83 |       3 |       4 |   1 |    18 |
+----------------------+-------+-------+---------+---------+-----+-------+
  Code LOC: 35     Test LOC: 48     Code to Test Ratio: 1:1.4

Cheers,
/Nick

[1]:
http://rubyforge.org/tracker/index.php?func=detail&aid=5449&group_id=797&atid=3151
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/rspec-devel/attachments/20060817/bba77077/attachment.html 


More information about the Rspec-devel mailing list