spec/private/recognize_spec.rb in usher-0.6.2 vs spec/private/recognize_spec.rb in usher-0.6.3
- old
+ new
@@ -271,9 +271,16 @@
@route_set.recognize(build_request({:path => '/id1/one.html'})).params.should == [[:id1, 'id1'], [:format, 'html']]
@route_set.recognize(build_request({:path => '/id1/one/id2'})).params.should == [[:id1, 'id1'], [:id2, 'id2']]
@route_set.recognize(build_request({:path => '/id1/one/id2.html'})).params.should == [[:id1, 'id1'], [:id2, 'id2'], [:format, 'html']]
end
+ it "should pick the correct variable name when there are two variable names that could be represented" do
+ @route_set.add_route('/:var1')
+ @route_set.add_route('/:var2/foo')
+ @route_set.recognize(build_request({:path => '/foo1'})).params.should == [[:var1, 'foo1']]
+ @route_set.recognize(build_request({:path => '/foo2/foo'})).params.should == [[:var2, 'foo2']]
+ end
+
it "should recognize a path with an optional compontnet" do
@route_set.add_route("/:name(/:surname)", :conditions => {:method => 'get'})
result = @route_set.recognize(build_request({:method => 'get', :path => '/homer'}))
result.params.should == [[:name, "homer"]]
result = @route_set.recognize(build_request({:method => 'get', :path => "/homer/simpson"}))