Problems with assert_select


#1

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:

foo

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.
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


#2

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…