[Rails] Re: get & post methods in controller's test
On Tuesday, September 4, 2012 12:56:05 AM UTC+1, Ruby-Forum.com User wrote:
But this will load the login action and not the login_create! After a
lot of searching and trying, I've wrote:
post :login_create
... And it works as expected. However, after that I've tried:
get :login_create
... And this works also! O_o
Controller specs bypass your routes entirely (as part as action invocation goes, they're still used if you try to generate a url inside the action).
If you do
get :action_name
then it will invoke that action with a get request, whether there's a route for it or not.
post '/login'
fails because there are is no '/login' action (but there is a 'login' one).
If you write an spec request spec (or a rails integration test) then get/post are the rack test methods instead which do take actual paths.
Fred
So, what this kind of methods really do and how are intended to be used?--
--
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@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/rIYIwQJsRJgJ.
For more options, visit https://groups.google.com/groups/opt_out.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home