How do I `expect` something which raises exception in RSpec?

You can chain positive assertions with and. If you want to mix in a negated one in the chain, RSpec 3.1 introduced define_negated_matcher.

You could do something like:

RSpec::Matchers.define_negated_matcher :not_change, :change

expect { eat(what: nil) }
  .to raise_error
  .and not_change(cat, :status)

Inspired by this comment.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)