Saturday, December 6, 2008

Some months with RSpec


For several months, I have been writing test-case ahead of any implementation. But the joy multiplied when we started thinking BDD. To me using RSpec as BDD tool is not much different than Rails default test mechanism other than the representation, unless you try the Story.

Test first development has a big advantage that you consider all possible scenarios before writing code. Yet sometimes you may miss some lines covered. An wonderful gem you require to check test coverage in Ruby is rcov. And no wonder RSpec has built-in support for rcov :) To test you code coverage, run
rake spec:rcov

This will create a folder named "coverage" on your rails root. Open the index.html from that folder in your browser to see how much your code is covered by test case. The screenshot is a polling script I just started.

1 comment:

hasan said...

nice post, btw did you find any way out to run a specific spec like RTest ?

btw, your blackish background is killing my eyes, it looks like asif bhai's t-shirt.