rails/rails — pull request #13938 by marcandre (2014-02-04 07:36:18+00:00)
Title: Sized enumerator

This PR adds a lazy size block to enumerators returns by `Batches#find_each`, `find_in_batches`, `Result#each` and `Enumerable#index_by`.

This allows, for example (using my [gem `with_progress`](https://github.com/marcandre/with_progress))

Users.where("balance > 0").find_each.with_progress do |u|
UserMailer.send_invoice(u)
end

This will print a progress bar with an estimated time left, etc, while still loading the records in batches.

The PR also has a couple of test cleanup commits at the beginning.