Please disregard this ticket. The tests were correct,
the destroy wants params[:id], which I didn't provide.
When you leave out the map.connect
':controller/:action/:id' route, functional tests encounters
a ActionController::RoutingError when testing
post :destroy even though you have map.resources
:posts in routes.rb
Here's how I'm producing this error:
leethal@haxxor ~> ruby ~/Code/rails/rails/railties/bin/rails weird_bug
# ...
leethal@haxxor ~> cd weird_bug
leethal@haxxor ~/weird_bug> git init
leethal@haxxor ~/weird_bug> git submodule add git://github.com/rails/rails.git vendor/rails
# ...
leethal@haxxor ~/weird_bug> ruby script/generate controller posts
Then, in config/routes.rb:
ActionController::Routing::Routes.draw do |map|
map.resources :posts
end
In test/functional/posts_controller_test.rb:
require 'test_helper'
class PostsControllerTest < ActionController::TestCase
test "destroy" do
post :destroy
end
end
Back in the terminal.
leethal@haxxor ~/weird_bug> rake test:functionals
(in /Users/leethal/weird_bug)
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -Ilib:test "/Library/Ruby/Gems/1.8/gems/rake-0.8.3/lib/rake/rake_test_loader.rb" "test/functional/posts_controller_test.rb"
Loaded suite /Library/Ruby/Gems/1.8/gems/rake-0.8.3/lib/rake/rake_test_loader
Started
E
Finished in 0.077376 seconds.
1) Error:
test_destroy(PostsControllerTest):
ActionController::RoutingError: No route matches {:action=>"destroy", :controller=>"posts"}
/test/functional/posts_controller_test.rb:5:in `test_destroy'
1 tests, 0 assertions, 0 failures, 1 errors
rake aborted!
Command failed with status (1): [/System/Library/Frameworks/Ruby.framework/...]
(See full trace by running task with --trace)