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