spec/private/recognize_spec.rb in usher-0.5.6 vs spec/private/recognize_spec.rb in usher-0.5.7

- old
+ new

@@ -1,6 +1,7 @@ -require 'lib/usher' +require File.expand_path(File.join(File.dirname(__FILE__), "..", "spec_helper")) +require "usher" route_set = Usher.new def build_request(opts) request = mock "Request" @@ -204,9 +205,17 @@ end it "should should raise if malformed variables are used" do route_set.add_route('/products/show/:id', :id => /\d+/, :conditions => {:method => 'get'}) proc {route_set.recognize(build_request({:method => 'get', :path => '/products/show/qweasd', :domain => 'admin.host.com'}))}.should raise_error + end + + it "should recognize multiple optional parts" do + target_route = route_set.add_route('/test(/this)(/too)') + route_set.recognize_path('/test').path.route.should == target_route + route_set.recognize_path('/test/this').path.route.should == target_route + route_set.recognize_path('/test/too').path.route.should == target_route + route_set.recognize_path('/test/this/too').path.route.should == target_route end describe "partial recognition" do it "should partially match a route" do route = route_set.add_route("/foo")