spec/plugin/multi_route_spec.rb in roda-0.9.0 vs spec/plugin/multi_route_spec.rb in roda-1.0.0

- old
+ new

@@ -3,40 +3,47 @@ describe "multi_route plugin" do before do app(:bare) do plugin :multi_route - route(:get) do |r| + route("get") do |r| r.is "" do "get" end r.is "a" do "geta" end end - route(:post) do |r| + route("post") do |r| r.is "" do "post" end r.is "a" do "posta" end end route do |r| + r.on 'foo' do + r.multi_route do + "foo" + end + end + r.get do - route(:get) + r.route("get") r.is "b" do "getb" end end + r.post do - route(:post) + r.route("post") r.is "b" do "postb" end end @@ -53,10 +60,19 @@ body('/b', 'REQUEST_METHOD'=>'POST').should == 'postb' status('/c').should == 404 status('/c', 'REQUEST_METHOD'=>'POST').should == 404 end + it "uses multi_route to dispatch to any named route" do + status('/foo').should == 404 + body('/foo/get/').should == 'get' + body('/foo/get/a').should == 'geta' + body('/foo/post/').should == 'post' + body('/foo/post/a').should == 'posta' + body('/foo/post/b').should == 'foo' + end + it "handles loading the plugin multiple times correctly" do app.plugin :multi_route body.should == 'get' body('REQUEST_METHOD'=>'POST').should == 'post' body('/a').should == 'geta' @@ -69,17 +85,17 @@ it "handles subclassing correctly" do @app = Class.new(@app) @app.route do |r| r.get do - route(:post) + r.route("post") r.is "b" do "1b" end end r.post do - route(:get) + r.route("get") r.is "b" do "2b" end end