We are a software consultancy based in Berlin, Germany. We deliver
high quality web apps in short timespans.

Upstream Agile GmbH Logo

Testing helpers in Ruby on Rails 1.2

February 21, 2007 by alex

We are just migrating one of our projects from Rails 1.1.6 to 1.2.2. One of the problems we encountered was, that Recipe 44: Write tests for your helpers from Rails Recipes (by the way Advanced Rails Recipes will come out in Augut 2007) is not working anymore. The line

@controller.send :initialize_current_url

resulted in a

can't clone NilClass

After some messing around, we found out that the following setup method solves this:

def setup
  @controller = MyController.new
  request = ActionController::TestRequest.new
  <strong>@controller.instance_eval { @url = ActionController::UrlRewriter.new(request, {}) }</strong>
  @response = ActionController::TestResponse.new
end

Happy testing :)

Hello Explorer!

You’ve found our very old Website Archive (2007-2012). It’s a bit out of date, but we love looking back at how it all started - and how far we’ve come since then! We’re now fully focused on building our coworking management product, Cobot.

Take a look →