If you’ve ever been working on a Rails application (or any application, for that matter) and found yourself [stupidly] slipping in your testing, I have just the tool for you.
Using rake and rubyosa, you can now automatically post your Code to Test Ratio as your iChat status message—meaning you can now use shame and self-humiliation to keep you motivated.
First, take a look at Mike Clark’s instructions for setting up rubyosa. After you’ve set up rubyosa, add shame.rake to your lib/tasks directory, which contains:
require 'rbosa'
require 'code_statistics'
task :shame do
stats = CodeStatistics.new(*STATS_DIRECTORIES)
code = stats.send :calculate_code
tests = stats.send :calculate_tests
ichat = OSA.app('ichat')
msg = "Code To Test Ratio: 1:#{sprintf("%.1f", tests.to_f/code)}"
ichat.status_message = msg
$stderr.puts %|iChat status set to: #{msg.inspect}|
end
Type rake shame and let the mocking (and motivation) begin!