File tree Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -404,6 +404,8 @@ Prefer negated matchers over `to change.by(0)`.
404
404
# bad
405
405
expect { run }.to change(Foo, :bar).by(0)
406
406
expect { run }.to change { Foo.bar }.by(0)
407
+
408
+ # bad - compound expectations
407
409
expect { run }
408
410
.to change(Foo, :bar).by(0)
409
411
.and change(Foo, :baz).by(0)
@@ -414,6 +416,9 @@ expect { run }
414
416
# good
415
417
expect { run }.not_to change(Foo, :bar)
416
418
expect { run }.not_to change { Foo.bar }
419
+
420
+ # good - compound expectations
421
+ define_negated_matcher :not_change, :change
417
422
expect { run }
418
423
.to not_change(Foo, :bar)
419
424
.and not_change(Foo, :baz)
Original file line number Diff line number Diff line change @@ -9,6 +9,8 @@ module RSpec
9
9
# # bad
10
10
# expect { run }.to change(Foo, :bar).by(0)
11
11
# expect { run }.to change { Foo.bar }.by(0)
12
+ #
13
+ # # bad - compound expectations
12
14
# expect { run }
13
15
# .to change(Foo, :bar).by(0)
14
16
# .and change(Foo, :baz).by(0)
@@ -19,6 +21,9 @@ module RSpec
19
21
# # good
20
22
# expect { run }.not_to change(Foo, :bar)
21
23
# expect { run }.not_to change { Foo.bar }
24
+ #
25
+ # # good - compound expectations
26
+ # define_negated_matcher :not_change, :change
22
27
# expect { run }
23
28
# .to not_change(Foo, :bar)
24
29
# .and not_change(Foo, :baz)
You can’t perform that action at this time.
0 commit comments