Problems testing destroy method in rspec2

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//.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:inrewrite’
# /Users//.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:inurl_for’
# /Users//.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:inredirect_to’
# /Users//.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:inredirect_to’
# /Users//.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:insend
# /Users//.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:inredirect_to’
# /Users//dev/easyclinica/app/controllers/convenios_controller.rb:55
# /Users//.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:inrespond_to’
# /Users//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:insend_action’
# /Users//.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:inprocess_action’
# /Users//.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//.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//.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:inrun_callbacks’
# /Users//.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:inprocess_action’
# /Users//.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:inprocess_action’
# /Users//.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:insend
# /Users//.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:inprocess_action’
# /Users//.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:inprocess’
# /Users//.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:indispatch’
# /Users//.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:inrequest’
# /Users//.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:inrequest’
# /Users//.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:indelete’
# /Users//.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:indelete’
# (eval):3:in `delete’
# ./spec/controllers/<my_controller>_spec.rb:49

Have you guys ever been through this problem?

Thanks,
Mauricio

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

Julian.

On Wed, Mar 24, 2010 at 10:39 PM, Mauricio Aniche
[email protected] 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.

What version of rspec and rspec-rails are you using?

Hi David,

I am using rspec2 beta4, which is the latest version in gemcutter.

Hi Julian,

The problem only happens in my spec. My rails3 applications works fine
(I use a post with a hidden _method set as delete, but I guess this is
a browser problem!)

Regards,
Mauricio

Hi,

Is there anyone else who had this problem?

Thanks,
Mauricio

On Thu, Mar 25, 2010 at 10:15 AM, Mauricio Aniche

Hi,

Just to close this one… RSpec wasn’t the problem!

My bad! :slight_smile:

Thanks,
Mauricio

On Mon, Mar 29, 2010 at 1:20 PM, Mauricio Aniche

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs