-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Josh Hull
committed
Mar 22, 2011
1 parent
bd79060
commit 218995f
Showing
6 changed files
with
58 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,24 @@ | ||
class TestMisc < MiniTest::Unit::TestCase | ||
#def test_exceptions | ||
# assert_raises(HttpRouter::AmbiguousRouteException) {HttpRouter.new.add("/:var1(/:var2)(/:var3)").compile} | ||
# assert_raises(HttpRouter::AmbiguousVariableException) {HttpRouter.new.add("/:var1(/:var1)(/:var1)").compile} | ||
# assert_raises(HttpRouter::UnsupportedRequestConditionError) {HttpRouter.new.add("/").condition(:flibberty => 'gibet').compile} | ||
#end | ||
# | ||
#def test_cloning | ||
# r1 = HttpRouter.new { | ||
# add('/test').name(:test_route).to :test | ||
# } | ||
# r2 = r1.clone | ||
# | ||
# r2.add('/test2').name(:test).to(:test2) | ||
# assert_equal 2, r2.routes.size | ||
# | ||
# assert r1.recognize(Rack::Request.new(Rack::MockRequest.env_for('/test2'))).nil? | ||
# assert !r2.recognize(Rack::Request.new(Rack::MockRequest.env_for('/test2'))).nil? | ||
# assert_equal r1.routes.first, r1.named_routes[:test_route] | ||
# assert_equal r2.routes.first, r2.named_routes[:test_route] | ||
# | ||
# r1.add('/another').name(:test).to(:test2) | ||
# | ||
# assert_equal r1.routes.size, r2.routes.size | ||
# assert_equal '/another', r1.url(:test) | ||
# assert_equal '/test2', r2.url(:test) | ||
# assert_equal :test, r1.routes.first.dest | ||
# assert_equal :test, r2.routes.first.dest | ||
#end | ||
def test_cloning | ||
r1 = HttpRouter.new { | ||
add('/test').name(:test_route).to :test | ||
} | ||
r2 = r1.clone | ||
|
||
r2.add('/test2').name(:test).to(:test2) | ||
assert_equal 2, r2.routes.size | ||
|
||
assert_equal 404, r1.recognize(Rack::Request.new(Rack::MockRequest.env_for('/test2'))).first | ||
assert r2.recognize(Rack::Request.new(Rack::MockRequest.env_for('/test2'))) | ||
assert_equal r1.routes.first, r1.named_routes[:test_route] | ||
assert_equal r2.routes.first, r2.named_routes[:test_route] | ||
|
||
r1.add('/another').name(:test).to(:test2) | ||
|
||
assert_equal r1.routes.size, r2.routes.size | ||
assert_equal '/another', r1.url(:test) | ||
assert_equal '/test2', r2.url(:test) | ||
assert_equal :test, r1.routes.first.dest | ||
assert_equal :test, r2.routes.first.dest | ||
end | ||
end |