aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--actionpack/test/controller/routing_test.rb22
1 files changed, 22 insertions, 0 deletions
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