Created
January 23, 2018 00:09
-
-
Save rrcobb/8f12d51e2d1628068d2f51ce398c1d7a to your computer and use it in GitHub Desktop.
Rspec negated change matcher
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This should be in rspec core, but add it here so we can chain negative change expectations, like | |
# expect { do_thing }.to change {a}.and not_change {b}.and change {b} | |
RSpec::Matchers.define_negated_matcher :not_change, :change |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When expecting multiple things to happen given some code block, sometimes you want some things not to change. This is annoying with the default matchers in rspec, so define this in an rspec initializer.