spec/private/recognize_spec.rb in usher-0.6.8 vs spec/private/recognize_spec.rb in usher-0.7.0
- old
+ new
@@ -330,9 +330,23 @@
@route_set.add_route("/foo")
@route_set.recognize(build_request(:method => "get", :path => "/asdf")).should be_nil
end
+ it "should match a variable inbetween two secondary delimiters" do
+ @route_set.add_route("/o.:slug.gif").to(:test)
+ response = @route_set.recognize(build_request(:method => "get", :path => "/o.help.gif"))
+ response.destination.should == :test
+ response.params.should == [[:slug, "help"]]
+ end
+
+ it "should match a route with no path" do
+ route = @route_set.add_route(nil, :conditions => {:protocol => 'http'}).to(:test)
+ @route_set.recognize(build_request({:method => 'post', :protocol => 'http', :path => '/foo'})).destination.should == :test
+ @route_set.recognize(build_request({:method => 'post', :protocol => 'http', :path => '/bar'})).destination.should == :test
+ @route_set.recognize(build_request({:method => 'post', :protocol => 'https', :path => '/foo'})).should be_nil
+ end
+
describe "partial recognition" do
it "should partially match a route" do
route = @route_set.add_route("/foo")
route.match_partially!
response = @route_set.recognize(build_request(:method => "get", :path => "/foo/bar"))