spec/private/recognize_spec.rb in joshbuddy-usher-0.4.10 vs spec/private/recognize_spec.rb in joshbuddy-usher-0.4.11
- old
+ new
@@ -97,9 +97,17 @@
target_route = route_set.add_route('/test/part/{!test,one/more/time}')
route_set.recognize(build_request({:method => 'get', :path => '/test/part/one/more/time'})).path.route.should == target_route
route_set.recognize(build_request({:method => 'get', :path => '/test/part/one/more/time'})).params.should == [[:test, 'one/more/time']]
end
+ it "should recgonize a greedy regex that matches across / and not" do
+ target_route = route_set.add_route('/test/part/{!test,one/more|one}')
+ route_set.recognize(build_request({:method => 'get', :path => '/test/part/one/more'})).path.route.should == target_route
+ route_set.recognize(build_request({:method => 'get', :path => '/test/part/one/more'})).params.should == [[:test, 'one/more']]
+ route_set.recognize(build_request({:method => 'get', :path => '/test/part/one'})).path.route.should == target_route
+ route_set.recognize(build_request({:method => 'get', :path => '/test/part/one'})).params.should == [[:test, 'one']]
+ end
+
it "should recgonize a greedy regex single variable with static parts after" do
target_route = route_set.add_route('/test/part/{!test,one/more/time}/help')
route_set.recognize(build_request({:method => 'get', :path => '/test/part/one/more/time/help'})).path.route.should == target_route
route_set.recognize(build_request({:method => 'get', :path => '/test/part/one/more/time/help'})).params.should == [[:test, 'one/more/time']]
end
\ No newline at end of file