# Assert\_select with count 0

**URL:** <https://www.ruby-forum.com/t/assert-select-with-count-0/159273>\
**Category:** Rails\
**Created:** [February 2, 2009, 11:06pm UTC](https://www.ruby-forum.com/t/assert-select-with-count-0/159273 "2009-02-02T23:06:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![aawilson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e495f1/32.png) [@aawilson](https://www.ruby-forum.com/u/aawilson)\
**Post date:** [February 2, 2009, 11:06pm UTC](https://www.ruby-forum.com/t/assert-select-with-count-0/159273/1 "2009-02-02T23:06:04Z")

</div>

Hello, all. This is short and simple. I have this statement in a  
functional test:

assert\_select ‘input’ do  
assert\_select “[name=?]”, {:count =\> 0,:text =\>/areas[1]/}  
end  
This assertion gives me the following:

1. Failure:  
test\_areas(SampleControllerTest)  
[c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action\_controller/asse  
rtions/selector\_assertions.rb:281:in `assert_select' test/functional/sample_controller_test.rb:315:in`test\_areas’  
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action\_controller/asse  
rtions/selector\_assertions.rb:294:in `assert_select' test/functional/sample_controller_test.rb:312:in`test\_areas’]:  
Expected at least 1 elements, found 0.  
 is not true.

Since I’ve explicitly used :count =\> 0, I can’t for the life of me  
figure out why it’s expecting at least 1 element. I’m certain that this  
is the source of the failure, and not something else in the test,  
because I have achieved success by commenting only the line with  
assert\_select “[name=?]”, {:count =\> 0,:text =\>/areas[1]/}.

Thanks in advance for your time.

---

<div class="post-metadata">

**Author:** ![aawilson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e495f1/32.png) [@aawilson](https://www.ruby-forum.com/u/aawilson)\
**Post date:** [February 3, 2009, 5:13pm UTC](https://www.ruby-forum.com/t/assert-select-with-count-0/159273/2 "2009-02-03T17:13:21Z")

</div>

Hello, again. I just wanted to post this here for the future help of  
anyone searching the archives.

This works:

assert\_select ["[name=?]", “areas[1]”], {:count =\> 0}

Evidently, the areas[1] is a part of the selector (which can be  
specified as an array), and not the “text” value of the hash.

Cheers.

Aa Wilson wrote:

> Hello, all. This is short and simple. I have this statement in a  
> functional test:
> 
> assert\_select ‘input’ do  
> assert\_select “[name=?]”, {:count =\> 0,:text =\>/areas[1]/}  
> end  
> This assertion gives me the following:
> 
> 1. Failure:  
> test\_areas(SampleControllerTest)  
> [c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action\_controller/asse  
> rtions/selector\_assertions.rb:281:in `assert_select' test/functional/sample_controller_test.rb:315:in`test\_areas’  
> c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action\_controller/asse  
> rtions/selector\_assertions.rb:294:in `assert_select' test/functional/sample_controller_test.rb:312:in`test\_areas’]:  
> Expected at least 1 elements, found 0.  
> is not true.
> 
> Since I’ve explicitly used :count =\> 0, I can’t for the life of me  
> figure out why it’s expecting at least 1 element. I’m certain that this  
> is the source of the failure, and not something else in the test,  
> because I have achieved success by commenting only the line with  
> assert\_select “[name=?]”, {:count =\> 0,:text =\>/areas[1]/}.
> 
> Thanks in advance for your time.
