Added test for case described in 688
This commit is contained in:
parent
62639dba3d
commit
3be9e098a6
|
@ -6,7 +6,7 @@ class CompileTest < Test::Unit::TestCase
|
||||||
def self.converts pattern, expected_regexp
|
def self.converts pattern, expected_regexp
|
||||||
it "generates #{expected_regexp.source} from #{pattern}" do
|
it "generates #{expected_regexp.source} from #{pattern}" do
|
||||||
compiled, _ = compiled pattern
|
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
|
||||||
end
|
end
|
||||||
def self.parses pattern, example, expected_params
|
def self.parses pattern, example, expected_params
|
||||||
|
@ -27,7 +27,7 @@ class CompileTest < Test::Unit::TestCase
|
||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_equal(expected_params, params)
|
assert_equal expected_params, params, "Pattern #{pattern} does not match path #{example}."
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
def self.fails pattern, example
|
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", "/2/test.bar", {"id" => "2"}
|
||||||
parses "/:id/test.bar", "/2E/test.bar", {"id" => "2E"}
|
parses "/:id/test.bar", "/2E/test.bar", {"id" => "2E"}
|
||||||
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/test', "id" => "test"
|
||||||
parses '/10/:id', '/10/te.st', "id" => "te.st"
|
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"
|
parses "/:file.:ext", "/pony正%2ejpg", "file" => "pony正", "ext" => "jpg"
|
||||||
fails "/:file.:ext", "/pony正..jpg"
|
fails "/:file.:ext", "/pony正..jpg"
|
||||||
fails "/:file.:ext", "/pony正.%2ejpg"
|
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
|
end
|
||||||
|
|
Loading…
Reference in New Issue