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
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 ?
Why monkey patch the gem like that? You'll have to add your fix for it every time you update rspec-rails. Just extend the task locally with something like this:
And FYI Lichtamberg and Damien MATHIEU this works just fine with rspec 2. However these rails specific rake tasks are ofc not part of the rspec gem itself, but a part of the rspec-rails gem.
P.S. This all was tested with ruby 1.9.2p180 (2011-02-18 revision 30909) [i686-linux], rails 3.0.8, rspec 2.6.0 and rspec-rails 2.6.1 and it might or might not work older versions of them.
Here's a version that works with Turnip and RSpec 2
https://gist.github.com/2360892
Although this is an extremely old question, it is still first when googling "rails rake stats cucumber" and the answers are misleading or outdated.
For future googlers, all you need to do is run
This will create the necessary files, and specifically the
lib/tasks/cucumber.rake
file, which adds "Cucumber Features" to therake stats
output.RSpec creates a
lib/tasks/rspec.rake
file. And redefines the stats directories inside of it.At the line 108 of that file, you'll see :
You just need to add your cucumber features directory there, right before the end of the task.
Code: