Methods
- T
-
- test_ast_sets_regular_expressions,
- test_failed_match,
- test_insensitive_regexp_with_group,
- test_match_controller,
- test_match_controller_action,
- test_match_controller_action_id,
- test_match_data_with_group,
- test_match_data_with_multi_group,
- test_match_literal,
- test_match_literal_with_action,
- test_match_literal_with_action_and_format,
- test_optional_names,
- test_star_with_custom_re,
- test_to_regexp_defaults,
- test_to_regexp_match_non_optional,
- test_to_regexp_with_extended_group,
- test_to_regexp_with_group,
- test_to_regexp_with_strexp
Instance Public methods
test_ast_sets_regular_expressions()
Link
# File actionpack/test/journey/path/pattern_test.rb, line 128 def test_ast_sets_regular_expressions requirements = { :name => /(tender|love)/, :value => /./ } strexp = Router::Strexp.build( '/page/:name/:value', requirements, ["/", ".", "?"] ) assert_equal requirements, strexp.requirements path = Pattern.new strexp nodes = path.ast.grep(Nodes::Symbol) assert_equal 2, nodes.length nodes.each do |node| assert_equal requirements[node.to_sym], node.regexp end end
test_failed_match()
Link
test_insensitive_regexp_with_group()
Link
# File actionpack/test/journey/path/pattern_test.rb, line 183 def test_insensitive_regexp_with_group strexp = Router::Strexp.build( '/page/:name/aaron', { :name => /(tender|love)/i }, ["/", ".", "?"] ) path = Pattern.new strexp assert_match(path, '/page/TENDER/aaron') assert_match(path, '/page/loVE/aaron') assert_no_match(path, '/page/loVE/AAron') end
test_match_controller()
Link
# File actionpack/test/journey/path/pattern_test.rb, line 216 def test_match_controller path = Pattern.from_string '/:controller(/:action(/:id(.:format)))' uri = '/content' match = path =~ uri assert_equal %w{ controller action id format }, match.names assert_equal 'content', match[1] assert_nil match[2] assert_nil match[3] assert_nil match[4] end
test_match_controller_action()
Link
# File actionpack/test/journey/path/pattern_test.rb, line 228 def test_match_controller_action path = Pattern.from_string '/:controller(/:action(/:id(.:format)))' uri = '/content/list' match = path =~ uri assert_equal %w{ controller action id format }, match.names assert_equal 'content', match[1] assert_equal 'list', match[2] assert_nil match[3] assert_nil match[4] end
test_match_controller_action_id()
Link
# File actionpack/test/journey/path/pattern_test.rb, line 240 def test_match_controller_action_id path = Pattern.from_string '/:controller(/:action(/:id(.:format)))' uri = '/content/list/10' match = path =~ uri assert_equal %w{ controller action id format }, match.names assert_equal 'content', match[1] assert_equal 'list', match[2] assert_equal '10', match[3] assert_nil match[4] end
test_match_data_with_group()
Link
# File actionpack/test/journey/path/pattern_test.rb, line 146 def test_match_data_with_group strexp = Router::Strexp.build( '/page/:name', { :name => /(tender|love)/ }, ["/", ".", "?"] ) path = Pattern.new strexp match = path.match '/page/tender' assert_equal 'tender', match[1] assert_equal 2, match.length end
test_match_data_with_multi_group()
Link
# File actionpack/test/journey/path/pattern_test.rb, line 158 def test_match_data_with_multi_group strexp = Router::Strexp.build( '/page/:name/:id', { :name => /t(((ender|love)))()/ }, ["/", ".", "?"] ) path = Pattern.new strexp match = path.match '/page/tender/10' assert_equal 'tender', match[1] assert_equal '10', match[2] assert_equal 3, match.length assert_equal %w{ tender 10 }, match.captures end
test_match_literal()
Link
test_match_literal_with_action()
Link
# File actionpack/test/journey/path/pattern_test.rb, line 262 def test_match_literal_with_action path = Path::Pattern.from_string "/books(/:action(.:format))" uri = '/books/list' match = path =~ uri assert_equal %w{ action format }, match.names assert_equal 'list', match[1] assert_nil match[2] end
test_match_literal_with_action_and_format()
Link
# File actionpack/test/journey/path/pattern_test.rb, line 272 def test_match_literal_with_action_and_format path = Path::Pattern.from_string "/books(/:action(.:format))" uri = '/books/list.rss' match = path =~ uri assert_equal %w{ action format }, match.names assert_equal 'list', match[1] assert_equal 'rss', match[2] end
test_optional_names()
Link
# File actionpack/test/journey/path/pattern_test.rb, line 94 def test_optional_names [ ['/:foo(/:bar(/:baz))', %w{ bar baz }], ['/:foo(/:bar)', %w{ bar }], ['/:foo(/:bar)/:lol(/:baz)', %w{ bar baz }], ].each do |pattern, list| path = Pattern.from_string pattern assert_equal list.sort, path.optional_names.sort end end
test_star_with_custom_re()
Link
test_to_regexp_defaults()
Link
test_to_regexp_match_non_optional()
Link
test_to_regexp_with_extended_group()
Link
# File actionpack/test/journey/path/pattern_test.rb, line 78 def test_to_regexp_with_extended_group strexp = Router::Strexp.build( '/page/:name', { :name => / #ROFL (tender|love #MAO )/x }, ["/", ".", "?"] ) path = Pattern.new strexp assert_match(path, '/page/tender') assert_match(path, '/page/love') assert_no_match(path, '/page/loving') end
test_to_regexp_with_group()
Link
# File actionpack/test/journey/path/pattern_test.rb, line 116 def test_to_regexp_with_group strexp = Router::Strexp.build( '/page/:name', { :name => /(tender|love)/ }, ["/", ".", "?"] ) path = Pattern.new strexp assert_match(path, '/page/tender') assert_match(path, '/page/love') assert_no_match(path, '/page/loving') end
test_to_regexp_with_strexp()
Link