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

Fernando Perez lists at ruby-forum.com
Wed May 13 16:42:31 EDT 2009


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}}}

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/.

More information about the rspec-users mailing list