Using Rcov to measure the test coverage of Rails plugins

To view the coverage of your plugins using Rcov, first install the rcov gem with sudo gem install rcov, then copy and paste the following onto the end of the Rakefile inside your plugin directory: require ‘rcov/rcovtask’ desc ‘Measures test coverage using rcov’ namespace :rcov do desc ‘Output unit test coverage of plugin.’ Rcov::RcovTask.new(:unit) do […]

Autotest Growl Fail/Pass Smilies

John Nunemaker posted a handy tip on “setting up autotest to work with Growl”:http://railstips.org/2007/7/23/autotest-growl-pass-fail-notifications I use this all the time now however I didn’t like the ugly smilies (call me shallow if you like). I used “Wolfgang Bartelme’s”:http://bartelme.at “Smily Devkit”:http://bartelme.at/journal/archive/smiley_devkit to make a couple of PNG’s slightly more pleasing to the eye. p=. !http://thelucid.com/files/fail.png(Autotest Fail […]

Rails Edge: Getting your view extensions ready for edge

Following my previous post, below is a modified version of “John Nunemaker’s ‘Renaming RHTML to ERB’”:http://railstips.org/2007/3/4/renaming-rhtml-to-erb to take into account the format in the extension, and handle “the RJS issues I was having”:http://www.thelucid.com/articles/2007/05/16/rails-edge-view-file-extention-functionality-has-changed. namespace ‘views’ do desc ‘Renames all .rhtml views to .html.erb, .rjs to .js.rjs, .rxml to .xml.builder and .haml to .html.haml’ task ‘rename’ […]

Disabling plugin code in generators/migrations

I have found on numerous occasions that I need to disable certain plugin functionality if running a generator / rake db:migrate etc. An easy way to disable certain functionality follows: def method_that_shouldnt_be_run_in_migrations_or_generators # Return if we are using a generator or migrations script = File.basename($0) return if (script == ‘generate’) || (script == ‘rake’ && […]

Handy Subversion Rake task

Just read a post from “David”:http://david.planetargon.us at “Planet Argon”:http://planetargon.us/ showing a way to “add un-added files”:http://david.planetargon.us/articles/2006/07/28/i-love-shell-scripting in your Subversion working copy. I have made this into a simple rake task: namespace :svn do desc “Adds all files with an svn status flag of ‘?'” task(:add_new) { `svn status | awk ‘/\\?/ {print $2}’ | xargs […]