Forum: Ruby on Rails problems with assert_select

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
374b97c6fbdc2afdd4e5e4f1901edca2?d=identicon&s=25 Bryan Noll (Guest)
on 2007-07-27 19:09
(Received via mailing list)
I'm sure this is user error, so let me describe it real quick.

So, I'm in a functional test, and this line exists in the body of the
response:

<div id="div_nick_name" class='nav_item'>foo</div>


I'm attempting to do this in the test:

  assert_select "div#div_nick_name"
  assert_select "div#div_nick_name" "foo"

My intent in case it's not obvious is to test that the content of the
div is equal to 'foo'.  The first of those two lines works, the second
results in:

############################
  1) Failure:
test_xss_using_nick_name(UsersControllerTest)

[/home/bnoll/tools/jruby-1.0/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/assertions/selector_assertions.rb:282:in
`_wrap_assertion'

/home/bnoll/tools/jruby-1.0/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/assertions/selector_assertions.rb:282:in
`assert_select'

/home/bnoll/projects/openlogic/olex-trunk/test/functional/users_controller_test.rb:30:in
`test_xss_using_nick_name']:
Expected at least 1 elements, found 0.
<false> is not true.

5 tests, 7 assertions, 1 failures, 0 errors
rake aborted!
Command failed with status (1): [/home/bnoll/tools/jruby-1.0/bin/jruby
-Ili...]

############################


I'm a newb to rails, so I'm hoping this will be obvious to someone a bit
more seasoned.

TIA...

Bryan
374b97c6fbdc2afdd4e5e4f1901edca2?d=identicon&s=25 Bryan Noll (Guest)
on 2007-07-27 20:01
(Received via mailing list)
I'll answer my own question in case someone else out there is as much of
a moron as me and could use it to help them...

assert_select "div#div_nick_name", "foo"

Notice the comma...
This topic is locked and can not be replied to.