rspec/rspec-expectations — pull request #477 by myronmarston (2014-02-22 23:28:13+00:00)
Title: Fix do end blocks

This fixes #137.

As discussed in that issue, `be_xyz` predicate matchers didn't support `do...end` blocks properly. This fixes.

I had also commented there that `change` needs a fix here as well, but after looking into it some more, I've concluded that it's OK as is. For `change` we raise an error if `do ... end` is used to provide the block, because we can't support the chainable `by`, `to`, `from`, etc, expressions off of a `do...end` block. That's because in an expression like:

``` ruby
expect do
do_something
end.to change do
foo
end.by(3)
```
...ruby sends the `by` message to the return value of `expect().to(matcher)`, at which point it is too late for it to apply to the matcher. Given that, I think it's best if we don't support the `do...end` form for `change` at all. The other change matcher classes don't prevent the do...end block but you can only get instances of those classes by using the chainable methods like `by`, so we already know that no `do...end` block has been passed by the time we get there. So, nothing to do for `change` :).

/cc @xaviershay