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 :)