[Rspec-devel] Spec stats

aslak hellesoy aslak.hellesoy at gmail.com
Thu Aug 17 20:41:50 EDT 2006


On 8/17/06, Nick Sieger <nicksieger at gmail.com> wrote:
> 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
>

Good stuff Nick - we love patches. I'll get to it as soon as I get my
head above water(just moved).

Aslak

>
> _______________________________________________
> Rspec-devel mailing list
> Rspec-devel at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-devel
>
>


More information about the Rspec-devel mailing list