Skip to content

Commit

Permalink
guard named caputres tests (they only work on Ruby 1.9). fixes #169.
Browse files Browse the repository at this point in the history
  • Loading branch information
rkh committed Feb 17, 2011
1 parent 0428794 commit e07a603
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions test/routing_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -179,19 +179,21 @@ class RoutingTest < Test::Unit::TestCase
assert_equal "foo=;bar=", body
end

it "supports named captures like %r{/hello/(?<person>[^/?#]+)}" do
it "supports named captures like %r{/hello/(?<person>[^/?#]+)} on Ruby >= 1.9" do
next if RUBY_VERSION < '1.9'
mock_app {
get %r{/hello/(?<person>[^/?#]+)} do
get Regexp.new('/hello/(?<person>[^/?#]+)') do
"Hello #{params['person']}"
end
}
get '/hello/Frank'
assert_equal 'Hello Frank', body
end

it "supports optional named captures like %r{/page(?<format>.[^/?#]+)?}" do
it "supports optional named captures like %r{/page(?<format>.[^/?#]+)?} on Ruby >= 1.9" do
next if RUBY_VERSION < '1.9'
mock_app {
get %r{/page(?<format>.[^/?#]+)?} do
get Regexp.new('/page(?<format>.[^/?#]+)?') do
"format=#{params[:format]}"
end
}
Expand Down

0 comments on commit e07a603

Please sign in to comment.