Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 8284

Show
Ignore:
Timestamp:
12/05/07 14:40:42 (9 months ago)
Author:
marcel
Message:

Add examples in the documentation for various assertions. Closes #9938 [zapnap]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/actionpack/CHANGELOG

    r8283 r8284  
    11*SVN* 
     2 
     3* Add examples in the documentation for various assertions. Closes #9938 [zapnap] 
    24 
    35* When a NonInferrableControllerError is raised, make the proposed fix clearer in the error message. Closes #10199 [danger] 
  • trunk/actionpack/lib/action_controller/assertions/dom_assertions.rb

    r7437 r8284  
    33    module DomAssertions 
    44      # Test two HTML strings for equivalency (e.g., identical up to reordering of attributes) 
     5      # 
     6      # ==== Examples 
     7      # 
     8      #   # assert that the referenced method generates the appropriate HTML string 
     9      #   assert_dom_equal '<a href="http://www.example.com">Apples</a>', link_to("Apples", "http://www.example.com") 
     10      # 
    511      def assert_dom_equal(expected, actual, message = "") 
    612        clean_backtrace do 
     
    1420       
    1521      # The negated form of +assert_dom_equivalent+. 
     22      # 
     23      # ==== Examples 
     24      # 
     25      #   # assert that the referenced method does not generate the specified HTML string 
     26      #   assert_dom_not_equal '<a href="http://www.example.com">Apples</a>', link_to("Oranges", "http://www.example.com") 
     27      # 
    1628      def assert_dom_not_equal(expected, actual, message = "") 
    1729        clean_backtrace do 
  • trunk/actionpack/lib/action_controller/assertions/model_assertions.rb

    r6470 r8284  
    33    module ModelAssertions 
    44      # Ensures that the passed record is valid by ActiveRecord standards and returns any error messages if it is not. 
     5      # 
     6      # ==== Examples 
     7      # 
     8      #   # assert that a newly created record is valid 
     9      #   model = Model.new 
     10      #   assert_valid(model) 
     11      # 
    512      def assert_valid(record) 
    613        clean_backtrace do 
  • trunk/actionpack/lib/action_controller/assertions/response_assertions.rb

    r8106 r8284  
    1515      # or its symbolic equivalent assert_response(:not_implemented). 
    1616      # See ActionController::StatusCodes for a full list. 
     17      # 
     18      # ==== Examples 
     19      # 
     20      #   # assert that the response was a redirection 
     21      #   assert_response :redirect  
     22      # 
     23      #   # assert that the response code was status code 401 (unauthorized) 
     24      #   assert_response 401 
     25      # 
    1726      def assert_response(type, message = nil) 
    1827        clean_backtrace do 
     
    2938      end 
    3039 
    31       # Assert that the redirection options passed in match those of the redirect called in the latest action. This match can be partial, 
    32       # such that assert_redirected_to(:controller => "weblog") will also match the redirection of 
    33       # redirect_to(:controller => "weblog", :action => "show") and so on. 
     40      # Assert that the redirection options passed in match those of the redirect called in the latest action.  
     41      # This match can be partial, such that assert_redirected_to(:controller => "weblog") will also 
     42      # match the redirection of redirect_to(:controller => "weblog", :action => "show") and so on. 
     43      # 
     44      # ==== Examples 
     45      # 
     46      #   # assert that the redirection was to the "index" action on the WeblogController 
     47      #   assert_redirected_to :controller => "weblog", :action => "index" 
     48      # 
     49      #   # assert that the redirection was to the named route login_url 
     50      #   assert_redirected_to login_url 
     51      # 
    3452      def assert_redirected_to(options = {}, message=nil) 
    3553        clean_backtrace do 
     
    105123 
    106124      # Asserts that the request was rendered with the appropriate template file. 
     125      # 
     126      # ==== Examples 
     127      # 
     128      #   # assert that the "new" view template was rendered 
     129      #   assert_template "new" 
     130      # 
    107131      def assert_template(expected = nil, message=nil) 
    108132        clean_backtrace do