request.path_info doesn't work in tests

Hi all,

I'm having a problem with my tests. In my application.rb, I've got the
following:

before_filter :record_current_page
def record_current_page
    unless request.path_info == session[:current_page]
      session[:previous_page] = session[:current_page]
      session[:current_page] = request.path_info
    end
    @previous_page = session[:previous_page] || '/'
end

This always lets me generate a "Back" link for my users that points to
the previous URL they were looking at, ignoring any
refreshes/reloads/validation error pages etc. that might be happening.

It works fine, until I test:

  def test_should_get_index
    get :index
    assert_response :success
  end

When I run this test, or any other test on my controller, I get:

test_should_get_new(PersonControllerTest):
NoMethodError: undefined method `path_info' for
#<ActionController::TestRequest:0x1fceb0c>

It seems to me that the TestRequest object should have a path_info
method, right? If not, how do I code my app to do what I want, but have
the tests pass? Or, how do I rejigger my tests to get them to pass,
since I know the behavior of the app is correct?

Any help would be appreciated.

Thanks!

When I run this test, or any other test on my controller, I get:

test_should_get_new(PersonControllerTest):
NoMethodError: undefined method `path_info' for
#<ActionController::TestRequest:0x1fceb0c>

It seems to me that the TestRequest object should have a path_info
method, right? If not, how do I code my app to do what I want, but
have
the tests pass? Or, how do I rejigger my tests to get them to pass,
since I know the behavior of the app is correct?

well the functional tests operate a layer below routing, so it doesn't
actually know what is the current path (although I suppose it could
make it up).
This is ruby though, so you could define path_info as a single method
on @request or use mocha to stub/expect a call to path_info.

Fred

I was afraid it would be something like that. Mocha to the rescue...

Thanks, Fred!