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/
Software Development
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
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
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
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)
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.
2. gem install ripper
3. From the root of the project run:
rails_best_practices -f html .
to generate the report.
Sunday, December 25, 2011
You need to specify gem names as Strings. Use 'gem "test"' instead.
This can happen due to syntax error in your Gemfile. Fix the sytax error by manually checking this file. If that does not work delete the lines that you added to result in this problem and copy / paste from a working copy of a Gemfile.
Wednesday, December 07, 2011
syntax error, unexpected keyword_end
This happens because you have : <%= end %> instead of <% end %>
Thursday, December 01, 2011
`test': unknown command 't' (ArgumentError)
To write tests using Test::Unit new syntax :
test "truth" do
assert true
end
1. gem install test-unit
2. Code:
require 'rubygems'
gem 'test-unit'
require 'test/unit'
class ExampleTest < Test::Unit::TestCase
def test_truth
assert true
end
test "truth" do
assert true
end
end
3. Run: ruby example_test This will work on ruby-1.9.3-p0.
Reference: Test::Unit and MiniTest with different Ruby versions
test "truth" do
assert true
end
1. gem install test-unit
2. Code:
require 'rubygems'
gem 'test-unit'
require 'test/unit'
class ExampleTest < Test::Unit::TestCase
def test_truth
assert true
end
test "truth" do
assert true
end
end
3. Run: ruby example_test This will work on ruby-1.9.3-p0.
Reference: Test::Unit and MiniTest with different Ruby versions
Subscribe to:
Posts (Atom)
