| 4 | | # test 2 html strings to be equivalent, i.e. identical up to reordering of attributes |
|---|
| | 7 | # Test two HTML or XML strings (<tt>expected</tt> and <tt>actual</tt>) to be equivalent (i.e., |
|---|
| | 8 | # identical up to the reordering of attributes). The <tt>message</tt> parameter allows you to |
|---|
| | 9 | # feed in a message that is displayed upon failure (useful if you want to make a note about what |
|---|
| | 10 | # part of the view isn't being rendered correctly). |
|---|
| | 11 | # |
|---|
| | 12 | # === Examples |
|---|
| | 13 | # # Asserts that a link generated by Rails to the Rails website is correct |
|---|
| | 14 | # assert_dom_equal "<a href=\"http://www.rubyonrails.com\">Rails</a>", link_to("Rails", "http://www.rubyonrails.com") |
|---|
| | 15 | # |
|---|
| | 16 | # # Asserts that a link to an action is generated properly; gives a custom error message if it's not |
|---|
| | 17 | # assert_dom_equal "<a href=\"account/login">Login</a>", link_to("Login", :action => 'login'), "Login link broken" |
|---|
| | 18 | # |
|---|
| | 19 | # # Tests that a text area tag generated properly |
|---|
| | 20 | # assert_dom_equal "<textarea name=\"body\" id="body"></textarea>", text_area_tag("body") |
|---|
| | 21 | # |
|---|
| | 22 | # # Asserts that a form tag is properly generated |
|---|
| | 23 | # assert_dom_equal " <form action=\"/posts\" method=\"post\"><div><input type=\"submit\" name=\"submit\" value=\"Save\" /></div></form>", |
|---|
| | 24 | # form_tag('/posts') { submit_tag 'Save' } |
|---|
| | 25 | # |
|---|
| | 26 | # # Asserts that JavaScript files are included properly, even when given different paths |
|---|
| | 27 | # assert_dom_equal "<script type=\"text/javascript\" src=\"/javascripts/xhr.js\"></script>", javascript_include_tag "xhr" |
|---|
| | 28 | # assert_dom_equal """<script type="text/javascript" src="/javascripts/corners.js"></script> |
|---|
| | 29 | # <script type=\"text/javascript" src=\"/shared/common.js\"></script>""", javascript_include_tag("corners.js", "/shared/common") |
|---|
| | 30 | # |
|---|
| | 31 | # # Tests for proper generation of an auto-discovery link for an action |
|---|
| | 32 | # assert_dom_equal "<link rel=\"alternate\" type=\"application/rss+xml\" title=\"RSS\" href=\"http://host.com/controller/feed\" />", |
|---|
| | 33 | # auto_discovery_link_tag(:rss, {:action => "feed"}, {:title => "RSS"}) |
|---|
| | 34 | # |
|---|
| | 35 | # # Asserts that a button to an action is generated correctly |
|---|
| | 36 | # assert_dom_equal """<form method=\"post\" action=\"/controller/visit/9\" class=\"button-to\"> |
|---|
| | 37 | # <div><input value=\"Go\" type=\"submit\" /></div> |
|---|
| | 38 | # </form>""", button_to("Go", :action => "visit", :id => 9) |
|---|
| | 39 | # |
|---|
| 14 | | # negated form of +assert_dom_equivalent+ |
|---|
| | 49 | # This is a negated form of #assert_dom_equivalent, that is, it tests that the HTML and/or XML strings are not equal. |
|---|
| | 50 | # |
|---|
| | 51 | # === Examples |
|---|
| | 52 | # # Asserts that the image path is picked up properly for an image tag |
|---|
| | 53 | # assert_dom_not_equal "<img src=\"images/my_assets/my_image.gif\">", image_tag("/my_assets/my_image.gif") |
|---|
| | 54 | # |
|---|
| | 55 | # # Asserts that a link to an action recognizes the route properly |
|---|
| | 56 | # assert_dom_not_equal "<a href=\"/home/index\">", link_to(:controller => 'home', :action => 'index') |
|---|
| | 57 | # |
|---|
| | 58 | # # Makes sure the custom path for a JavaScript link is correctly rendered |
|---|
| | 59 | # assert_dom_equal "<script type=\"text/javascript\" src=\"/javascripts/shared/nav.js\"></script>", javascript_include_tag "/shared/nav" |
|---|
| | 60 | # |
|---|
| | 61 | # # Tests that a custom route is recognized properly |
|---|
| | 62 | # assert_dom_not_equal "<a href=\"/user/home/1\">", link_to(:controller => 'user', :action => 'home', :id => 1) # => passes |
|---|
| | 63 | # assert_dom_equal "<a href=\"/user1\">", link_to(:controller => 'user', :action => 'home', :id => 1) # => passes |
|---|