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!