Produce Documentation from your RSpec test cases

anand posted this on 06 Jan 2011

Well, if you are not in the habit of writing test cases, this post is not for you. So if you are in the other jungle, writing test cases for your app, this post hopefully will show you something cool about rspec.

Ruby community generally believes a lot in test cases. Why? well, there are many reasons. One primary thing is that test cases document your code. what does that mean ... ? let me show you.

If you have rspec test cases written in your ruby app ( a rails project for example) , in PROJECT_ROOT/spec/, here is a way in which you can get the documentation of your app.

Give this command to get a neat output of rspec test cases

If you want the same in a text file, probably to print it out at later stage, you can give like

You can open that txt file to see your App's documentation. There are a lot of nice command line options that rspec provides you. Tweak them to your interests.