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!
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
On 9 Jun 2008, at 19:06, Brent Miller wrote:> > > 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> Any help would be appreciated. > > Thanks! > -- > Posted via http://www.ruby-forum.com/. > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I was afraid it would be something like that. Mocha to the rescue... Thanks, Fred! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---