Sunday, January 13, 2013

[Rails] Rspec: How to test create action in controller

Hi Everyone,

(using rails 3.2.11)

I've searched high and low for the answer to this, so now I have to submit a question...

      # describe "POST on Users#create" do
      #   before { post users_path }
      #   specify { response.should redirect_to(root_path) }
      # end

Every time I run rspec with that test, I get this:

     Failure/Error: before { post users_path }
     AbstractController::DoubleRenderError:
       Render and/or redirect were called multiple times in this action. Please note that you may only call render OR redirect, and at most once per action. Also note that neither redirect nor render terminate execution of the action, so if you want to exit an action after redirecting, you need to do something like "redirect_to(...) and return".

What am I doing wrong? Thank you.

--
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/-/TfxFT6X_GLgJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate