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…
-
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.
is not true. -
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.
is not true. -
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.
is not true. -
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:
“\n\n\n\tRegister\n\t<link
href=”/stylesheets/site.css?1199235828" media=“screen”
rel=“stylesheet” type=“text/css” />\n\n\n\t<div
id=“whole_page”>\n\t\t<div id=“header”>RailsSpace\n\t\t<div
id=“nav”>\n\t\t\t<a href="/">Home |\n\t\t\t<a
href="/site/about">About Us |\n\t\t\t<a
href="/site/help">Help |\n\t\t\tRegister\n\t\t\n\t\t<div
id=“content”>\t\n\t\t\t\t\n\t\t\tRegister
\n<form
action="/user/register" method=“post”>\n\n Enter
Your Details \n \n <div class=“form_row”> \n<label
for=“screen_name”>Screen name:\n<input id=“user_screen_name”
maxlength=“20” name=“user[screen_name]” size=“20” type=“text”
/>\n\n <div class=“form_row”> \n<label
for=“email”>Email:\n<input id=“user_email” maxlength=“50”
name=“user[email]” size=“30” type=“text” />\n\n <div
class=“form_row”> \n<label for=“password”>Password:\n<input
id=“user_password” maxlength=“40” name=“user[password]”
size=“10” type=“text” />\n\n\n <div class=“form_row”> \n
<input class=“submit” name=“commit” type=“submit”
value=“Register!” /> \n \n
\n\n\t\t\t\n\t\t\n\t\n\n".
is not true.