Upgraded to RoR 2.0 on Mac OS X -
and cannot seem to get assert_select or the supposedly deprecated
assert_tag to work. - Asserts are fairly simple and so is the page being
tested - see below for HTML and different errors.
Any help is greatly appreciated!
thanks
Jim.
class UserControllerTest < Test::Unit::TestCase
def setup
@controller = UserController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
end
# Make sure the registration page responds with the proper form.
# Make sure the registration page responds with the proper form.
def test_registration_page
get :register
title = assigns(:title)
assert_equal "Register", title
assert_response :success
assert_template "register"
# NONE OF THESE WORK....
assert_select "title", "Register"
assert_select "form"
assert_select "form[action=/user/register]"
assert_tag "form", :attributes => { :action =>
"/user/register",
:method => "post" }
end
end
None of the 4 assert_* at the end work...
These are the errors I get as I rotate the asserts...
1) Failure:
test_registration_page(UserControllerTest)
[/opt/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/assertions/selector_assertions.rb:296:in
`assert_select''
./test/functional/user_controller_test.rb:24:in
`test_registration_page'']:
Expected at least 1 element matching "title", found 0.
<false> is not true.
1) Failure:
test_registration_page(UserControllerTest)
[/opt/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/assertions/selector_assertions.rb:296:in
`assert_select''
./test/functional/user_controller_test.rb:24:in
`test_registration_page'']:
Expected at least 1 element matching "form", found 0.
<false> is not true.
1) Failure:
test_registration_page(UserControllerTest)
[/opt/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/assertions/selector_assertions.rb:296:in
`assert_select''
./test/functional/user_controller_test.rb:24:in
`test_registration_page'']:
Expected at least 1 element matching
"form[action=''/user/register'']",
found 0.
<false> is not true.
1) Failure:
test_registration_page(UserControllerTest)
[./test/functional/user_controller_test.rb:24]:
expected tag, but no tag found matching {:tag=>"form",
:attributes=>{:action=>"/user/register",
:method=>"post"}} in:
"<!DOCTYPE HTML PUBLIC \"-//W3C/DTD XHTML 1.0 Strict//EN\"\n
http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n<html>\n<head>\n\t<title>Register</title>\n\t<link
href=\"/stylesheets/site.css?1199235828\" media=\"screen\"
rel=\"stylesheet\" type=\"text/css\"
/>\n</head>\n<body>\n\t<div
id=\"whole_page\">\n\t\t<div
id=\"header\">RailsSpace</div>\n\t\t<div
id=\"nav\">\n\t\t\t<a href=\"/\">Home</a>
|\n\t\t\t<a
href=\"/site/about\">About Us</a> |\n\t\t\t<a
href=\"/site/help\">Help</a>
|\n\t\t\tRegister\n\t\t</div>\n\t\t<div
id=\"content\">\t\n\t\t\t\t\n\t\t\t<h2>Register</h2>\n<form
action=\"/user/register\"
method=\"post\">\n<fieldset>\n <legend>Enter
Your Details</legend> \n \n <div class=\"form_row\">
\n<label
for=\"screen_name\">Screen name:</label>\n<input
id=\"user_screen_name\"
maxlength=\"20\" name=\"user[screen_name]\"
size=\"20\" type=\"text\"
/>\n</div>\n <div class=\"form_row\"> \n<label
for=\"email\">Email:</label>\n<input
id=\"user_email\" maxlength=\"50\"
name=\"user[email]\" size=\"30\" type=\"text\"
/>\n</div>\n <div
class=\"form_row\"> \n<label
for=\"password\">Password:</label>\n<input
id=\"user_password\" maxlength=\"40\"
name=\"user[password]\"
size=\"10\" type=\"text\" />\n</div>\n\n <div
class=\"form_row\"> \n
<input class=\"submit\" name=\"commit\"
type=\"submit\"
value=\"Register!\" /> \n </div>\n</fieldset>
\n</form>\n\t\t</div>\t\n\t\t\n\t</div>\n</body>\n</html>".
<nil> is not true.
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---