From ae8179f05c49867e1136204bdf6d14a8fd4a7596 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Mon, 15 Oct 2007 04:27:31 +0000 Subject: Expand Routes::DynamicSegment test coverage. Closes #7122 [Kevin Clark] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7898 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/test/controller/routing_test.rb | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'actionpack/test/controller') diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb index ce897db238..f2bd9f4301 100644 --- a/actionpack/test/controller/routing_test.rb +++ b/actionpack/test/controller/routing_test.rb @@ -874,6 +874,28 @@ class DynamicSegmentTest < Test::Unit::TestCase assert_kind_of String, segment.regexp_chunk end + def test_build_pattern_non_optional_with_no_captures + # Non optioanl + a_segment = ROUTING::DynamicSegment.new + a_segment.regexp = /\d+/ #number_of_captures is 0 + assert_equal "(\\d+)stuff", a_segment.build_pattern('stuff') + end + + def test_build_pattern_non_optional_with_captures + # Non optioanl + a_segment = ROUTING::DynamicSegment.new + a_segment.regexp = /(\d+)(.*?)/ #number_of_captures is 2 + assert_equal "((\\d+)(.*?))stuff", a_segment.build_pattern('stuff') + end + + def test_optionality_implied + a_segment = ROUTING::DynamicSegment.new + a_segment.key = :id + assert a_segment.optionality_implied? + + a_segment.key = :action + assert a_segment.optionality_implied? + end end class ControllerSegmentTest < Test::Unit::TestCase -- cgit v1.2.3