[rspec-users] Problems testing destroy method in rspec2

Julian Leviston julian at leviston.net
Thu Mar 25 00:22:46 EDT 2010


Only thing that springs to mind is that perhaps you haven't specified the :method => :delete option on the link?

Julian.

On 25/03/2010, at 2:39 PM, Mauricio Aniche wrote:

> Hi,
> 
> I am trying to test the destroy method in my rails 3 controller, but I always get an "no route matches {}" error. But the route do exist, as I can see by running rake routes.
> 
> I have something like this:
> delete :destroy, :id => "1"
> 
> The stack trace:
>     Failure/Error: delete :destroy, :id => "1"
>     No route matches {}
>     # /Users/<my user>/.rvm/gems/ree-1.8.7-2010.01%rails3/gems/actionpack-3.0.0.beta/lib/action_dispatch/routing/route_set.rb:415:in `generate'
>     # /Users/<my user>/.rvm/gems/ree-1.8.7-2010.01%rails3/gems/actionpack-3.0.0.beta/lib/action_controller/url_rewriter.rb:43:in `rewrite'
>     # /Users/<my user>/.rvm/gems/ree-1.8.7-2010.01%rails3/gems/actionpack-3.0.0.beta/lib/action_controller/url_rewriter.rb:16:in `rewrite'
>     # /Users/<my user>/.rvm/gems/ree-1.8.7-2010.01%rails3/gems/actionpack-3.0.0.beta/lib/action_controller/metal/url_for.rb:145:in `url_for'
>     # /Users/<my user>/.rvm/gems/ree-1.8.7-2010.01%rails3/gems/actionpack-3.0.0.beta/lib/action_controller/metal/redirecting.rb:86:in `_compute_redirect_to_location'
>     # /Users/<my user>/.rvm/gems/ree-1.8.7-2010.01%rails3/gems/actionpack-3.0.0.beta/lib/action_controller/metal/redirecting.rb:58:in `redirect_to'
>     # /Users/<my user>/.rvm/gems/ree-1.8.7-2010.01%rails3/gems/actionpack-3.0.0.beta/lib/action_controller/metal/flash.rb:25:in `redirect_to'
>     # /Users/<my user>/.rvm/gems/ree-1.8.7-2010.01%rails3/gems/actionpack-3.0.0.beta/lib/action_controller/metal/instrumentation.rb:59:in `redirect_to'
>     # /Users/<my user>/.rvm/gems/ree-1.8.7-2010.01%rails3/gems/activesupport-3.0.0.beta/lib/active_support/notifications/instrumenter.rb:18:in `instrument'
>     # /Users/<my user>/.rvm/gems/ree-1.8.7-2010.01%rails3/gems/activesupport-3.0.0.beta/lib/active_support/notifications.rb:49:in `__send__'
>     # /Users/<my user>/.rvm/gems/ree-1.8.7-2010.01%rails3/gems/activesupport-3.0.0.beta/lib/active_support/notifications.rb:49:in `instrument'
>     # /Users/<my user>/.rvm/gems/ree-1.8.7-2010.01%rails3/gems/actionpack-3.0.0.beta/lib/action_controller/metal/instrumentation.rb:58:in `redirect_to'
>     # /Users/<my user>/dev/easyclinica/app/controllers/convenios_controller.rb:55
>     # /Users/<my user>/.rvm/gems/ree-1.8.7-2010.01%rails3/gems/actionpack-3.0.0.beta/lib/action_controller/metal/mime_responds.rb:189:in `call'
>     # /Users/<my user>/.rvm/gems/ree-1.8.7-2010.01%rails3/gems/actionpack-3.0.0.beta/lib/action_controller/metal/mime_responds.rb:189:in `respond_to'
>     # /Users/<my user>/dev/easyclinica/app/controllers/convenios_controller.rb:53:in `destroy'
>     # /Users/<my user>/.rvm/gems/ree-1.8.7-2010.01%rails3/gems/actionpack-3.0.0.beta/lib/action_controller/base.rb:44:in `send_action'
>     # /Users/<my user>/.rvm/gems/ree-1.8.7-2010.01%rails3/gems/actionpack-3.0.0.beta/lib/action_controller/base.rb:44:in `send_action'
>     # /Users/<my user>/.rvm/gems/ree-1.8.7-2010.01%rails3/gems/actionpack-3.0.0.beta/lib/abstract_controller/base.rb:145:in `process_action'
>     # /Users/<my user>/.rvm/gems/ree-1.8.7-2010.01%rails3/gems/actionpack-3.0.0.beta/lib/abstract_controller/callbacks.rb:18:in `process_action'
>     # /Users/<my user>/.rvm/gems/ree-1.8.7-2010.01%rails3/gems/activesupport-3.0.0.beta/lib/active_support/callbacks.rb:438:in `_run__2086632925__process_action__988268021__callbacks'
>     # /Users/<my user>/.rvm/gems/ree-1.8.7-2010.01%rails3/gems/activesupport-3.0.0.beta/lib/active_support/callbacks.rb:403:in `send'
>     # /Users/<my user>/.rvm/gems/ree-1.8.7-2010.01%rails3/gems/activesupport-3.0.0.beta/lib/active_support/callbacks.rb:403:in `_run_process_action_callbacks'
>     # /Users/<my user>/.rvm/gems/ree-1.8.7-2010.01%rails3/gems/activesupport-3.0.0.beta/lib/active_support/callbacks.rb:88:in `send'
>     # /Users/<my user>/.rvm/gems/ree-1.8.7-2010.01%rails3/gems/activesupport-3.0.0.beta/lib/active_support/callbacks.rb:88:in `run_callbacks'
>     # /Users/<my user>/.rvm/gems/ree-1.8.7-2010.01%rails3/gems/actionpack-3.0.0.beta/lib/abstract_controller/callbacks.rb:17:in `process_action'
>     # /Users/<my user>/.rvm/gems/ree-1.8.7-2010.01%rails3/gems/actionpack-3.0.0.beta/lib/action_controller/metal/rendering.rb:12:in `process_action'
>     # /Users/<my user>/.rvm/gems/ree-1.8.7-2010.01%rails3/gems/actionpack-3.0.0.beta/lib/action_controller/metal/compatibility.rb:66:in `process_action'
>     # /Users/<my user>/.rvm/gems/ree-1.8.7-2010.01%rails3/gems/actionpack-3.0.0.beta/lib/action_controller/metal/instrumentation.rb:29:in `process_action'
>     # /Users/<my user>/.rvm/gems/ree-1.8.7-2010.01%rails3/gems/activesupport-3.0.0.beta/lib/active_support/notifications/instrumenter.rb:18:in `instrument'
>     # /Users/<my user>/.rvm/gems/ree-1.8.7-2010.01%rails3/gems/activesupport-3.0.0.beta/lib/active_support/notifications.rb:49:in `__send__'
>     # /Users/<my user>/.rvm/gems/ree-1.8.7-2010.01%rails3/gems/activesupport-3.0.0.beta/lib/active_support/notifications.rb:49:in `instrument'
>     # /Users/<my user>/.rvm/gems/ree-1.8.7-2010.01%rails3/gems/actionpack-3.0.0.beta/lib/action_controller/metal/instrumentation.rb:28:in `process_action'
>     # /Users/<my user>/.rvm/gems/ree-1.8.7-2010.01%rails3/gems/actionpack-3.0.0.beta/lib/action_controller/metal/rescue.rb:8:in `process_action'
>     # /Users/<my user>/.rvm/gems/ree-1.8.7-2010.01%rails3/gems/actionpack-3.0.0.beta/lib/abstract_controller/base.rb:115:in `process'
>     # /Users/<my user>/.rvm/gems/ree-1.8.7-2010.01%rails3/gems/actionpack-3.0.0.beta/lib/action_controller/metal.rb:64:in `dispatch'
>     # /Users/<my user>/.rvm/gems/ree-1.8.7-2010.01%rails3/gems/actionpack-3.0.0.beta/lib/action_controller/metal/rack_delegation.rb:19:in `dispatch'
>     # /Users/<my user>/.rvm/gems/ree-1.8.7-2010.01%rails3/gems/actionpack-3.0.0.beta/lib/action_controller/metal.rb:89:in `call'
>     # /Users/<my user>/.rvm/gems/ree-1.8.7-2010.01%rails3/gems/rack-test-0.5.3/lib/rack/mock_session.rb:30:in `request'
>     # /Users/<my user>/.rvm/gems/ree-1.8.7-2010.01%rails3/gems/rack-test-0.5.3/lib/rack/test.rb:207:in `process_request'
>     # /Users/<my user>/.rvm/gems/ree-1.8.7-2010.01%rails3/gems/rack-test-0.5.3/lib/rack/test.rb:105:in `request'
>     # /Users/<my user>/.rvm/gems/ree-1.8.7-2010.01%rails3/gems/actionpack-3.0.0.beta/lib/action_dispatch/testing/integration.rb:272:in `process'
>     # /Users/<my user>/.rvm/gems/ree-1.8.7-2010.01%rails3/gems/actionpack-3.0.0.beta/lib/action_dispatch/testing/integration.rb:48:in `delete'
>     # /Users/<my user>/.rvm/gems/ree-1.8.7-2010.01%rails3/gems/actionpack-3.0.0.beta/lib/action_dispatch/testing/integration.rb:315:in `__send__'
>     # /Users/<my user>/.rvm/gems/ree-1.8.7-2010.01%rails3/gems/actionpack-3.0.0.beta/lib/action_dispatch/testing/integration.rb:315:in `delete'
>     # (eval):3:in `delete'
>     # ./spec/controllers/<my_controller>_spec.rb:49
> 
> Have you guys ever been through this problem?
> 
> Thanks,
> Mauricio
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users



More information about the rspec-users mailing list