From faee12d5af7182e8aca0e44faee149d289a6dfa0 Mon Sep 17 00:00:00 2001 From: Pratik Naik Date: Wed, 10 Sep 2008 19:32:41 +0100 Subject: Fix a typo in guide and change assertion style in examples --- .../assertions/routing_assertions.rb | 28 +++++++++++----------- railties/doc/guides/routing/routing_outside_in.txt | 12 +++++----- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/actionpack/lib/action_controller/assertions/routing_assertions.rb b/actionpack/lib/action_controller/assertions/routing_assertions.rb index 312b4e228b..8a837c592c 100644 --- a/actionpack/lib/action_controller/assertions/routing_assertions.rb +++ b/actionpack/lib/action_controller/assertions/routing_assertions.rb @@ -10,32 +10,32 @@ module ActionController # and a :method containing the required HTTP verb. # # # assert that POSTing to /items will call the create action on ItemsController - # assert_recognizes({:controller => 'items', :action => 'create'}, {:path => 'items', :method => :post}) + # assert_recognizes {:controller => 'items', :action => 'create'}, {:path => 'items', :method => :post} # # You can also pass in +extras+ with a hash containing URL parameters that would normally be in the query string. This can be used # to assert that values in the query string string will end up in the params hash correctly. To test query strings you must use the # extras argument, appending the query string on the path directly will not work. For example: # # # assert that a path of '/items/list/1?view=print' returns the correct options - # assert_recognizes({:controller => 'items', :action => 'list', :id => '1', :view => 'print'}, 'items/list/1', { :view => "print" }) + # assert_recognizes {:controller => 'items', :action => 'list', :id => '1', :view => 'print'}, 'items/list/1', { :view => "print" } # # The +message+ parameter allows you to pass in an error message that is displayed upon failure. # # ==== Examples # # Check the default route (i.e., the index action) - # assert_recognizes({:controller => 'items', :action => 'index'}, 'items') + # assert_recognizes {:controller => 'items', :action => 'index'}, 'items' # # # Test a specific action - # assert_recognizes({:controller => 'items', :action => 'list'}, 'items/list') + # assert_recognizes {:controller => 'items', :action => 'list'}, 'items/list' # # # Test an action with a parameter - # assert_recognizes({:controller => 'items', :action => 'destroy', :id => '1'}, 'items/destroy/1') + # assert_recognizes {:controller => 'items', :action => 'destroy', :id => '1'}, 'items/destroy/1' # # # Test a custom route - # assert_recognizes({:controller => 'items', :action => 'show', :id => '1'}, 'view/item1') + # assert_recognizes {:controller => 'items', :action => 'show', :id => '1'}, 'view/item1' # # # Check a Simply RESTful generated route - # assert_recognizes(list_items_url, 'items/list') + # assert_recognizes list_items_url, 'items/list' def assert_recognizes(expected_options, path, extras={}, message=nil) if path.is_a? Hash request_method = path[:method] @@ -67,13 +67,13 @@ module ActionController # # ==== Examples # # Asserts that the default action is generated for a route with no action - # assert_generates("/items", :controller => "items", :action => "index") + # assert_generates "/items", :controller => "items", :action => "index" # # # Tests that the list action is properly routed - # assert_generates("/items/list", :controller => "items", :action => "list") + # assert_generates "/items/list", :controller => "items", :action => "list" # # # Tests the generation of a route with a parameter - # assert_generates("/items/list/1", { :controller => "items", :action => "list", :id => "1" }) + # assert_generates "/items/list/1", { :controller => "items", :action => "list", :id => "1" } # # # Asserts that the generated route gives us our custom route # assert_generates "changesets/12", { :controller => 'scm', :action => 'show_diff', :revision => "12" } @@ -104,19 +104,19 @@ module ActionController # # ==== Examples # # Assert a basic route: a controller with the default action (index) - # assert_routing('/home', :controller => 'home', :action => 'index') + # assert_routing '/home', :controller => 'home', :action => 'index' # # # Test a route generated with a specific controller, action, and parameter (id) - # assert_routing('/entries/show/23', :controller => 'entries', :action => 'show', id => 23) + # assert_routing '/entries/show/23', :controller => 'entries', :action => 'show', id => 23 # # # Assert a basic route (controller + default action), with an error message if it fails - # assert_routing('/store', { :controller => 'store', :action => 'index' }, {}, {}, 'Route for store index not generated properly') + # assert_routing '/store', { :controller => 'store', :action => 'index' }, {}, {}, 'Route for store index not generated properly' # # # Tests a route, providing a defaults hash # assert_routing 'controller/action/9', {:id => "9", :item => "square"}, {:controller => "controller", :action => "action"}, {}, {:item => "square"} # # # Tests a route with a HTTP method - # assert_routing({ :method => 'put', :path => '/product/321' }, { :controller => "product", :action => "update", :id => "321" }) + # assert_routing { :method => 'put', :path => '/product/321' }, { :controller => "product", :action => "update", :id => "321" } def assert_routing(path, options, defaults={}, extras={}, message=nil) assert_recognizes(options, path, extras, message) diff --git a/railties/doc/guides/routing/routing_outside_in.txt b/railties/doc/guides/routing/routing_outside_in.txt index 8bad4e0673..1a4b1a9530 100644 --- a/railties/doc/guides/routing/routing_outside_in.txt +++ b/railties/doc/guides/routing/routing_outside_in.txt @@ -801,8 +801,8 @@ Use +assert_generates+ to assert that a particular set of options generate a par [source, ruby] ------------------------------------------------------- -assert_generates("/photos/1", { :controller => "photos", :action => "show", :id => "1" }) -assert_generates("/about", :controller => "pages", :action => "about") +assert_generates "/photos/1", { :controller => "photos", :action => "show", :id => "1" } +assert_generates "/about", :controller => "pages", :action => "about" ------------------------------------------------------- ==== The +assert_recognizes+ Assertion @@ -811,21 +811,21 @@ The +assert_recognizes+ assertion is the inverse of +assert_generates+. It asser [source, ruby] ------------------------------------------------------- -assert_recognizes({ :controller => "photos", :action => "show", :id => "1" }, "/photos/1") +assert_recognizes { :controller => "photos", :action => "show", :id => "1" }, "/photos/1" ------------------------------------------------------- You can supply a +:method+ argument to specify the HTTP verb: [source, ruby] ------------------------------------------------------- -assert_recognizes({ :controller => "photos", :action => "create" }, { :path => "photos", :method => :post }) +assert_recognizes { :controller => "photos", :action => "create" }, { :path => "photos", :method => :post } ------------------------------------------------------- You can also use the RESTful helpers to test recognition of a RESTful route: [source, ruby] ------------------------------------------------------- -assert_recognizes(new_photo_url, { :path => "photos", :method => :post }) +assert_recognizes new_photo_url, { :path => "photos", :method => :post } ------------------------------------------------------- ==== The +assert_routing+ Assertion @@ -834,5 +834,5 @@ The +assert_routing+ assertion checks the route both ways: it tests that the pat [source, ruby] ------------------------------------------------------- -assert_recognizes({ :path => "photos", :method => :post }, { :controller => "photos", :action => "create" }) +assert_routing { :path => "photos", :method => :post }, { :controller => "photos", :action => "create" } ------------------------------------------------------- \ No newline at end of file -- cgit v1.2.3