Skip to content
Browse files

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
  • Loading branch information...
1 parent e81f1ac commit ae8179f05c49867e1136204bdf6d14a8fd4a7596 @jeremy jeremy committed Oct 15, 2007
Showing with 22 additions and 0 deletions.
  1. +22 −0 actionpack/test/controller/routing_test.rb
View
22 actionpack/test/controller/routing_test.rb
@@ -874,6 +874,28 @@ def test_regexp_chunk_should_return_string
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

0 comments on commit ae8179f

Please sign in to comment.
Something went wrong with that request. Please try again.