RSpec: Is there a not for `and change`, e.g. `and_not to change`?

No, there is no and_not and no general negation operator, as discussed in https://github.com/rspec/rspec-expectations/issues/493

There is, however, a mechanism to define a negated version of an existing matcher, as described in http://www.rubydoc.info/github/rspec/rspec-expectations/RSpec/Matchers.define_negated_matcher, which you can use with and.

The full set of compound matchers is documented at https://www.relishapp.com/rspec/rspec-expectations/v/3-4/docs/compound-expectations

Leave a Comment