rspec/rspec-expectations — pull request #405 by sferik (2014-01-03 21:30:40+00:00)
Title: Add RSpec::Matchers::BuiltIn::BeBetween

Ruby’s `#between?` instance method is included in the `Comparable` module.
Any object that mixes in `Comparable` and responds to the `<=>` operator
will also respond to `#between?`, including the following core classes:

* `Numeric` (`Fixnum`, `Bignum`, `Integer`, `Float`, `Complex`, and `Rational`)
* `String`
* `Symbol`
* `Time`

...as well as a few lesser-used ones (e.g. `File::Stat`, `Gem::Version`).

`BeBetween` defines a matcher that takes exactly two arguments—a minimum
and a maximum value—mimicking the interface of `Comparable.html#between?`
and ensuring backward compatibility.

Before this patch, using `be_between` on `Comparable` objects worked but
produced the following failure message:

expected between?(1, 10) to return true, got false

After this patch, it will produce this message, instead:

expected 5 to be between 1 and 10

I believe this is a much more informative failure message, as it reveals
the actual value, which is often a variable, in addition to displaying
the expectation in plainer English.