%(<form action="create" method="get"><p><label for="post_title">Title</label><br /><input id="post_title" name="post[title]" size="30" type="text" value="Hello World" /></p>\n<p><label for="post_body">Body</label><br /><div class="fieldWithErrors"><textarea cols="40" id="post_body" name="post[body]" rows="20">Back to the hill and over it again!</textarea></div></p><input name="commit" type="submit" value="Create" /></form>),
assert_dom_equal"<div class=\"formError\">can't be empty</div>",error_message_on(other_post,:author_name)
end
deftest_error_message_on_should_use_options
assert_dom_equal"<div class=\"differentError\">beforecan't be emptyafter</div>",error_message_on(:post,:author_name,"before","after","differentError")
deftest_error_message_on_with_options_hash
assert_dom_equal"<div class=\"differentError\">beforecan't be emptyafter</div>",error_message_on(:post,:author_name,:css_class=>'differentError',:prepend_text=>'before',:append_text=>'after')
assert_dom_equal%(<div class="errorExplanation" id="errorExplanation"><h2>2 errors prohibited this post from being saved</h2><p>There were problems with the following fields:</p><ul><li>User email can't be empty</li><li>Author name can't be empty</li></ul></div>),error_messages_for("user","post",:object_name=>"post")
# symbols work as well
assert_dom_equal%(<div class="errorExplanation" id="errorExplanation"><h2>2 errors prohibited this post from being saved</h2><p>There were problems with the following fields:</p><ul><li>User email can't be empty</li><li>Author name can't be empty</li></ul></div>),error_messages_for(:user,:post,:object_name=>:post)
# any default works too
assert_dom_equal%(<div class="errorExplanation" id="errorExplanation"><h2>2 errors prohibited this monkey from being saved</h2><p>There were problems with the following fields:</p><ul><li>User email can't be empty</li><li>Author name can't be empty</li></ul></div>),error_messages_for(:user,:post,:object_name=>"monkey")
message="Please fix the following fields and resubmit:"
assert_dom_equal%(<div class="errorExplanation" id="errorExplanation"><h2>#{header_message}</h2><p>#{message}</p><ul><li>User email can't be empty</li><li>Author name can't be empty</li></ul></div>),error_messages_for(:user,:post,:header_message=>header_message,:message=>message)
assert_dom_equal%(<div class="errorExplanation" id="errorExplanation"><h2>1 error prohibited this post from being saved</h2><p>There were problems with the following fields:</p><ul><li>Author name can't be empty</li></ul></div>),error_messages_for("post",:object=>actual_post)
#multiple objects
assert_dom_equal%(<div class="errorExplanation" id="errorExplanation"><h2>2 errors prohibited this user from being saved</h2><p>There were problems with the following fields:</p><ul><li>User email can't be empty</li><li>Author name can't be empty</li></ul></div>),error_messages_for("user","post",:object=>[actual_user,actual_post])