spec/private/recognize_spec.rb in joshbuddy-usher-0.4.8 vs spec/private/recognize_spec.rb in joshbuddy-usher-0.4.10
- old
+ new
@@ -91,9 +91,21 @@
target_route = route_set.add_route('/test/part/{*test,^(hello|again|\d+)$}/{:party,onemore}')
route_set.recognize(build_request({:method => 'get', :path => '/test/part/hello/again/123/hello/again/onemore'})).path.route.should == target_route
route_set.recognize(build_request({:method => 'get', :path => '/test/part/hello/again/123/hello/again/onemore'})).params.should == [[:test, ['hello', 'again', '123', 'hello', 'again']], [:party, 'onemore']]
end
+ it "should recgonize a greedy regex single variable" do
+ 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 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
+
it "should recgonize two glob-style variables separated by a static part" do
target_route = route_set.add_route('/*format/innovate/*onemore')
response = route_set.recognize(build_request({:method => 'get', :path => '/sample/html/innovate/apple'}))
response.params.should == [[:format, ['sample', 'html']], [:onemore, ['apple']]]
response.path.route.should == target_route
\ No newline at end of file