jnicklas/capybara — pull request #1232 by tmertens (2014-01-17 22:05:55+00:00)
Title: Enable use of count query options with Capybara::Node::Finders#all

This resolves https://github.com/jnicklas/capybara/issues/1231 and https://github.com/natritmeyer/site_prism/issues/57

This PR enables the use of count query options [:count, :maximum, :minimum, :between] with the Capybara::Node::Finders#all method.

These changes maintain backwards compatibility. All original capybara specs are passing in their original form, and new specs have been added to validate the new behavior for Capybara::Node::Finders#all()

This enables users to specify expectations on the number of elements to be found by their query, without first using assertions such as `has_css?('a', :count=>5)` before attempting to interact with the desired element array.

The following queries which use to ignore the options values will now only succeed if the expectation is met:

```ruby
# Where :css is the default
page.all('.result-row',:count=>10)
page.all('.result-row',:minimum=>5)
page.all('.result-row',:maximum=>25)
page.all('.result-row',:between=>1..10)
```

Not that anyone really needs this functionality, but you can also now combine query options and the query will only succeed if all expectations are met. This, however, does not apply to the :count option. If :count is specified, all other options will be ignored.

```ruby
# This could be also written with :between
page.all('.result-row', :minimum=>5, :maximum=>10)
# This would always fail:
page.all('.result-row', :minimum=>11, :maximum=>10)
# Only :count is evaluated:
page.all('.result-row', :count=>7, :minimum=>8, :maximum=>6)
```