Added test for case described in 688

This commit is contained in:
Florian René Hanke 2013-03-21 10:03:22 +11:00
parent 62639dba3d
commit 3be9e098a6
1 changed files with 35 additions and 29 deletions

View File

@ -6,7 +6,7 @@ class CompileTest < Test::Unit::TestCase
def self.converts pattern, expected_regexp
it "generates #{expected_regexp.source} from #{pattern}" do
compiled, _ = compiled pattern
assert_equal expected_regexp, compiled
assert_equal expected_regexp, compiled, "Pattern #{pattern} is not compiled into #{expected_regexp.source}. Was #{compiled.source}."
end
end
def self.parses pattern, example, expected_params
@ -27,7 +27,7 @@ class CompileTest < Test::Unit::TestCase
hash
end
assert_equal(expected_params, params)
assert_equal expected_params, params, "Pattern #{pattern} does not match path #{example}."
end
end
def self.fails pattern, example
@ -142,7 +142,7 @@ class CompileTest < Test::Unit::TestCase
parses "/:id/test.bar", "/2/test.bar", {"id" => "2"}
parses "/:id/test.bar", "/2E/test.bar", {"id" => "2E"}
parses "/:id/test.bar", "/2e/test.bar", {"id" => "2e"}
fails "/:id/test.bar", "/%2E/test.bar"
parses "/:id/test.bar", "/%2E/test.bar", {"id" => "%2E"}
parses '/10/:id', '/10/test', "id" => "test"
parses '/10/:id', '/10/te.st', "id" => "te.st"
@ -162,4 +162,10 @@ class CompileTest < Test::Unit::TestCase
parses "/:file.:ext", "/pony正%2ejpg", "file" => "pony正", "ext" => "jpg"
fails "/:file.:ext", "/pony正..jpg"
fails "/:file.:ext", "/pony正.%2ejpg"
# parses "/:foo.:bar", "/file.tar.gz", "foo" => "file", "bar" => "tar.gz"
# From issue #688.
#
parses "/articles/10.1103/:doi", "/articles/10.1103/PhysRevLett.110.026401", "doi" => "PhysRevLett.110.026401"
end