Thursday, January 26, 2012

RCov Tips

1. How to turn off rcov for specific sections in a file:
Start and end with :

#:nocov:

in your file.

2. How to exclude files from rcov:

In spec directory, edit rcov.opts

 append our path of files to –exclude option. Eg: –exclude “helpers/*,app/sweepers/*”.

Reference

http://psixty.wordpress.com/2010/06/22/how-to-exclude-files-in-rcova-code-coverage-tool-in-ruby/

Monday, January 16, 2012

How to uninstall all gems in global rvm ?

rvm use @global 
rvm gemset empty global

If you want to remove all gems for a particular gemset, replace global with your-gemset-name

gem "rake" is not installed

Problem uninstalling rake? Run the following command:
rvm use @global && gem uninstall rake

Thursday, January 12, 2012

How to disable acts_as_audited 2.0 rails plugin in Rails 3.1 and RSpec

Create disable.rb under spec/support folder and call disable_auditing method on your modes. For example:
Account.disable_auditing
Cart.disable_auditing

Monday, January 09, 2012

Using Reek gem in Rails 3.1 projects

1. gem install reek
2. reek lib/*.rb > myreport.txt

You can run reports for app/models/*.rb, app/controllers/*.rb and app/helpers/*.rb

rcov for Rails 3.1

1. rake spec:rcov
2. open coverage/index.html
3. add coverage/* to your .gitignore file.
4. $ rake -T rcov
rake spec:clobber_rcov  # Remove rcov products for rcov
rake spec:rcov          # Run all specs in spec directory with RCov (excluding plugin specs)

Rails Best Practices

1. gem install rails_best_practices
2. gem install ripper
3. From the root of the project run: 
rails_best_practices -f html .
to generate the report.