Skip to content

Commit dbbef32

Browse files
authored
Merge pull request #1303 from edgibbs/add-inline-doc-examples-of-aggregate-failures
Document aggregate_failures behavior in MultipleExpectations cop
2 parents b6516ba + 455e336 commit dbbef32

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* Add new `RSpec/Capybara/SpecificMatcher` cop. ([@ydah][])
88
* Fixed false offense detection in `FactoryBot/CreateList` when a n.times block is including method calls in the factory create arguments. ([@ngouy][])
99
* Fix error in `RSpec/RSpec/FactoryBot/CreateList` cop for empty block. ([@tejasbubane][])
10+
* Update `RSpec/MultipleExpectations` cop documentation with examples of aggregate_failures use. ([@edgibbs][])
1011

1112
## 2.11.1 (2022-05-18)
1213

@@ -702,3 +703,4 @@ Compatibility release so users can upgrade RuboCop to 0.51.0. No new features.
702703
[@luke-hill]: https://github.com/luke-hill
703704
[@johnny-miyake]: https://github.com/johnny-miyake
704705
[@ngouy]: https://github.com/ngouy
706+
[@edgibbs]: https://github.com/edgibbs

docs/modules/ROOT/pages/cops_rspec.adoc

+26
Original file line numberDiff line numberDiff line change
@@ -2837,6 +2837,32 @@ describe UserCreator do
28372837
end
28382838
----
28392839

2840+
==== `aggregate_failures: true` (default)
2841+
2842+
[source,ruby]
2843+
----
2844+
# good - the cop ignores when RSpec aggregates failures
2845+
describe UserCreator do
2846+
it 'builds a user', :aggregate_failures do
2847+
expect(user.name).to eq("John")
2848+
expect(user.age).to eq(22)
2849+
end
2850+
end
2851+
----
2852+
2853+
==== `aggregate_failures: false`
2854+
2855+
[source,ruby]
2856+
----
2857+
# Detected as an offense
2858+
describe UserCreator do
2859+
it 'builds a user', aggregate_failures: false do
2860+
expect(user.name).to eq("John")
2861+
expect(user.age).to eq(22)
2862+
end
2863+
end
2864+
----
2865+
28402866
==== configuration
28412867

28422868
[source,ruby]

lib/rubocop/cop/rspec/multiple_expectations.rb

+20
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,26 @@ module RSpec
3131
# end
3232
# end
3333
#
34+
# @example `aggregate_failures: true` (default)
35+
#
36+
# # good - the cop ignores when RSpec aggregates failures
37+
# describe UserCreator do
38+
# it 'builds a user', :aggregate_failures do
39+
# expect(user.name).to eq("John")
40+
# expect(user.age).to eq(22)
41+
# end
42+
# end
43+
#
44+
# @example `aggregate_failures: false`
45+
#
46+
# # Detected as an offense
47+
# describe UserCreator do
48+
# it 'builds a user', aggregate_failures: false do
49+
# expect(user.name).to eq("John")
50+
# expect(user.age).to eq(22)
51+
# end
52+
# end
53+
#
3454
# @example configuration
3555
#
3656
# # .rubocop.yml

0 commit comments

Comments
 (0)