spec/recognize_spec.rb in joshbuddy-usher-0.1.0 vs spec/recognize_spec.rb in joshbuddy-usher-0.1.1

- old
+ new

@@ -28,9 +28,24 @@ target_route = route_set.add_route('/sample', :controller => 'sample', :action => 'action', :conditions => {:domain => /^admin.*$/}) route_set.add_route('/sample', :controller => 'sample', :action => 'action2', :conditions => {:domain => 'www.host.com'}) target_route.paths.include?(route_set.recognize(build_request({:method => 'get', :path => '/sample', :domain => 'admin.host.com'})).first).should == true end + it "should recognize a format-style variable" do + target_route = route_set.add_route('/sample.:format', :controller => 'sample', :action => 'action') + route_set.recognize(build_request({:method => 'get', :path => '/sample.html', :domain => 'admin.host.com'})).should == [target_route.paths.first, [[:format , 'html']]] + end + + it "should recognize a format-style literal" do + target_route = route_set.add_route(':action.html', :controller => 'sample', :action => 'action') + route_set.recognize(build_request({:method => 'get', :path => '/sample.html', :domain => 'admin.host.com'})).should == [target_route.paths.first, [[:action , 'sample']]] + end + + it "should recognize a format-style variable along side another variable" do + target_route = route_set.add_route(':action.:format', :controller => 'sample', :action => 'action') + route_set.recognize(build_request({:method => 'get', :path => '/sample.html', :domain => 'admin.host.com'})).should == [target_route.paths.first, [[:action , 'sample'], [:format, 'html']]] + end + it "should recognize a specific route when several http-style restrictions are used" do target_route_http_admin = route_set.add_route('/sample', :controller => 'sample', :action => 'action', :conditions => {:protocol => 'http', :domain => 'admin.spec.com'}) target_route_http_www = route_set.add_route('/sample', :controller => 'sample', :action => 'action', :conditions => {:protocol => 'http', :domain => 'www.spec.com'}) target_route_https_msie = route_set.add_route('/sample', :controller => 'sample', :action => 'action2', :conditions => {:protocol => 'https', :user_agent => 'MSIE 6.0'}) target_route_https_admin = route_set.add_route('/sample', :controller => 'sample', :action => 'action2', :conditions => {:protocol => 'https', :domain => 'admin.spec.com'}) \ No newline at end of file