aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2007-10-15 04:27:31 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2007-10-15 04:27:31 +0000
commitae8179f05c49867e1136204bdf6d14a8fd4a7596 (patch)
tree29a3898da8cd5f31516ddbac5a85e8c0cefd446e /actionpack
parente81f1acc33a642df68c32d28202dcf589a79d714 (diff)
downloadrails-ae8179f05c49867e1136204bdf6d14a8fd4a7596.tar.gz
rails-ae8179f05c49867e1136204bdf6d14a8fd4a7596.tar.bz2
rails-ae8179f05c49867e1136204bdf6d14a8fd4a7596.zip
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
Diffstat (limited to 'actionpack')
-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