Expanding tests with own methods

I want to call the method 'url_for' in my functional test. e.g. assert_select "a[href=?]", url_for(:action => :new), :text => 'Neue Seite'

The book I am reading suggests doing this:

class PagesControllerTest < ActionController::TestCase def setup   def self.url_for(options, *parameters_for_method_reference)      options.merge! :only_path => true      @controller.url_for(options, *parameters_for_method_reference)   end end ... end

Why is it necessary to define 'url_for' within the definition of the 'setup' method?

Why is it necessary to define 'url_for' using self?

All of my tests run just fine if I define url_for as a normal instance method:

class PagesControllerTest < ActionController::TestCase def url_for(options, *parameters_for_method_reference)   options.merge! :only_path => true   @controller.url_for(options, *parameters_for_method_reference) end def test_create_link_in_index   get :index   assert_select "a[href=?]", url_for(:action => :new), :text => 'Neue Seite' end ... end

Thanks in advance.