Technical.Web

Technical.Projects

Jeweler is the GitHub recommended way to generating and maintaining RubyGem projects.

Homesick is a command line tool for storing your dotfiles in git, and being able to use them locally.

is a Ruby library to help test your library code against multiple versions of a particular gem (ie rails).

capistrano-gitflow is a Capistrano library that provide a git work flow for deploying to staging and production servers based on git tagging.

Technical.Stats

Use ActionController::TestCase

I’ve been coming across a lot of Rails functional tests that look like this:

require File.dirname(__FILE__) + '/../test_helper'
require 'owners_controller'

# Raise errors beyond the default web-based presentation
class OwnersController; def rescue_action(e) raise e end; end

class OwnersControllerTest < Test::Unit::TestCase
  def setup
    @controller = OwnersController.new
    @request = ActionController::TestRequest.new
    @response = ActionController::TestResponse.new
    # ...
  end
  # ...
end

Some of it is repetitive (you always have to always create the controller, request, and response, and reopening the class). Some is unnecessary (requiring the file).

I’m not sure when it was added, but Rails provides ActionController::TestCase which does this boilerplate stuff up for you. Here’s what we can change to it to:

require File.dirname(__FILE__) + '/../test_helper'

class OwnersControllerTest < ActionController::TestCase
  def setup
    # ...
  end
  # ...
end

Much cleaner, right?

blog comments powered byDisqus