Skip to content

Commit bb046eb

Browse files
authored
Merge pull request #1289 from rubocop/default-styles-on-top
Move enforced styles to top in docs
2 parents 54ee974 + c8246f6 commit bb046eb

File tree

3 files changed

+41
-41
lines changed

3 files changed

+41
-41
lines changed

docs/modules/ROOT/pages/cops_rspec.adoc

+23-23
Original file line numberDiff line numberDiff line change
@@ -1528,17 +1528,6 @@ This cop can be configured using the `EnforcedStyle` option.
15281528

15291529
=== Examples
15301530

1531-
==== `EnforcedStyle: block`
1532-
1533-
[source,ruby]
1534-
----
1535-
# bad
1536-
expect { run }.to change(Foo, :bar)
1537-
1538-
# good
1539-
expect { run }.to change { Foo.bar }
1540-
----
1541-
15421531
==== `EnforcedStyle: method_call` (default)
15431532

15441533
[source,ruby]
@@ -1555,6 +1544,17 @@ expect { run }.to change { Foo.bar(:count) }
15551544
expect { run }.to change { user.reload.name }
15561545
----
15571546

1547+
==== `EnforcedStyle: block`
1548+
1549+
[source,ruby]
1550+
----
1551+
# bad
1552+
expect { run }.to change(Foo, :bar)
1553+
1554+
# good
1555+
expect { run }.to change { Foo.bar }
1556+
----
1557+
15581558
=== Configurable attributes
15591559

15601560
|===
@@ -3810,34 +3810,34 @@ This cop can be configured using the `EnforcedStyle` option
38103810

38113811
=== Examples
38123812

3813-
==== `EnforcedStyle: block`
3813+
==== `EnforcedStyle: and_return` (default)
38143814

38153815
[source,ruby]
38163816
----
38173817
# bad
3818-
allow(Foo).to receive(:bar).and_return("baz")
3819-
expect(Foo).to receive(:bar).and_return("baz")
3820-
3821-
# good
38223818
allow(Foo).to receive(:bar) { "baz" }
38233819
expect(Foo).to receive(:bar) { "baz" }
3820+
3821+
# good
3822+
allow(Foo).to receive(:bar).and_return("baz")
3823+
expect(Foo).to receive(:bar).and_return("baz")
38243824
# also good as the returned value is dynamic
3825-
allow(Foo).to receive(:bar).and_return(bar.baz)
3825+
allow(Foo).to receive(:bar) { bar.baz }
38263826
----
38273827

3828-
==== `EnforcedStyle: and_return` (default)
3828+
==== `EnforcedStyle: block`
38293829

38303830
[source,ruby]
38313831
----
38323832
# bad
3833-
allow(Foo).to receive(:bar) { "baz" }
3834-
expect(Foo).to receive(:bar) { "baz" }
3835-
3836-
# good
38373833
allow(Foo).to receive(:bar).and_return("baz")
38383834
expect(Foo).to receive(:bar).and_return("baz")
3835+
3836+
# good
3837+
allow(Foo).to receive(:bar) { "baz" }
3838+
expect(Foo).to receive(:bar) { "baz" }
38393839
# also good as the returned value is dynamic
3840-
allow(Foo).to receive(:bar) { bar.baz }
3840+
allow(Foo).to receive(:bar).and_return(bar.baz)
38413841
----
38423842

38433843
=== Configurable attributes

lib/rubocop/cop/rspec/expect_change.rb

+7-7
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,6 @@ module RSpec
1010
#
1111
# This cop can be configured using the `EnforcedStyle` option.
1212
#
13-
# @example `EnforcedStyle: block`
14-
# # bad
15-
# expect { run }.to change(Foo, :bar)
16-
#
17-
# # good
18-
# expect { run }.to change { Foo.bar }
19-
#
2013
# @example `EnforcedStyle: method_call` (default)
2114
# # bad
2215
# expect { run }.to change { Foo.bar }
@@ -29,6 +22,13 @@ module RSpec
2922
# expect { run }.to change { Foo.bar(:count) }
3023
# expect { run }.to change { user.reload.name }
3124
#
25+
# @example `EnforcedStyle: block`
26+
# # bad
27+
# expect { run }.to change(Foo, :bar)
28+
#
29+
# # good
30+
# expect { run }.to change { Foo.bar }
31+
#
3232
class ExpectChange < Base
3333
extend AutoCorrector
3434
include ConfigurableEnforcedStyle

lib/rubocop/cop/rspec/return_from_stub.rb

+11-11
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,6 @@ module RSpec
1111
#
1212
# This cop can be configured using the `EnforcedStyle` option
1313
#
14-
# @example `EnforcedStyle: block`
15-
# # bad
16-
# allow(Foo).to receive(:bar).and_return("baz")
17-
# expect(Foo).to receive(:bar).and_return("baz")
18-
#
19-
# # good
20-
# allow(Foo).to receive(:bar) { "baz" }
21-
# expect(Foo).to receive(:bar) { "baz" }
22-
# # also good as the returned value is dynamic
23-
# allow(Foo).to receive(:bar).and_return(bar.baz)
24-
#
2514
# @example `EnforcedStyle: and_return` (default)
2615
# # bad
2716
# allow(Foo).to receive(:bar) { "baz" }
@@ -33,6 +22,17 @@ module RSpec
3322
# # also good as the returned value is dynamic
3423
# allow(Foo).to receive(:bar) { bar.baz }
3524
#
25+
# @example `EnforcedStyle: block`
26+
# # bad
27+
# allow(Foo).to receive(:bar).and_return("baz")
28+
# expect(Foo).to receive(:bar).and_return("baz")
29+
#
30+
# # good
31+
# allow(Foo).to receive(:bar) { "baz" }
32+
# expect(Foo).to receive(:bar) { "baz" }
33+
# # also good as the returned value is dynamic
34+
# allow(Foo).to receive(:bar).and_return(bar.baz)
35+
#
3636
class ReturnFromStub < Base
3737
extend AutoCorrector
3838
include ConfigurableEnforcedStyle

0 commit comments

Comments
 (0)