# Problems with assert\_select

**URL:** <https://www.ruby-forum.com/t/problems-with-assert-select/110578>\
**Category:** Rails\
**Created:** [July 27, 2007, 7:09pm UTC](https://www.ruby-forum.com/t/problems-with-assert-select/110578 "2007-07-27T19:09:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bnab](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/7ea924/32.png) [@bnab](https://www.ruby-forum.com/u/bnab)\
**Post date:** [July 27, 2007, 7:09pm UTC](https://www.ruby-forum.com/t/problems-with-assert-select/110578/1 "2007-07-27T19:09:23Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![bnab](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/7ea924/32.png) [@bnab](https://www.ruby-forum.com/u/bnab)\
**Post date:** [July 27, 2007, 8:01pm UTC](https://www.ruby-forum.com/t/problems-with-assert-select/110578/2 "2007-07-27T20:01:30Z")

</div>

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…
