Skip to content

Commit 0dff833

Browse files
authored
Merge pull request #1293 from kuboon/patch-1
Better explanation for MessageSpies
2 parents d6c507b + 52bc397 commit 0dff833

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

docs/modules/ROOT/pages/cops_rspec.adoc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2683,8 +2683,11 @@ This cop can be configured in your configuration using the
26832683
----
26842684
# bad
26852685
expect(foo).to receive(:bar)
2686+
do_something
26862687
26872688
# good
2689+
allow(foo).to receive(:bar) # or use instance_spy
2690+
do_something
26882691
expect(foo).to have_received(:bar)
26892692
----
26902693

@@ -2693,10 +2696,13 @@ expect(foo).to have_received(:bar)
26932696
[source,ruby]
26942697
----
26952698
# bad
2699+
allow(foo).to receive(:bar)
2700+
do_something
26962701
expect(foo).to have_received(:bar)
26972702
26982703
# good
26992704
expect(foo).to receive(:bar)
2705+
do_something
27002706
----
27012707

27022708
=== Configurable attributes

lib/rubocop/cop/rspec/message_spies.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,23 @@ module RSpec
1212
#
1313
# # bad
1414
# expect(foo).to receive(:bar)
15+
# do_something
1516
#
1617
# # good
18+
# allow(foo).to receive(:bar) # or use instance_spy
19+
# do_something
1720
# expect(foo).to have_received(:bar)
1821
#
1922
# @example `EnforcedStyle: receive`
2023
#
2124
# # bad
25+
# allow(foo).to receive(:bar)
26+
# do_something
2227
# expect(foo).to have_received(:bar)
2328
#
2429
# # good
2530
# expect(foo).to receive(:bar)
31+
# do_something
2632
#
2733
class MessageSpies < Base
2834
include ConfigurableEnforcedStyle

0 commit comments

Comments
 (0)