rspec/rspec-expectations — Issue #109: Sticky matcher chain methods
Author: laserlemon
Created: 2012-01-22 15:42:58+00:00
State: open

This is an example from the rspec-expectations source:

```rb
RSpec::Matchers.define :have_errors_on do |key|
chain :with do |message|
@message = message
end

match do |actual|
actual.errors[key] == @message
end
end
```

The problem is that if this matcher is used twice, the `@message` seems to stick around from the first invocation. Is there a way to avoid that and make sure the chained attributes are cleared out between uses?