rubocop-rspec 2.23.0 → 2.26.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +61 -12
- data/config/default.yml +69 -3
- data/lib/rubocop/cop/rspec/around_block.rb +3 -3
- data/lib/rubocop/cop/rspec/be.rb +1 -1
- data/lib/rubocop/cop/rspec/be_eq.rb +1 -1
- data/lib/rubocop/cop/rspec/be_eql.rb +1 -1
- data/lib/rubocop/cop/rspec/be_nil.rb +2 -2
- data/lib/rubocop/cop/rspec/before_after_all.rb +7 -13
- data/lib/rubocop/cop/rspec/capybara/feature_methods.rb +2 -2
- data/lib/rubocop/cop/rspec/change_by_zero.rb +3 -3
- data/lib/rubocop/cop/rspec/context_method.rb +2 -2
- data/lib/rubocop/cop/rspec/context_wording.rb +1 -1
- data/lib/rubocop/cop/rspec/describe_symbol.rb +1 -1
- data/lib/rubocop/cop/rspec/described_class.rb +5 -5
- data/lib/rubocop/cop/rspec/duplicated_metadata.rb +1 -1
- data/lib/rubocop/cop/rspec/empty_example_group.rb +2 -2
- data/lib/rubocop/cop/rspec/empty_line_after_example.rb +2 -2
- data/lib/rubocop/cop/rspec/empty_metadata.rb +46 -0
- data/lib/rubocop/cop/rspec/eq.rb +47 -0
- data/lib/rubocop/cop/rspec/example_length.rb +11 -5
- data/lib/rubocop/cop/rspec/example_wording.rb +11 -2
- data/lib/rubocop/cop/rspec/excessive_docstring_spacing.rb +4 -2
- data/lib/rubocop/cop/rspec/expect_change.rb +2 -2
- data/lib/rubocop/cop/rspec/file_path.rb +6 -0
- data/lib/rubocop/cop/rspec/focus.rb +4 -2
- data/lib/rubocop/cop/rspec/hook_argument.rb +2 -2
- data/lib/rubocop/cop/rspec/hooks_before_examples.rb +1 -1
- data/lib/rubocop/cop/rspec/implicit_block_expectation.rb +2 -2
- data/lib/rubocop/cop/rspec/implicit_expect.rb +1 -1
- data/lib/rubocop/cop/rspec/implicit_subject.rb +2 -2
- data/lib/rubocop/cop/rspec/instance_spy.rb +2 -2
- data/lib/rubocop/cop/rspec/instance_variable.rb +2 -2
- data/lib/rubocop/cop/rspec/iterated_expectation.rb +3 -3
- data/lib/rubocop/cop/rspec/let_before_examples.rb +1 -1
- data/lib/rubocop/cop/rspec/let_setup.rb +1 -1
- data/lib/rubocop/cop/rspec/message_expectation.rb +1 -1
- data/lib/rubocop/cop/rspec/metadata_style.rb +202 -0
- data/lib/rubocop/cop/rspec/mixin/file_help.rb +14 -0
- data/lib/rubocop/cop/rspec/mixin/metadata.rb +21 -7
- data/lib/rubocop/cop/rspec/mixin/skip_or_pending.rb +2 -2
- data/lib/rubocop/cop/rspec/multiple_expectations.rb +2 -2
- data/lib/rubocop/cop/rspec/pending.rb +1 -1
- data/lib/rubocop/cop/rspec/pending_without_reason.rb +1 -1
- data/lib/rubocop/cop/rspec/predicate_matcher.rb +6 -6
- data/lib/rubocop/cop/rspec/rails/avoid_setup_hook.rb +1 -1
- data/lib/rubocop/cop/rspec/rails/have_http_status.rb +1 -1
- data/lib/rubocop/cop/rspec/rails/http_status.rb +29 -18
- data/lib/rubocop/cop/rspec/rails/minitest_assertions.rb +2 -2
- data/lib/rubocop/cop/rspec/rails/negation_be_valid.rb +10 -0
- data/lib/rubocop/cop/rspec/receive_counts.rb +1 -1
- data/lib/rubocop/cop/rspec/receive_messages.rb +11 -5
- data/lib/rubocop/cop/rspec/redundant_predicate_matcher.rb +65 -0
- data/lib/rubocop/cop/rspec/remove_const.rb +40 -0
- data/lib/rubocop/cop/rspec/repeated_example_group_body.rb +1 -1
- data/lib/rubocop/cop/rspec/repeated_example_group_description.rb +2 -2
- data/lib/rubocop/cop/rspec/repeated_include_example.rb +1 -1
- data/lib/rubocop/cop/rspec/return_from_stub.rb +1 -1
- data/lib/rubocop/cop/rspec/shared_context.rb +1 -1
- data/lib/rubocop/cop/rspec/shared_examples.rb +66 -20
- data/lib/rubocop/cop/rspec/single_argument_message_chain.rb +1 -1
- data/lib/rubocop/cop/rspec/sort_metadata.rb +2 -1
- data/lib/rubocop/cop/rspec/spec_file_path_format.rb +133 -0
- data/lib/rubocop/cop/rspec/spec_file_path_suffix.rb +40 -0
- data/lib/rubocop/cop/rspec/stubbed_mock.rb +1 -1
- data/lib/rubocop/cop/rspec/subject_stub.rb +4 -4
- data/lib/rubocop/cop/rspec/unspecified_exception.rb +2 -2
- data/lib/rubocop/cop/rspec/variable_definition.rb +4 -4
- data/lib/rubocop/cop/rspec/verified_double_reference.rb +5 -5
- data/lib/rubocop/cop/rspec/verified_doubles.rb +1 -1
- data/lib/rubocop/cop/rspec/void_expect.rb +4 -3
- data/lib/rubocop/cop/rspec_cops.rb +7 -0
- data/lib/rubocop/rspec/language.rb +8 -8
- data/lib/rubocop/rspec/version.rb +1 -1
- data/lib/rubocop/rspec/wording.rb +8 -0
- data/lib/rubocop-rspec.rb +1 -0
- metadata +16 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2bf3d2ebea2c15361963f61079a377b069b01ed6ebb4979b0229471b38866098
|
4
|
+
data.tar.gz: 1910cd808996e04802802dd138e297c98191fd9e8a5bf0c35644ebf589e7bf2e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b94923f79321f29b16c763f995a36c547068a8f69b52e1a5dbe99999f38052f609743fd7132aa672aea7a57726a135d99c171406774a0cc05c30114602dd3d7
|
7
|
+
data.tar.gz: 0fffcfe3e0f089c416bf6fa61dfd89217ccfe7203f0c7bbf4185a30d94a08a7146848ffb592f374f0aa100067d8ca7eec80986310069b9d6c9b16f73c2f72e29
|
data/CHANGELOG.md
CHANGED
@@ -2,19 +2,61 @@
|
|
2
2
|
|
3
3
|
## Master (Unreleased)
|
4
4
|
|
5
|
+
## 2.26.1 (2024-01-05)
|
6
|
+
|
7
|
+
- Fix an error for `RSpec/SharedExamples` when using examples without argument. ([@ydah])
|
8
|
+
|
9
|
+
## 2.26.0 (2024-01-04)
|
10
|
+
|
11
|
+
- Add new `RSpec/RedundantPredicateMatcher` cop. ([@ydah])
|
12
|
+
- Add new `RSpec/RemoveConst` cop. ([@swelther])
|
13
|
+
- Add support for correcting "it will" (future tense) for `RSpec/ExampleWording`. ([@jdufresne])
|
14
|
+
- Add support for `symbol` style for `RSpec/SharedExamples`. ([@jessieay])
|
15
|
+
- Ensure `PendingWithoutReason` can detect violations inside shared groups. ([@robinaugh])
|
16
|
+
|
17
|
+
## 2.25.0 (2023-10-27)
|
18
|
+
|
19
|
+
- Add support single quoted string and percent string and heredoc for `RSpec/Rails/HttpStatus`. ([@ydah])
|
20
|
+
- Change to be inline disable for `RSpec/SpecFilePathFormat` like `RSpec/FilePath`. ([@ydah])
|
21
|
+
- Fix a false positive for `RSpec/MetadataStyle` with example groups having multiple string arguments. ([@franzliedke])
|
22
|
+
|
23
|
+
## 2.24.1 (2023-09-23)
|
24
|
+
|
25
|
+
- Fix an error when using `RSpec/FilePath` and revert to enabled by default. If you have already moved to `RSpec/SpecFilePathSuffix` and `RSpec/SpecFilePathFormat`, disable `RSpec/FilePath` explicitly as `Enabled: false`. The `RSpec/FilePath` before migration and the `RSpec/SpecFilePathSuffix` and `RSpec/SpecFilePathFormat` as the target are available respectively. ([@ydah])
|
26
|
+
|
27
|
+
## 2.24.0 (2023-09-08)
|
28
|
+
|
29
|
+
- Split `RSpec/FilePath` into `RSpec/SpecFilePathSuffix` and `RSpec/SpecFilePathFormat`. `RSpec/FilePath` cop is disabled by default and the two new cops are pending and need to be enabled explicitly. ([@ydah])
|
30
|
+
- Add new `RSpec/Eq` cop. ([@ydah])
|
31
|
+
- Add `RSpec/MetadataStyle` and `RSpec/EmptyMetadata` cops. ([@r7kamura])
|
32
|
+
- Add support `RSpec/Rails/HttpStatus` when `have_http_status` with string argument. ([@ydah])
|
33
|
+
- Fix an infinite loop error when `RSpec/ExcessiveDocstringSpacing` finds a description with non-ASCII leading/trailing whitespace. ([@bcgraham])
|
34
|
+
- Fix an incorrect autocorrect for `RSpec/ReceiveMessages` when return values declared between stubs. ([@marocchino])
|
35
|
+
- Fix a false positive `RSpec/Focus` when chained method call and inside define method. ([@ydah])
|
36
|
+
|
37
|
+
## 2.23.2 (2023-08-09)
|
38
|
+
|
39
|
+
- Fix an incorrect autocorrect for `RSpec/ReceiveMessages` when method is only non-word character. ([@marocchino])
|
40
|
+
- Fix a false positive for `RSpec/ReceiveMessages` when return with splat. ([@marocchino])
|
41
|
+
|
42
|
+
## 2.23.1 (2023-08-07)
|
43
|
+
|
44
|
+
- Mark to `Safe: false` for `RSpec/Rails/NegationBeValid` cop. ([@ydah])
|
45
|
+
- Declare autocorrect as unsafe for `RSpec/ReceiveMessages`. ([@bquorning])
|
46
|
+
|
5
47
|
## 2.23.0 (2023-07-30)
|
6
48
|
|
7
49
|
- Add new `RSpec/Rails/NegationBeValid` cop. ([@ydah])
|
8
50
|
- Fix a false negative for `RSpec/ExcessiveDocstringSpacing` when finds description with em space. ([@ydah])
|
9
51
|
- Fix a false positive for `RSpec/EmptyExampleGroup` when example group with examples defined in `if` branch inside iterator. ([@ydah])
|
10
52
|
- Update the message output of `RSpec/ExpectActual` to include the word 'value'. ([@corydiamand])
|
11
|
-
- Fix a false negative for `RSpec/Pending` when
|
53
|
+
- Fix a false negative for `RSpec/Pending` when `it` without body. ([@ydah])
|
12
54
|
- Add new `RSpec/ReceiveMessages` cop. ([@ydah])
|
13
55
|
- Change default.yml path to use `**/spec/*` instead of `spec/*`. ([@ydah])
|
14
|
-
- Add `AllowedIdentifiers` and `AllowedPatterns` configuration option to `RSpec/IndexedLet`.
|
56
|
+
- Add `AllowedIdentifiers` and `AllowedPatterns` configuration option to `RSpec/IndexedLet`. ([@ydah])
|
15
57
|
- Fix `RSpec/NamedSubject` when block has no body. ([@splattael])
|
16
58
|
- Fix `RSpec/LetBeforeExamples` autocorrect incompatible with `RSpec/ScatteredLet` autocorrect. ([@ydah])
|
17
|
-
- Update `RSpec/Focus` to support `shared_context` and `shared_examples
|
59
|
+
- Update `RSpec/Focus` to support `shared_context` and `shared_examples`. ([@tmaier])
|
18
60
|
|
19
61
|
## 2.22.0 (2023-05-06)
|
20
62
|
|
@@ -36,9 +78,9 @@
|
|
36
78
|
- Add support `be_status` style for `RSpec/Rails/HttpStatus`. ([@ydah])
|
37
79
|
- Add support for shared example groups to `RSpec/EmptyLineAfterExampleGroup`. ([@pirj])
|
38
80
|
- Add support for `RSpec/HaveHttpStatus` when using `response.code`. ([@ydah])
|
39
|
-
- Fix order of expected and actual in correction for `RSpec/Rails/MinitestAssertions
|
81
|
+
- Fix order of expected and actual in correction for `RSpec/Rails/MinitestAssertions`. ([@mvz])
|
40
82
|
- Fix a false positive for `RSpec/DescribedClassModuleWrapping` when RSpec.describe numblock is nested within a module. ([@ydah])
|
41
|
-
- Fix a false positive for `RSpec/FactoryBot/ConsistentParenthesesStyle` inside `&&`, `||` and `:?` when `omit_parentheses` is on ([@dmitrytsepelev])
|
83
|
+
- Fix a false positive for `RSpec/FactoryBot/ConsistentParenthesesStyle` inside `&&`, `||` and `:?` when `omit_parentheses` is on. ([@dmitrytsepelev])
|
42
84
|
- Fix a false positive for `RSpec/PendingWithoutReason` when pending/skip has a reason inside an example group. ([@ydah])
|
43
85
|
- Fix a false negative for `RSpec/RedundantAround` when redundant numblock `around`. ([@ydah])
|
44
86
|
- Change `RSpec/ContainExactly` to ignore calls with no arguments, and change `RSpec/MatchArray` to ignore calls with an empty array literal argument. ([@ydah], [@bquorning])
|
@@ -91,7 +133,7 @@
|
|
91
133
|
- Improved processing speed for `RSpec/Be`, `RSpec/ExpectActual`, `RSpec/ImplicitExpect`, `RSpec/MessageSpies`, `RSpec/PredicateMatcher` and `RSpec/Rails/HaveHttpStatus`. ([@ydah])
|
92
134
|
- Fix wrong autocorrection in `n_times` style on `RSpec/FactoryBot/CreateList`. ([@r7kamura])
|
93
135
|
- Fix a false positive for `RSpec/FactoryBot/ConsistentParenthesesStyle` when using `generate` with multiple arguments. ([@ydah])
|
94
|
-
- Mark `RSpec/BeEq` as `Safe: false
|
136
|
+
- Mark `RSpec/BeEq` as `Safe: false`. ([@r7kamura])
|
95
137
|
- Add `RSpec/DuplicatedMetadata` cop. ([@r7kamura])
|
96
138
|
- Mark `RSpec/BeEql` as `Safe: false`. ([@r7kamura])
|
97
139
|
- Add `RSpec/PendingWithoutReason` cop. ([@r7kamura])
|
@@ -124,8 +166,8 @@
|
|
124
166
|
- Fix a false positive for `RSpec/Capybara/SpecificMatcher` when `have_css("a")` without attribute. ([@ydah])
|
125
167
|
- Update `RSpec/ExampleWording` cop to raise error for insufficient descriptions. ([@akrox58])
|
126
168
|
- Add new `RSpec/Capybara/NegationMatcher` cop. ([@ydah])
|
127
|
-
- Add `AllowedPatterns` configuration option to `RSpec/NoExpectationExample`.
|
128
|
-
- Improve `RSpec/NoExpectationExample` cop to ignore examples skipped or pending via metadata.
|
169
|
+
- Add `AllowedPatterns` configuration option to `RSpec/NoExpectationExample`. ([@ydah])
|
170
|
+
- Improve `RSpec/NoExpectationExample` cop to ignore examples skipped or pending via metadata. ([@pirj])
|
129
171
|
- Add `RSpec/FactoryBot/ConsistentParenthesesStyle` cop. ([@Liberatys])
|
130
172
|
- Add `RSpec/Rails/InferredSpecType` cop. ([@r7kamura])
|
131
173
|
- Add new `RSpec/Capybara/SpecificActions` cop. ([@ydah])
|
@@ -441,7 +483,7 @@
|
|
441
483
|
- Add config to `RSpec/VerifiedDoubles` to enforcement of verification on unnamed doubles. ([@BrentWheeldon])
|
442
484
|
- Fix `FactoryBot/AttributeDefinedStatically` not working when there is a non-symbol key. ([@vzvu3k6k])
|
443
485
|
- Fix false positive in `RSpec/ImplicitSubject` when `is_expected` is used inside `its()` block. ([@Darhazer])
|
444
|
-
- Add `single_statement_only` style to
|
486
|
+
- Add `single_statement_only` style to `RSpec/ImplicitSubject` as a more relaxed alternative to `single_line_only`. ([@Darhazer])
|
445
487
|
- Add `RSpec/UnspecifiedException` as a default cop to encourage more-specific `expect{}.to raise_error(ExceptionType)`, or `raise_exception` style handling of exceptions. ([@daveworth])
|
446
488
|
|
447
489
|
## 1.29.1 (2018-09-01)
|
@@ -476,14 +518,14 @@
|
|
476
518
|
|
477
519
|
## 1.26.0 (2018-06-06)
|
478
520
|
|
479
|
-
- Fix false positive in `RSpec/EmptyExampleGroup` cop when methods named like a RSpec method are used.
|
521
|
+
- Fix false positive in `RSpec/EmptyExampleGroup` cop when methods named like a RSpec method are used. ([@Darhazer])
|
480
522
|
- Fix `Capybara/FeatureMethods` not working when there is require before the spec. ([@Darhazer])
|
481
523
|
- Fix `RSpec/EmptyLineAfterFinalLet`: allow a comment to be placed after latest let, requiring empty line after the comment. ([@Darhazer])
|
482
524
|
- Add `RSpec/ReceiveCounts` cop to enforce usage of :once and :twice matchers. ([@Darhazer])
|
483
525
|
|
484
526
|
## 1.25.1 (2018-04-10)
|
485
527
|
|
486
|
-
- Fix false positive in `RSpec/Pending` cop when pending is used as a method name.
|
528
|
+
- Fix false positive in `RSpec/Pending` cop when pending is used as a method name. ([@Darhazer])
|
487
529
|
- Fix `FactoryBot/DynamicAttributeDefinedStatically` false positive when using symbol proc argument for a sequence. ([@tdeo])
|
488
530
|
|
489
531
|
## 1.25.0 (2018-04-07)
|
@@ -491,7 +533,7 @@
|
|
491
533
|
- Add `RSpec/SharedExamples` cop to enforce consistent usage of string to titleize shared examples. ([@anthony-robin])
|
492
534
|
- Add `RSpec/Be` cop to enforce passing argument to the generic `be` matcher. ([@Darhazer])
|
493
535
|
- Fix false positives in `StaticAttributeDefinedDynamically` and `ReturnFromStub` when a const is used in an array or hash. ([@Darhazer])
|
494
|
-
- Add `RSpec/Pending` cop to enforce no existing pending or skipped examples.
|
536
|
+
- Add `RSpec/Pending` cop to enforce no existing pending or skipped examples. This is disabled by default. ([@patrickomatic])
|
495
537
|
- Fix `RSpec/NestedGroups` cop support --auto-gen-config. ([@walf443])
|
496
538
|
- Fix false positives in `Capybara/FeatureMethods` when feature methods are used as property names in a factory. ([@Darhazer])
|
497
539
|
- Allow configuring enabled methods in `Capybara/FeatureMethods`. ([@Darhazer])
|
@@ -787,6 +829,7 @@ Compatibility release so users can upgrade RuboCop to 0.51.0. No new features.
|
|
787
829
|
[@aried3r]: https://github.com/aried3r
|
788
830
|
[@baberthal]: https://github.com/baberthal
|
789
831
|
[@backus]: https://github.com/backus
|
832
|
+
[@bcgraham]: https://github.com/bcgraham
|
790
833
|
[@biinari]: https://github.com/biinari
|
791
834
|
[@bmorrall]: https://github.com/bmorrall
|
792
835
|
[@bquorning]: https://github.com/bquorning
|
@@ -814,6 +857,7 @@ Compatibility release so users can upgrade RuboCop to 0.51.0. No new features.
|
|
814
857
|
[@faucct]: https://github.com/faucct
|
815
858
|
[@foton]: https://github.com/foton
|
816
859
|
[@francois-ferrandis]: https://github.com/francois-ferrandis
|
860
|
+
[@franzliedke]: https://github.com/franzliedke
|
817
861
|
[@g-rath]: https://github.com/G-Rath
|
818
862
|
[@geniou]: https://github.com/geniou
|
819
863
|
[@gsamokovarov]: https://github.com/gsamokovarov
|
@@ -823,7 +867,9 @@ Compatibility release so users can upgrade RuboCop to 0.51.0. No new features.
|
|
823
867
|
[@ignaciovillaverde]: https://github.com/ignaciovillaverde
|
824
868
|
[@jaredbeck]: https://github.com/jaredbeck
|
825
869
|
[@jaredmoody]: https://github.com/jaredmoody
|
870
|
+
[@jdufresne]: https://github.com/jdufresne
|
826
871
|
[@jeffreyc]: https://github.com/jeffreyc
|
872
|
+
[@jessieay]: https://github.com/jessieay
|
827
873
|
[@jfragoulis]: https://github.com/jfragoulis
|
828
874
|
[@johnny-miyake]: https://github.com/johnny-miyake
|
829
875
|
[@jojos003]: https://github.com/jojos003
|
@@ -838,6 +884,7 @@ Compatibility release so users can upgrade RuboCop to 0.51.0. No new features.
|
|
838
884
|
[@lokhi]: https://github.com/lokhi
|
839
885
|
[@luke-hill]: https://github.com/luke-hill
|
840
886
|
[@m-yamashita01]: https://github.com/M-Yamashita01
|
887
|
+
[@marocchino]: https://github.com/marocchino
|
841
888
|
[@miguelfteixeira]: https://github.com/miguelfteixeira
|
842
889
|
[@mkenyon]: https://github.com/mkenyon
|
843
890
|
[@mkrawc]: https://github.com/mkrawc
|
@@ -864,6 +911,7 @@ Compatibility release so users can upgrade RuboCop to 0.51.0. No new features.
|
|
864
911
|
[@rafix02]: https://github.com/Rafix02
|
865
912
|
[@redross]: https://github.com/redross
|
866
913
|
[@renanborgescampos]: https://github.com/renanborgescampos
|
914
|
+
[@robinaugh]: https://github.com/robinaugh
|
867
915
|
[@robotdana]: https://github.com/robotdana
|
868
916
|
[@rolfschmidt]: https://github.com/rolfschmidt
|
869
917
|
[@rrosenblum]: https://github.com/rrosenblum
|
@@ -876,6 +924,7 @@ Compatibility release so users can upgrade RuboCop to 0.51.0. No new features.
|
|
876
924
|
[@smcgivern]: https://github.com/smcgivern
|
877
925
|
[@splattael]: https://github.com/splattael
|
878
926
|
[@stephannv]: https://github.com/stephannv
|
927
|
+
[@swelther]: https://github.com/swelther
|
879
928
|
[@t3h2mas]: https://github.com/t3h2mas
|
880
929
|
[@tdeo]: https://github.com/tdeo
|
881
930
|
[@tejasbubane]: https://github.com/tejasbubane
|
data/config/default.yml
CHANGED
@@ -178,7 +178,7 @@ RSpec/BeNil:
|
|
178
178
|
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/BeNil
|
179
179
|
|
180
180
|
RSpec/BeforeAfterAll:
|
181
|
-
Description: Check that before/after(:all) isn't being used.
|
181
|
+
Description: Check that before/after(:all/:context) isn't being used.
|
182
182
|
Enabled: true
|
183
183
|
Exclude:
|
184
184
|
- "**/spec/spec_helper.rb"
|
@@ -359,6 +359,18 @@ RSpec/EmptyLineAfterSubject:
|
|
359
359
|
StyleGuide: https://rspec.rubystyle.guide/#empty-line-after-let
|
360
360
|
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/EmptyLineAfterSubject
|
361
361
|
|
362
|
+
RSpec/EmptyMetadata:
|
363
|
+
Description: Avoid empty metadata hash.
|
364
|
+
Enabled: pending
|
365
|
+
VersionAdded: '2.24'
|
366
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/EmptyMetadata
|
367
|
+
|
368
|
+
RSpec/Eq:
|
369
|
+
Description: Use `eq` instead of `be ==` to compare objects.
|
370
|
+
Enabled: pending
|
371
|
+
VersionAdded: '2.24'
|
372
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Eq
|
373
|
+
|
362
374
|
RSpec/ExampleLength:
|
363
375
|
Description: Checks for long examples.
|
364
376
|
Enabled: true
|
@@ -446,7 +458,7 @@ RSpec/FilePath:
|
|
446
458
|
IgnoreMethods: false
|
447
459
|
SpecSuffixOnly: false
|
448
460
|
VersionAdded: '1.2'
|
449
|
-
VersionChanged: '
|
461
|
+
VersionChanged: '2.24'
|
450
462
|
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/FilePath
|
451
463
|
|
452
464
|
RSpec/Focus:
|
@@ -613,6 +625,16 @@ RSpec/MessageSpies:
|
|
613
625
|
VersionAdded: '1.9'
|
614
626
|
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/MessageSpies
|
615
627
|
|
628
|
+
RSpec/MetadataStyle:
|
629
|
+
Description: Use consistent metadata style.
|
630
|
+
Enabled: pending
|
631
|
+
EnforcedStyle: symbol
|
632
|
+
SupportedStyles:
|
633
|
+
- hash
|
634
|
+
- symbol
|
635
|
+
VersionAdded: '2.24'
|
636
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/MetadataStyle
|
637
|
+
|
616
638
|
RSpec/MissingExampleGroupArgument:
|
617
639
|
Description: Checks that the first argument to an example group is not empty.
|
618
640
|
Enabled: true
|
@@ -733,6 +755,7 @@ RSpec/ReceiveCounts:
|
|
733
755
|
RSpec/ReceiveMessages:
|
734
756
|
Description: Checks for multiple messages stubbed on the same object.
|
735
757
|
Enabled: pending
|
758
|
+
SafeAutoCorrect: false
|
736
759
|
VersionAdded: '2.23'
|
737
760
|
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ReceiveMessages
|
738
761
|
|
@@ -748,6 +771,18 @@ RSpec/RedundantAround:
|
|
748
771
|
VersionAdded: '2.19'
|
749
772
|
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/RedundantAround
|
750
773
|
|
774
|
+
RSpec/RedundantPredicateMatcher:
|
775
|
+
Description: Checks for redundant predicate matcher.
|
776
|
+
Enabled: pending
|
777
|
+
VersionAdded: '2.26'
|
778
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/RedundantPredicateMatcher
|
779
|
+
|
780
|
+
RSpec/RemoveConst:
|
781
|
+
Description: Checks that `remove_const` is not used in specs.
|
782
|
+
Enabled: pending
|
783
|
+
VersionAdded: '2.26'
|
784
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/RemoveConst
|
785
|
+
|
751
786
|
RSpec/RepeatedDescription:
|
752
787
|
Description: Check for repeated description strings in example groups.
|
753
788
|
Enabled: true
|
@@ -809,9 +844,14 @@ RSpec/SharedContext:
|
|
809
844
|
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/SharedContext
|
810
845
|
|
811
846
|
RSpec/SharedExamples:
|
812
|
-
Description:
|
847
|
+
Description: Checks for consistent style for shared example names.
|
813
848
|
Enabled: true
|
849
|
+
EnforcedStyle: string
|
850
|
+
SupportedStyles:
|
851
|
+
- string
|
852
|
+
- symbol
|
814
853
|
VersionAdded: '1.25'
|
854
|
+
VersionChanged: '2.26'
|
815
855
|
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/SharedExamples
|
816
856
|
|
817
857
|
RSpec/SingleArgumentMessageChain:
|
@@ -833,6 +873,31 @@ RSpec/SortMetadata:
|
|
833
873
|
VersionAdded: '2.14'
|
834
874
|
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/SortMetadata
|
835
875
|
|
876
|
+
RSpec/SpecFilePathFormat:
|
877
|
+
Description: Checks that spec file paths are consistent and well-formed.
|
878
|
+
Enabled: pending
|
879
|
+
Include:
|
880
|
+
- "**/*_spec.rb"
|
881
|
+
Exclude:
|
882
|
+
- "**/spec/routing/**/*"
|
883
|
+
CustomTransform:
|
884
|
+
RuboCop: rubocop
|
885
|
+
RSpec: rspec
|
886
|
+
IgnoreMethods: false
|
887
|
+
IgnoreMetadata:
|
888
|
+
type: routing
|
889
|
+
VersionAdded: '2.24'
|
890
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/SpecFilePathFormat
|
891
|
+
|
892
|
+
RSpec/SpecFilePathSuffix:
|
893
|
+
Description: Checks that spec file paths suffix are consistent and well-formed.
|
894
|
+
Enabled: pending
|
895
|
+
VersionAdded: '2.24'
|
896
|
+
Include:
|
897
|
+
- "**/*_spec*rb*"
|
898
|
+
- "**/spec/**/*"
|
899
|
+
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/SpecFilePathSuffix
|
900
|
+
|
836
901
|
RSpec/StubbedMock:
|
837
902
|
Description: Checks that message expectations do not have a configured response.
|
838
903
|
Enabled: true
|
@@ -1108,6 +1173,7 @@ RSpec/Rails/MinitestAssertions:
|
|
1108
1173
|
|
1109
1174
|
RSpec/Rails/NegationBeValid:
|
1110
1175
|
Description: Enforces use of `be_invalid` or `not_to` for negated be_valid.
|
1176
|
+
Safe: false
|
1111
1177
|
EnforcedStyle: not_to
|
1112
1178
|
SupportedStyles:
|
1113
1179
|
- not_to
|
@@ -32,17 +32,17 @@ module RuboCop
|
|
32
32
|
'or `%<arg>s.run`.'
|
33
33
|
|
34
34
|
# @!method hook_block(node)
|
35
|
-
def_node_matcher :hook_block,
|
35
|
+
def_node_matcher :hook_block, <<~PATTERN
|
36
36
|
(block (send nil? :around sym ?) (args $...) ...)
|
37
37
|
PATTERN
|
38
38
|
|
39
39
|
# @!method hook_numblock(node)
|
40
|
-
def_node_matcher :hook_numblock,
|
40
|
+
def_node_matcher :hook_numblock, <<~PATTERN
|
41
41
|
(numblock (send nil? :around sym ?) ...)
|
42
42
|
PATTERN
|
43
43
|
|
44
44
|
# @!method find_arg_usage(node)
|
45
|
-
def_node_search :find_arg_usage,
|
45
|
+
def_node_search :find_arg_usage, <<~PATTERN
|
46
46
|
{(send $... {:call :run}) (send _ _ $...) (yield $...) (block-pass $...)}
|
47
47
|
PATTERN
|
48
48
|
|
data/lib/rubocop/cop/rspec/be.rb
CHANGED
@@ -44,7 +44,7 @@ module RuboCop
|
|
44
44
|
RESTRICT_ON_SEND = %i[to].freeze
|
45
45
|
|
46
46
|
# @!method eql_type_with_identity(node)
|
47
|
-
def_node_matcher :eql_type_with_identity,
|
47
|
+
def_node_matcher :eql_type_with_identity, <<~PATTERN
|
48
48
|
(send _ :to $(send nil? :eql {true false int float sym nil}))
|
49
49
|
PATTERN
|
50
50
|
|
@@ -33,12 +33,12 @@ module RuboCop
|
|
33
33
|
RESTRICT_ON_SEND = %i[be be_nil].freeze
|
34
34
|
|
35
35
|
# @!method be_nil_matcher?(node)
|
36
|
-
def_node_matcher :be_nil_matcher?,
|
36
|
+
def_node_matcher :be_nil_matcher?, <<~PATTERN
|
37
37
|
(send nil? :be_nil)
|
38
38
|
PATTERN
|
39
39
|
|
40
40
|
# @!method nil_value_expectation?(node)
|
41
|
-
def_node_matcher :nil_value_expectation?,
|
41
|
+
def_node_matcher :nil_value_expectation?, <<~PATTERN
|
42
42
|
(send nil? :be nil)
|
43
43
|
PATTERN
|
44
44
|
|
@@ -3,22 +3,16 @@
|
|
3
3
|
module RuboCop
|
4
4
|
module Cop
|
5
5
|
module RSpec
|
6
|
-
# Check that before/after(:all) isn't being used.
|
6
|
+
# Check that before/after(:all/:context) isn't being used.
|
7
7
|
#
|
8
8
|
# @example
|
9
|
-
# # bad
|
10
|
-
# #
|
11
|
-
# # Faster but risk of state leaking between examples
|
12
|
-
# #
|
9
|
+
# # bad - Faster but risk of state leaking between examples
|
13
10
|
# describe MyClass do
|
14
11
|
# before(:all) { Widget.create }
|
15
|
-
# after(:
|
12
|
+
# after(:context) { Widget.delete_all }
|
16
13
|
# end
|
17
14
|
#
|
18
|
-
# # good
|
19
|
-
# #
|
20
|
-
# # Slower but examples are properly isolated
|
21
|
-
# #
|
15
|
+
# # good - Slower but examples are properly isolated
|
22
16
|
# describe MyClass do
|
23
17
|
# before(:each) { Widget.create }
|
24
18
|
# after(:each) { Widget.delete_all }
|
@@ -30,11 +24,11 @@ module RuboCop
|
|
30
24
|
'`use_transactional_fixtures` is enabled, then records created ' \
|
31
25
|
'in `%<hook>s` are not automatically rolled back.'
|
32
26
|
|
33
|
-
RESTRICT_ON_SEND =
|
27
|
+
RESTRICT_ON_SEND = Set[:before, :after].freeze
|
34
28
|
|
35
29
|
# @!method before_or_after_all(node)
|
36
|
-
def_node_matcher :before_or_after_all,
|
37
|
-
$(send _
|
30
|
+
def_node_matcher :before_or_after_all, <<~PATTERN
|
31
|
+
$(send _ RESTRICT_ON_SEND (sym {:all :context}))
|
38
32
|
PATTERN
|
39
33
|
|
40
34
|
def on_send(node)
|
@@ -58,12 +58,12 @@ module RuboCop
|
|
58
58
|
}.freeze
|
59
59
|
|
60
60
|
# @!method capybara_speak(node)
|
61
|
-
def_node_matcher :capybara_speak,
|
61
|
+
def_node_matcher :capybara_speak, <<~PATTERN
|
62
62
|
{#{MAP.keys.map(&:inspect).join(' ')}}
|
63
63
|
PATTERN
|
64
64
|
|
65
65
|
# @!method feature_method(node)
|
66
|
-
def_node_matcher :feature_method,
|
66
|
+
def_node_matcher :feature_method, <<~PATTERN
|
67
67
|
(block
|
68
68
|
$(send #rspec? $#capybara_speak ...)
|
69
69
|
...)
|
@@ -66,14 +66,14 @@ module RuboCop
|
|
66
66
|
RESTRICT_ON_SEND = CHANGE_METHODS.freeze
|
67
67
|
|
68
68
|
# @!method expect_change_with_arguments(node)
|
69
|
-
def_node_matcher :expect_change_with_arguments,
|
69
|
+
def_node_matcher :expect_change_with_arguments, <<~PATTERN
|
70
70
|
(send
|
71
71
|
$(send nil? CHANGE_METHODS ...) :by
|
72
72
|
(int 0))
|
73
73
|
PATTERN
|
74
74
|
|
75
75
|
# @!method expect_change_with_block(node)
|
76
|
-
def_node_matcher :expect_change_with_block,
|
76
|
+
def_node_matcher :expect_change_with_block, <<~PATTERN
|
77
77
|
(send
|
78
78
|
(block
|
79
79
|
$(send nil? CHANGE_METHODS)
|
@@ -83,7 +83,7 @@ module RuboCop
|
|
83
83
|
PATTERN
|
84
84
|
|
85
85
|
# @!method change_nodes(node)
|
86
|
-
def_node_search :change_nodes,
|
86
|
+
def_node_search :change_nodes, <<~PATTERN
|
87
87
|
$(send nil? CHANGE_METHODS ...)
|
88
88
|
PATTERN
|
89
89
|
|
@@ -30,7 +30,7 @@ module RuboCop
|
|
30
30
|
MSG = 'Use `describe` for testing methods.'
|
31
31
|
|
32
32
|
# @!method context_method(node)
|
33
|
-
def_node_matcher :context_method,
|
33
|
+
def_node_matcher :context_method, <<~PATTERN
|
34
34
|
(block
|
35
35
|
(send #rspec? :context
|
36
36
|
${(str #method_name?) (dstr (str #method_name?) ...)}
|
@@ -38,7 +38,7 @@ module RuboCop
|
|
38
38
|
...)
|
39
39
|
PATTERN
|
40
40
|
|
41
|
-
def on_block(node)
|
41
|
+
def on_block(node) # rubocop:disable InternalAffairs/NumblockHandler
|
42
42
|
context_method(node) do |context|
|
43
43
|
add_offense(context) do |corrector|
|
44
44
|
corrector.replace(node.send_node.loc.selector, 'describe')
|
@@ -61,7 +61,7 @@ module RuboCop
|
|
61
61
|
MSG = 'Context description should match %<patterns>s.'
|
62
62
|
|
63
63
|
# @!method context_wording(node)
|
64
|
-
def_node_matcher :context_wording,
|
64
|
+
def_node_matcher :context_wording, <<~PATTERN
|
65
65
|
(block (send #rspec? { :context :shared_context } $({str dstr xstr} ...) ...) ...)
|
66
66
|
PATTERN
|
67
67
|
|
@@ -63,7 +63,7 @@ module RuboCop
|
|
63
63
|
MSG = 'Use `%<replacement>s` instead of `%<src>s`.'
|
64
64
|
|
65
65
|
# @!method common_instance_exec_closure?(node)
|
66
|
-
def_node_matcher :common_instance_exec_closure?,
|
66
|
+
def_node_matcher :common_instance_exec_closure?, <<~PATTERN
|
67
67
|
(block (send (const nil? {:Class :Module :Struct}) :new ...) ...)
|
68
68
|
PATTERN
|
69
69
|
|
@@ -75,7 +75,7 @@ module RuboCop
|
|
75
75
|
def_node_matcher :scope_changing_syntax?, '{def class module}'
|
76
76
|
|
77
77
|
# @!method described_constant(node)
|
78
|
-
def_node_matcher :described_constant,
|
78
|
+
def_node_matcher :described_constant, <<~PATTERN
|
79
79
|
(block (send _ :describe $(const ...) ...) (args) $_)
|
80
80
|
PATTERN
|
81
81
|
|
@@ -148,15 +148,15 @@ module RuboCop
|
|
148
148
|
end
|
149
149
|
|
150
150
|
def offensive_described_class?(node)
|
151
|
-
return unless node.const_type?
|
151
|
+
return false unless node.const_type?
|
152
152
|
|
153
153
|
# E.g. `described_class::CONSTANT`
|
154
|
-
return if contains_described_class?(node)
|
154
|
+
return false if contains_described_class?(node)
|
155
155
|
|
156
156
|
nearest_described_class, = node.each_ancestor(:block)
|
157
157
|
.map { |ancestor| described_constant(ancestor) }.find(&:itself)
|
158
158
|
|
159
|
-
return if nearest_described_class.equal?(node)
|
159
|
+
return false if nearest_described_class.equal?(node)
|
160
160
|
|
161
161
|
full_const_name(nearest_described_class) == full_const_name(node)
|
162
162
|
end
|
@@ -162,7 +162,7 @@ module RuboCop
|
|
162
162
|
end
|
163
163
|
|
164
164
|
def conditionals_with_examples?(body)
|
165
|
-
return unless body.begin_type? || body.case_type?
|
165
|
+
return false unless body.begin_type? || body.case_type?
|
166
166
|
|
167
167
|
body.each_descendant(:if, :case).any? do |condition_node|
|
168
168
|
examples_in_branches?(condition_node)
|
@@ -170,7 +170,7 @@ module RuboCop
|
|
170
170
|
end
|
171
171
|
|
172
172
|
def examples_in_branches?(condition_node)
|
173
|
-
return if !condition_node.if_type? && !condition_node.case_type?
|
173
|
+
return false if !condition_node.if_type? && !condition_node.case_type?
|
174
174
|
|
175
175
|
condition_node.branches.any? { |branch| examples?(branch) }
|
176
176
|
end
|
@@ -71,8 +71,8 @@ module RuboCop
|
|
71
71
|
|
72
72
|
def next_one_line_example?(node)
|
73
73
|
next_sibling = node.right_sibling
|
74
|
-
return unless next_sibling
|
75
|
-
return unless example?(next_sibling)
|
74
|
+
return false unless next_sibling
|
75
|
+
return false unless example?(next_sibling)
|
76
76
|
|
77
77
|
next_sibling.single_line?
|
78
78
|
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module RSpec
|
6
|
+
# Avoid empty metadata hash.
|
7
|
+
#
|
8
|
+
# @example EnforcedStyle: symbol (default)
|
9
|
+
# # bad
|
10
|
+
# describe 'Something', {}
|
11
|
+
#
|
12
|
+
# # good
|
13
|
+
# describe 'Something'
|
14
|
+
class EmptyMetadata < Base
|
15
|
+
extend AutoCorrector
|
16
|
+
|
17
|
+
include Metadata
|
18
|
+
include RangeHelp
|
19
|
+
|
20
|
+
MSG = 'Avoid empty metadata hash.'
|
21
|
+
|
22
|
+
def on_metadata(_symbols, hash)
|
23
|
+
return unless hash&.pairs&.empty?
|
24
|
+
|
25
|
+
add_offense(hash) do |corrector|
|
26
|
+
remove_empty_metadata(corrector, hash)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def remove_empty_metadata(corrector, node)
|
33
|
+
corrector.remove(
|
34
|
+
range_with_surrounding_comma(
|
35
|
+
range_with_surrounding_space(
|
36
|
+
node.source_range,
|
37
|
+
side: :left
|
38
|
+
),
|
39
|
+
:left
|
40
|
+
)
|
41
|
+
)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|