spec/private/recognize_spec.rb in usher-0.8.0 vs spec/private/recognize_spec.rb in usher-0.8.1

- old
+ new

@@ -82,10 +82,19 @@ www_product_show_route.should == @route_set.recognize(build_request({:method => 'get', :path => '/products/show/123', :subdomains => 'admin', :user_agent => true})).path.route www_product_show_route.should == @route_set.recognize(build_request({:method => 'get', :path => '/products/show/123', :subdomains => 'www', :user_agent => false})).path.route end end + describe 'when proc' do + + it "pick the correct route" do + not_target_route = @route_set.add_route('/sample').when{|r| r.protocol == 'https'} + target_route = @route_set.add_route('/sample').when{|r| r.protocol == 'http'} + @route_set.recognize(build_request({:method => 'get', :path => '/sample', :protocol => 'http'})).path.route.should == target_route + end + end + it "should recognize path with a trailing slash" do @route_set = Usher.new(:request_methods => [:protocol, :domain, :port, :query_string, :remote_ip, :user_agent, :referer, :method, :subdomains], :ignore_trailing_delimiters => true) target_route = @route_set.add_route('/path', :controller => 'sample', :action => 'action') @@ -397,17 +406,17 @@ @r2.recognize( build_request(:path => "/foo")).path.route.destination.should == {:foo =>"foo"} end it "should not add routes added to the dup to the original" do @r2.add_route("/bar", :bar => "bar") - @r2.recognize( build_request(:path => "/bar")).path.route.destination.should == {:bar => "bar"} - @route_set.recognize( build_request(:path => "/bar")).should == nil + @r2.recognize( build_request(:path => "/bar")).path.route.destination.should == {:bar => "bar"} + @route_set.recognize(build_request(:path => "/bar")).should == nil end it "should not delete routes added to the dup to the original" do @r2.delete_route("/foo") - @route_set.recognize( build_request(:path => "/foo")).path.route.destination.should == {:foo => "foo"} - @r2.recognize( build_request(:path => "/foo")).should == nil + @route_set.recognize(build_request(:path => "/foo")).path.route.destination.should == {:foo => "foo"} + @r2.recognize( build_request(:path => "/foo")).should == nil end it "should safely dup with nested ushers" do r1 = Usher.new