With Capybara, one can easily assert the exact amount of nodes to be found:
page.should have_selector("fieldset.has_many_fields input[type=file]", :count => 2)
This ensures that there are exactly 2 such fields. But I want to check for "at least 2". Something like:
page.all("fieldset.has_many_fields input[type=file]").count should be_greater_than 2
This is an example, because it throws undefined method 'greater_than?' for 3:Fixnum'
Is there a matcher like this? Or another trick that allows me to check for "at least N nodes"?
Unfortunately the answer from RobertH on 17th Jan 2013 is now depreciated syntax.
For this precise scenario you would need to do:
page.all("fieldset.has_many_fields input[type=file]", :minimum => 2)
I think you just have a typo. Try:
expect(page.all("fieldset.has_many_fields input[type=file]").count).to be > 2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With