On Wed, Sep 3, 2008 at 6:56 AM, Bart Zonneveld <[EMAIL PROTECTED]> wrote: > Hey list, > > I found myself trying to verify there are some non-checked checkboxes in a > template today, and am kinda stumped how to do it :). > A checked checkbox is easy, > have_tag('input[type=checkbox][checked=checked]). But, an unchecked checkbox > hasn't got the checked attribute at all. And as it so happens, I want to > test for a number of checked, and a number of unchecked checkboxes. So, just > testing for input[type=checkbox] would return the number of checked *and* > unchecked checkboxes.. > > any ideas?
Let's say you want 10 checked and 5 unchecked. You could do this: response.should have_tag("input[type=checkbox]", 15) response.should have_tag("input[type=checkbox][checked=checked]", 10) It's not perfectly expressive, but a good example name would help: it "should have 15 checkboxes, 10 checked, 5 unchecked" do render "/path/to/file" response.should have_tag("input[type=checkbox]", 15) response.should have_tag("input[type=checkbox][checked=checked]", 10) end WDYT? > bartz > ps: that's prolly the most occurences of 'check' in a single email... > _______________________________________________ > rspec-users mailing list > rspec-users@rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users