[rspec-users] Unable to post to an update action in a controller spec

BJ Clark bj at aboutus.org
Wed May 13 16:48:31 EDT 2009


On May 13, 2009, at 1:42 PM, Fernando Perez wrote:

> Hi,
>
> I use restful routes. In one of my views I have a form that looks  
> like:
>
> <%- form_tag '/items/update', :method => :put do -%>
>  ...
>  <%= submit_tag "Recalculate" %>
> <%- end -%>
>
> I know I cheated a bit, as I should be submitting to /items/1 instead.
> Anyway, now how can I trigger the update action in my controller test?
>
> I tried stuff like:
> post :update, {:method => 'put', :item => {'1' => {:quantity => 5}}}

put :update, :item => 1 etc.

There are 4 methods for the 4 HTTP types. get, post, put, delete.


-----
BJ Clark


>
> But the route recognition isn't pleased, I guess it's missing  
> an :id. Is
> it possible to test the way I coded it?
>
>
> PS: please no comment about writing code before testing, I know it's a
> bad habit, and I am doing my best to change it.
> -- 
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users



More information about the rspec-users mailing list