spec/private/sinatra/recognize_spec.rb in usher-0.7.2 vs spec/private/sinatra/recognize_spec.rb in usher-0.7.3

- old
+ new

@@ -47,10 +47,27 @@ response = @app.call_with_mock_request('/foo/bar/') response.status.should == 200 response.body.should == "bar" end + it "should ignore trailing delimiters with an optional param" do + @app.get("/foo/(:bar)") { params[:bar] } + @app.get("/bar(/:foo)") { params[:foo] } + response = @app.call_with_mock_request('/foo/bar') + response.status.should == 200 + response.body.should == "bar" + response = @app.call_with_mock_request('/bar/foo') + response.status.should == 200 + response.body.should == "foo" + response = @app.call_with_mock_request('/bar') + response.status.should == 200 + response.body.should == "" + response = @app.call_with_mock_request('/bar/') + response.status.should == 200 + response.body.should == "" + end + it "should use sinatra optionals trailing delimiters" do @app.get("/foo/?") { "foo" } response = @app.call_with_mock_request('/foo') response.status.should == 200 response.body.should == "foo" @@ -95,8 +112,29 @@ it "should correctly generate a not found page without images" do response = @app.call_with_mock_request('/bar') response.status.should == 404 response.body.should_not match(/__sinatra__/) + end + end + + describe "recognize paths" do + + it "should recognize basic routes" do + pending "undefined method `request_method' for nil:NilClass" + @app.get("/foo/:bar") { "foo" } + @app.router.recognize_path("/foo/:bar").should == nil + end + end + + describe "priority" do + + it "should set correctly priorities" do + pending "match the wrong route" + @app.get("/:id/:right", :priority => 10) { "right" } + @app.get("/:id/:wrong") { "wrong" } + response = @app.call_with_mock_request('/foo/bar') + response.status.should == 200 + response.body.should == "right" end end end \ No newline at end of file