Skip to content

Instantly share code, notes, and snippets.

@aanand
Created March 2, 2010 23:05
Show Gist options
  • Save aanand/320085 to your computer and use it in GitHub Desktop.
Save aanand/320085 to your computer and use it in GitHub Desktop.
# encoding: utf-8
require 'abstract_unit'
class TestCaseInsensitivityFlag < Test::Unit::TestCase
def setup
@app = Rack::Mount::RouteSet.new do |set|
regex_1 = if supports_named_captures?
eval '/\A\/route1\/(?<first_part>[a-z]+)\/(?<second_part>[^\/.?]+)\Z/'
else
/\A\/route1\/([a-z]+)\/([^\/.?]+)\Z/
end
regex_2 = if supports_named_captures?
eval '/\A\/route2\/(?<first_part>(?i-mx:[a-z]+))\/(?<second_part>[^\/.?]+)\Z/'
else
/\A\/route2\/((?i-mx:[a-z]+))\/([^\/.?]+)\Z/
end
set.add_route(EchoApp, {:path_info => regex_1}, {:controller=>"foo", :action=>"action1"}, nil)
set.add_route(EchoApp, {:path_info => regex_2}, {:controller=>"foo", :action=>"action2"}, nil)
end
end
def test_route1
assert_recognizes({:controller => 'foo', :action => 'action1', :first_part => 'abc', :second_part => '123'}, '/route1/abc/123')
end
def test_route2
assert_recognizes({:controller => 'foo', :action => 'action2', :first_part => 'abc', :second_part => '123'}, '/route2/abc/123')
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment