Skip to content

Instantly share code, notes, and snippets.

@sukima
Created January 19, 2011 22:26
Show Gist options
  • Save sukima/787017 to your computer and use it in GitHub Desktop.
Save sukima/787017 to your computer and use it in GitHub Desktop.
Rails test routing bug
(in /Users/suki/tmp/barfoo)
Loaded suite /Users/suki/.rvm/gems/ruby-1.8.7-p302@global/gems/rake-0.8.7/lib/rake/rake_test_loader
Started
Finished in 0.000435 seconds.
0 tests, 0 assertions, 0 failures, 0 errors
Loaded suite /Users/suki/.rvm/gems/ruby-1.8.7-p302@global/gems/rake-0.8.7/lib/rake/rake_test_loader
Started
F
Finished in 0.044635 seconds.
1) Failure:
test_the_truth(SpecialEventsControllerTest) [/test/functional/special_events_controller_test.rb:6]:
The recognized options <{"action"=>"index", "controller"=>"special_events"}> did not match <{"action"=>"show", "controller"=>"special_events"}>, difference: <{"action"=>"show"}>
1 tests, 1 assertions, 1 failures, 0 errors

Using RAILS 2.3.5

$ rails foobar
$ cd foobar
$ script/generate controller SpecialEvents

Add/edit the following files to those in this gist.

$ rake db:migrate
$ rake test

Causes the following error:

  1) Failure:
test_the_truth(SpecialEventsControllerTest) [/test/functional/special_events_controller_test.rb:6]:
The recognized options <{"action"=>"index", "controller"=>"special_events"}> did not match <{"action"=>"show", "controller"=>"special_events"}>, difference: <{"action"=>"show"}>
ActionController::Routing::Routes.draw do |map|
map.resources :special_events
end
class SpecialEventsController < ApplicationController
def show
@special_event = nil
end
end
require 'test_helper'
class SpecialEventsControllerTest < ActionController::TestCase
# Replace this with your real tests.
test "the truth" do
assert_routing "special_events", {:controller =>"special_events", :action => 'show'}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment