Topic: Testing small methods?

I have several small "utility" methods that I need to test.  These methods are in application.rb and are used by various controllers.  Where do I put the test cases for these as they really aren't dependent on any controller, view or model?

A related question:  How do I "get to" the method from the unit test code.  I've tried to require 'application.rb' but that apparently doesn't do it.

Re: Testing small methods?

Have you looked at http://nubyonrails.com/articles/2006/04 … ur-helpers?

My RoR journey  -- thoughts on learning RoR and lessons learned in applying TDD and agile practices.

Re: Testing small methods?

The command ./script/plugin doesn't appear to work.  This should be done in the application directory I assume.

Re: Testing small methods?

If you're on windows, I find it works better to prepend 'ruby' to script calls.

Re: Testing small methods?

Yep, tried that also.  Didn't work either.

Re: Testing small methods?

Why not make a dummy controller for purposes of testing the helper methods?

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

class TestController < ApplicationController
end

# Re-raise errors caught by the controller.
class TestController; def rescue_action(e) raise e end; end

class TestControllerTest < Test::Unit::TestCase
  def setup
    @controller = TestController.new
    @request    = ActionController::TestRequest.new
    @response   = ActionController::TestResponse.new
  end

  def test_nothing
  end
end


Something like that.