Skip to content

Instantly share code, notes, and snippets.

@aanand
Created March 2, 2010 20:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aanand/319884 to your computer and use it in GitHub Desktop.
Save aanand/319884 to your computer and use it in GitHub Desktop.
class FooController < ApplicationController
end
require 'test_helper'
class FooControllerTest < ActionController::TestCase
def test_route1
assert_routing "/route1/abc/123",
:controller => 'foo',
:action => 'action1',
:first_part => 'abc',
:second_part => '123'
end
def test_route2
assert_routing "/route2/abc/123",
:controller => 'foo',
:action => 'action2',
:first_part => 'abc',
:second_part => '123'
end
end
Rails3app::Application.routes.draw do |map|
match '/route1/:first_part/:second_part' => 'foo#action1', :constraints => { :first_part => /[a-z]+/ }
match '/route2/:first_part/:second_part' => 'foo#action2', :constraints => { :first_part => /[a-z]+/i }
end
$ rvm 1.9.1,1.8.7 rake test
ruby-1.9.1-p378: ruby 1.9.1p378 (2010-01-10 revision 26273) [i386-darwin10.2.0]
(in /Users/aanand/src/rails3bugtest/rails3app)
Loaded suite /Users/aanand/.rvm/gems/ruby-1.9.1-p378%global/gems/rake-0.8.7/lib/rake/rake_test_loader
Started
..
Finished in 0.121878 seconds.
2 tests, 6 assertions, 0 failures, 0 errors, 0 skips
ruby-1.8.7-p249: ruby 1.8.7 (2010-01-10 patchlevel 249) [i686-darwin10.2.0]
(in /Users/aanand/src/rails3bugtest/rails3app)
Loaded suite /Users/aanand/.rvm/gems/ruby-1.8.7-p249/gems/rake-0.8.7/lib/rake/rake_test_loader
Started
.F
Finished in 0.029549 seconds.
1) Failure:
test_route2(FooControllerTest)
[]:
The recognized options <{"action"=>"action2", "first_part"=>"abc", "controller"=>"foo"}> did not match <{"second_part"=>"123",
"action"=>"action2",
"first_part"=>"abc",
"controller"=>"foo"}>, difference: <{"second_part"=>"123"}>
2 tests, 4 assertions, 1 failures, 0 errors
Errors running test:functionals!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment