rubocop-rspec 2.3.0 → 2.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +45 -0
- data/README.md +2 -4
- data/config/default.yml +85 -3
- data/lib/rubocop/cop/rspec/capybara/feature_methods.rb +2 -23
- data/lib/rubocop/cop/rspec/described_class.rb +1 -1
- data/lib/rubocop/cop/rspec/empty_hook.rb +4 -1
- data/lib/rubocop/cop/rspec/example_wording.rb +3 -0
- data/lib/rubocop/cop/rspec/excessive_docstring_spacing.rb +100 -0
- data/lib/rubocop/cop/rspec/expect_change.rb +3 -3
- data/lib/rubocop/cop/rspec/factory_bot/create_list.rb +4 -3
- data/lib/rubocop/cop/rspec/factory_bot/syntax_methods.rb +107 -0
- data/lib/rubocop/cop/rspec/file_path.rb +12 -10
- data/lib/rubocop/cop/rspec/hook_argument.rb +1 -1
- data/lib/rubocop/cop/rspec/identical_equality_assertion.rb +38 -0
- data/lib/rubocop/cop/rspec/implicit_subject.rb +17 -1
- data/lib/rubocop/cop/rspec/iterated_expectation.rb +2 -0
- data/lib/rubocop/cop/rspec/mixin/inside_example_group.rb +29 -0
- data/lib/rubocop/cop/rspec/nested_groups.rb +1 -1
- data/lib/rubocop/cop/rspec/rails/avoid_setup_hook.rb +44 -0
- data/lib/rubocop/cop/rspec/subject_declaration.rb +47 -0
- data/lib/rubocop/cop/rspec/variable_definition.rb +19 -2
- data/lib/rubocop/cop/rspec_cops.rb +5 -0
- data/lib/rubocop/rspec/align_let_brace.rb +2 -1
- data/lib/rubocop/rspec/config_formatter.rb +3 -0
- data/lib/rubocop/rspec/factory_bot/language.rb +17 -0
- data/lib/rubocop/rspec/version.rb +1 -1
- data/lib/rubocop-rspec.rb +5 -2
- metadata +18 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f73bb98579faf4e173aa834c1a3aa5fc1c9b6aa7c8790d3fcef2451594fadc78
|
4
|
+
data.tar.gz: e66399f76cea55c1eed9b348f3015ab726fb5df49b2f1a391bbf043b45b18507
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 44ba849ca8fd9ad7cb65355c78046bd5702f9d5b1f5df305fda876c6d7feb5947ea15e6fdb3749e32c1ae18b089703abefc074991fc780d6147b2295f3202a05
|
7
|
+
data.tar.gz: 5281f8fa3c1cb64028dd54544fc2f26fe25f382a5f842fa0dfe5040dbb6ea3627e74a386a596806cd6a0f56d8353d749fbec713c48c19d45f55840f9983cf755
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,40 @@
|
|
2
2
|
|
3
3
|
## Master (Unreleased)
|
4
4
|
|
5
|
+
## 2.7.0 (2021-12-26)
|
6
|
+
|
7
|
+
* Add new `RSpec/FactoryBot/SyntaxMethods` cop. ([@leoarnold][])
|
8
|
+
* Exclude `task` type specs from `RSpec/DescribeClass` cop. ([@harry-graham][])
|
9
|
+
|
10
|
+
## 2.6.0 (2021-11-08)
|
11
|
+
|
12
|
+
* Fix merging RSpec DSL configuration from third-party gems. ([@pirj][])
|
13
|
+
* Fix `RSpec/ExcessiveDocstringSpacing` false positive for multi-line indented strings. ([@G-Rath][])
|
14
|
+
* Fix `Include` configuration for sub-departments. ([@pirj][])
|
15
|
+
* Ignore heredocs in `RSpec/ExcessiveDocstringSpacing`. ([@G-Rath][])
|
16
|
+
* Stop `RSpec/ExampleWording` from trying to correct heredocs. ([@G-Rath][])
|
17
|
+
* Add autocorrect support for `RSpec/VariableDefinition`. ([@r7kamura][])
|
18
|
+
|
19
|
+
## 2.5.0 (2021-09-21)
|
20
|
+
|
21
|
+
* Declare autocorrect as unsafe for `ExpectChange`. ([@francois-ferrandis][])
|
22
|
+
* Fix each example for `RSpec/HookArgument`. ([@lokhi][])
|
23
|
+
* Exclude unrelated Rails directories from `RSpec/DescribeClass`. ([@MothOnMars][])
|
24
|
+
* Add `RSpec/ExcessiveDocstringSpacing` cop. ([@G-Rath][])
|
25
|
+
* Add `RSpec/SubjectDeclaration` cop. ([@dswij][])
|
26
|
+
* Fix excessive whitespace removal in `RSpec/EmptyHook` autocorrection. ([@pirj][])
|
27
|
+
* Bump RuboCop requirement to v1.19.0. ([@pirj][])
|
28
|
+
* Fix false positive in `RSpec/IteratedExpectation` when there is single, non-expectation statement in the block body. ([@Darhazer][])
|
29
|
+
|
30
|
+
## 2.4.0 (2021-06-09)
|
31
|
+
|
32
|
+
* Update `RSpec/FilePath` to check suffix when given a non-constant top-level node (e.g. features). ([@topalovic][])
|
33
|
+
* Add missing documentation for `single_statement_only` style of `RSpec/ImplicitSubject` cop. ([@tejasbubane][])
|
34
|
+
* Fix an exception in `DescribedClass` when accessing a constant on a variable in a spec that is nested in a namespace. ([@rrosenblum][])
|
35
|
+
* Add new `RSpec/IdenticalEqualityAssertion` cop. ([@tejasbubane][])
|
36
|
+
* Add `RSpec/Rails/AvoidSetupHook` cop. ([@paydaylight][])
|
37
|
+
* Fix false negative in `RSpec/ExpectChange` cop with block style and chained method call. ([@tejasbubane][])
|
38
|
+
|
5
39
|
## 2.3.0 (2021-04-28)
|
6
40
|
|
7
41
|
* Allow `RSpec/ContextWording` to accept multi-word prefixes. ([@hosamaly][])
|
@@ -613,3 +647,14 @@ Compatibility release so users can upgrade RuboCop to 0.51.0. No new features.
|
|
613
647
|
[@hosamaly]: https://github.com/hosamaly
|
614
648
|
[@stephannv]: https://github.com/stephannv
|
615
649
|
[@Tietew]: https://github.com/Tietew
|
650
|
+
[@rrosenblum]: https://github.com/rrosenblum
|
651
|
+
[@paydaylight]: https://github.com/paydaylight
|
652
|
+
[@topalovic]: https://github.com/topalovic
|
653
|
+
[@lokhi]: https://github.com/lokhi
|
654
|
+
[@MothOnMars]: https://github.com/MothOnMars
|
655
|
+
[@G-Rath]: https://github.com/G-Rath
|
656
|
+
[@dswij]: https://github.com/dswij
|
657
|
+
[@francois-ferrandis]: https://github.com/francois-ferrandis
|
658
|
+
[@r7kamura]: https://github.com/r7kamura
|
659
|
+
[@leoarnold]: https://github.com/leoarnold
|
660
|
+
[@harry-graham]: https://github.com/harry-graham
|
data/README.md
CHANGED
@@ -2,9 +2,7 @@
|
|
2
2
|
|
3
3
|
[![Join the chat at https://gitter.im/rubocop-rspec/Lobby](https://badges.gitter.im/rubocop-rspec/Lobby.svg)](https://gitter.im/rubocop-rspec/Lobby)
|
4
4
|
[![Gem Version](https://badge.fury.io/rb/rubocop-rspec.svg)](https://rubygems.org/gems/rubocop-rspec)
|
5
|
-
|
6
|
-
[![Test Coverage](https://api.codeclimate.com/v1/badges/8ffaabf633c968c22bdd/test_coverage)](https://codeclimate.com/github/rubocop-hq/rubocop-rspec/test_coverage)
|
7
|
-
[![Maintainability](https://api.codeclimate.com/v1/badges/8ffaabf633c968c22bdd/maintainability)](https://codeclimate.com/github/rubocop-hq/rubocop-rspec/maintainability)
|
5
|
+
![CI](https://github.com/rubocop-hq/rubocop-rspec/workflows/CI/badge.svg)
|
8
6
|
|
9
7
|
RSpec-specific analysis for your projects, as an extension to
|
10
8
|
[RuboCop](https://github.com/rubocop/rubocop).
|
@@ -67,7 +65,7 @@ end
|
|
67
65
|
|
68
66
|
### Code Climate
|
69
67
|
|
70
|
-
rubocop-rspec is available on Code Climate as part of the rubocop engine. [Learn More](https://codeclimate.com/changelog/55a433bbe30ba00852000fac).
|
68
|
+
rubocop-rspec is available on Code Climate as part of the rubocop engine. [Learn More](https://marketing.codeclimate.com/changelog/55a433bbe30ba00852000fac/).
|
71
69
|
|
72
70
|
## Documentation
|
73
71
|
|
data/config/default.yml
CHANGED
@@ -1,11 +1,24 @@
|
|
1
1
|
---
|
2
2
|
RSpec:
|
3
3
|
Enabled: true
|
4
|
-
Include:
|
4
|
+
Include: &1
|
5
5
|
- "**/*_spec.rb"
|
6
6
|
- "**/spec/**/*"
|
7
|
-
Language:
|
7
|
+
Language: &2
|
8
|
+
inherit_mode:
|
9
|
+
merge:
|
10
|
+
- Expectations
|
11
|
+
- Helpers
|
12
|
+
- Hooks
|
13
|
+
- HookScopes
|
14
|
+
- Runners
|
15
|
+
- Subjects
|
8
16
|
ExampleGroups:
|
17
|
+
inherit_mode:
|
18
|
+
merge:
|
19
|
+
- Regular
|
20
|
+
- Skipped
|
21
|
+
- Focused
|
9
22
|
Regular:
|
10
23
|
- describe
|
11
24
|
- context
|
@@ -20,6 +33,12 @@ RSpec:
|
|
20
33
|
- fcontext
|
21
34
|
- ffeature
|
22
35
|
Examples:
|
36
|
+
inherit_mode:
|
37
|
+
merge:
|
38
|
+
- Regular
|
39
|
+
- Skipped
|
40
|
+
- Focused
|
41
|
+
- Pending
|
23
42
|
Regular:
|
24
43
|
- it
|
25
44
|
- specify
|
@@ -62,6 +81,10 @@ RSpec:
|
|
62
81
|
- all
|
63
82
|
- suite
|
64
83
|
Includes:
|
84
|
+
inherit_mode:
|
85
|
+
merge:
|
86
|
+
- Examples
|
87
|
+
- Context
|
65
88
|
Examples:
|
66
89
|
- it_behaves_like
|
67
90
|
- it_should_behave_like
|
@@ -73,6 +96,10 @@ RSpec:
|
|
73
96
|
- to_not
|
74
97
|
- not_to
|
75
98
|
SharedGroups:
|
99
|
+
inherit_mode:
|
100
|
+
merge:
|
101
|
+
- Examples
|
102
|
+
- Context
|
76
103
|
Examples:
|
77
104
|
- shared_examples
|
78
105
|
- shared_examples_for
|
@@ -148,6 +175,12 @@ RSpec/ContextWording:
|
|
148
175
|
RSpec/DescribeClass:
|
149
176
|
Description: Check that the first argument to the top-level describe is a constant.
|
150
177
|
Enabled: true
|
178
|
+
Exclude:
|
179
|
+
- "**/spec/features/**/*"
|
180
|
+
- "**/spec/requests/**/*"
|
181
|
+
- "**/spec/routing/**/*"
|
182
|
+
- "**/spec/system/**/*"
|
183
|
+
- "**/spec/views/**/*"
|
151
184
|
IgnoredMetadata:
|
152
185
|
type:
|
153
186
|
- channel
|
@@ -163,8 +196,9 @@ RSpec/DescribeClass:
|
|
163
196
|
- system
|
164
197
|
- mailbox
|
165
198
|
- aruba
|
199
|
+
- task
|
166
200
|
VersionAdded: '1.0'
|
167
|
-
VersionChanged: '
|
201
|
+
VersionChanged: '2.7'
|
168
202
|
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/DescribeClass
|
169
203
|
|
170
204
|
RSpec/DescribeMethod:
|
@@ -269,6 +303,12 @@ RSpec/ExampleWithoutDescription:
|
|
269
303
|
VersionAdded: '1.22'
|
270
304
|
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ExampleWithoutDescription
|
271
305
|
|
306
|
+
RSpec/ExcessiveDocstringSpacing:
|
307
|
+
Description: Checks for excessive whitespace in example descriptions.
|
308
|
+
Enabled: pending
|
309
|
+
VersionAdded: '2.5'
|
310
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ExcessiveDocstringSpacing
|
311
|
+
|
272
312
|
RSpec/ExampleWording:
|
273
313
|
Description: Checks for common mistakes in example descriptions.
|
274
314
|
Enabled: true
|
@@ -297,7 +337,9 @@ RSpec/ExpectChange:
|
|
297
337
|
SupportedStyles:
|
298
338
|
- method_call
|
299
339
|
- block
|
340
|
+
SafeAutoCorrect: false
|
300
341
|
VersionAdded: '1.22'
|
342
|
+
VersionChanged: '2.5'
|
301
343
|
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ExpectChange
|
302
344
|
|
303
345
|
RSpec/ExpectInHook:
|
@@ -351,6 +393,12 @@ RSpec/HooksBeforeExamples:
|
|
351
393
|
VersionAdded: '1.29'
|
352
394
|
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/HooksBeforeExamples
|
353
395
|
|
396
|
+
RSpec/IdenticalEqualityAssertion:
|
397
|
+
Description: Checks for equality assertions with identical expressions on both sides.
|
398
|
+
Enabled: pending
|
399
|
+
VersionAdded: '2.4'
|
400
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/IdenticalEqualityAssertion
|
401
|
+
|
354
402
|
RSpec/ImplicitBlockExpectation:
|
355
403
|
Description: Check that implicit block expectation syntax is not used.
|
356
404
|
Enabled: true
|
@@ -637,6 +685,12 @@ RSpec/StubbedMock:
|
|
637
685
|
VersionAdded: '1.44'
|
638
686
|
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/StubbedMock
|
639
687
|
|
688
|
+
RSpec/SubjectDeclaration:
|
689
|
+
Description: Ensure that subject is defined using subject helper.
|
690
|
+
Enabled: pending
|
691
|
+
VersionAdded: '2.5'
|
692
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/SubjectDeclaration
|
693
|
+
|
640
694
|
RSpec/SubjectStub:
|
641
695
|
Description: Checks for stubbed test subjects.
|
642
696
|
Enabled: true
|
@@ -692,6 +746,11 @@ RSpec/Yield:
|
|
692
746
|
VersionAdded: '1.32'
|
693
747
|
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Yield
|
694
748
|
|
749
|
+
RSpec/Capybara:
|
750
|
+
Enabled: true
|
751
|
+
Include: *1
|
752
|
+
Language: *2
|
753
|
+
|
695
754
|
RSpec/Capybara/CurrentPathExpectation:
|
696
755
|
Description: Checks that no expectations are set on Capybara's `current_path`.
|
697
756
|
Enabled: true
|
@@ -714,6 +773,11 @@ RSpec/Capybara/VisibilityMatcher:
|
|
714
773
|
VersionChanged: '2.0'
|
715
774
|
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Capybara/VisibilityMatcher
|
716
775
|
|
776
|
+
RSpec/FactoryBot:
|
777
|
+
Enabled: true
|
778
|
+
Include: *1
|
779
|
+
Language: *2
|
780
|
+
|
717
781
|
RSpec/FactoryBot/AttributeDefinedStatically:
|
718
782
|
Description: Always declare attribute values as blocks.
|
719
783
|
Enabled: true
|
@@ -753,6 +817,24 @@ RSpec/FactoryBot/FactoryClassName:
|
|
753
817
|
VersionChanged: '2.0'
|
754
818
|
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/FactoryBot/FactoryClassName
|
755
819
|
|
820
|
+
RSpec/FactoryBot/SyntaxMethods:
|
821
|
+
Description: Use shorthands from `FactoryBot::Syntax::Methods` in your specs.
|
822
|
+
Enabled: pending
|
823
|
+
SafeAutoCorrect: false
|
824
|
+
VersionAdded: '2.7'
|
825
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/FactoryBot/SyntaxMethods
|
826
|
+
|
827
|
+
RSpec/Rails:
|
828
|
+
Enabled: true
|
829
|
+
Include: *1
|
830
|
+
Language: *2
|
831
|
+
|
832
|
+
RSpec/Rails/AvoidSetupHook:
|
833
|
+
Description: Checks that tests use RSpec `before` hook over Rails `setup` method.
|
834
|
+
Enabled: pending
|
835
|
+
VersionAdded: '2.4'
|
836
|
+
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Rails/AvoidSetupHook
|
837
|
+
|
756
838
|
RSpec/Rails/HttpStatus:
|
757
839
|
Description: Enforces use of symbolic or numeric value to describe HTTP status.
|
758
840
|
Enabled: true
|
@@ -42,6 +42,7 @@ module RuboCop
|
|
42
42
|
# end
|
43
43
|
class FeatureMethods < Base
|
44
44
|
extend AutoCorrector
|
45
|
+
include InsideExampleGroup
|
45
46
|
|
46
47
|
MSG = 'Use `%<replacement>s` instead of `%<method>s`.'
|
47
48
|
|
@@ -60,13 +61,6 @@ module RuboCop
|
|
60
61
|
{#{MAP.keys.map(&:inspect).join(' ')}}
|
61
62
|
PATTERN
|
62
63
|
|
63
|
-
# @!method spec?(node)
|
64
|
-
def_node_matcher :spec?, <<-PATTERN
|
65
|
-
(block
|
66
|
-
(send #rspec? {:describe :feature} ...)
|
67
|
-
...)
|
68
|
-
PATTERN
|
69
|
-
|
70
64
|
# @!method feature_method(node)
|
71
65
|
def_node_matcher :feature_method, <<-PATTERN
|
72
66
|
(block
|
@@ -75,7 +69,7 @@ module RuboCop
|
|
75
69
|
PATTERN
|
76
70
|
|
77
71
|
def on_block(node)
|
78
|
-
return unless
|
72
|
+
return unless inside_example_group?(node)
|
79
73
|
|
80
74
|
feature_method(node) do |send_node, match|
|
81
75
|
next if enabled?(match)
|
@@ -93,21 +87,6 @@ module RuboCop
|
|
93
87
|
|
94
88
|
private
|
95
89
|
|
96
|
-
def inside_spec?(node)
|
97
|
-
return spec?(node) if root_node?(node)
|
98
|
-
|
99
|
-
root = node.ancestors.find { |parent| root_node?(parent) }
|
100
|
-
spec?(root)
|
101
|
-
end
|
102
|
-
|
103
|
-
def root_node?(node)
|
104
|
-
node.parent.nil? || root_with_siblings?(node.parent)
|
105
|
-
end
|
106
|
-
|
107
|
-
def root_with_siblings?(node)
|
108
|
-
node.begin_type? && node.parent.nil?
|
109
|
-
end
|
110
|
-
|
111
90
|
def enabled?(method_name)
|
112
91
|
enabled_methods.include?(method_name)
|
113
92
|
end
|
@@ -36,7 +36,10 @@ module RuboCop
|
|
36
36
|
def on_block(node)
|
37
37
|
empty_hook?(node) do |hook|
|
38
38
|
add_offense(hook) do |corrector|
|
39
|
-
range = range_with_surrounding_space(
|
39
|
+
range = range_with_surrounding_space(
|
40
|
+
range: node.loc.expression,
|
41
|
+
side: :left
|
42
|
+
)
|
40
43
|
corrector.remove(range)
|
41
44
|
end
|
42
45
|
end
|
@@ -0,0 +1,100 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module RSpec
|
6
|
+
# Checks for excessive whitespace in example descriptions.
|
7
|
+
#
|
8
|
+
# @example
|
9
|
+
# # bad
|
10
|
+
# it ' has excessive spacing ' do
|
11
|
+
# end
|
12
|
+
#
|
13
|
+
# # good
|
14
|
+
# it 'has excessive spacing' do
|
15
|
+
# end
|
16
|
+
#
|
17
|
+
# @example
|
18
|
+
# # bad
|
19
|
+
# context ' when a condition is met ' do
|
20
|
+
# end
|
21
|
+
#
|
22
|
+
# # good
|
23
|
+
# context 'when a condition is met' do
|
24
|
+
# end
|
25
|
+
class ExcessiveDocstringSpacing < Base
|
26
|
+
extend AutoCorrector
|
27
|
+
|
28
|
+
MSG = 'Excessive whitespace.'
|
29
|
+
|
30
|
+
# @!method example_description(node)
|
31
|
+
def_node_matcher :example_description, <<-PATTERN
|
32
|
+
(send _ {#Examples.all #ExampleGroups.all} ${
|
33
|
+
$str
|
34
|
+
$(dstr ({str dstr `sym} ...) ...)
|
35
|
+
} ...)
|
36
|
+
PATTERN
|
37
|
+
|
38
|
+
def on_send(node)
|
39
|
+
example_description(node) do |description_node, message|
|
40
|
+
return if description_node.heredoc?
|
41
|
+
|
42
|
+
text = text(message)
|
43
|
+
|
44
|
+
return unless excessive_whitespace?(text)
|
45
|
+
|
46
|
+
add_whitespace_offense(description_node, text)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
# @param text [String]
|
53
|
+
def excessive_whitespace?(text)
|
54
|
+
return true if text.start_with?(' ') || text.end_with?(' ')
|
55
|
+
|
56
|
+
text.match?(/[^\n ] +[^ ]/)
|
57
|
+
end
|
58
|
+
|
59
|
+
# @param text [String]
|
60
|
+
def strip_excessive_whitespace(text)
|
61
|
+
text.strip.gsub(/ +/, ' ')
|
62
|
+
end
|
63
|
+
|
64
|
+
# @param node [RuboCop::AST::Node]
|
65
|
+
# @param text [String]
|
66
|
+
def add_whitespace_offense(node, text)
|
67
|
+
docstring = docstring(node)
|
68
|
+
corrected = strip_excessive_whitespace(text)
|
69
|
+
|
70
|
+
add_offense(docstring) do |corrector|
|
71
|
+
corrector.replace(docstring, corrected)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def docstring(node)
|
76
|
+
expr = node.loc.expression
|
77
|
+
|
78
|
+
Parser::Source::Range.new(
|
79
|
+
expr.source_buffer,
|
80
|
+
expr.begin_pos + 1,
|
81
|
+
expr.end_pos - 1
|
82
|
+
)
|
83
|
+
end
|
84
|
+
|
85
|
+
# Recursive processing is required to process nested dstr nodes
|
86
|
+
# that is the case for \-separated multiline strings with interpolation.
|
87
|
+
def text(node)
|
88
|
+
case node.type
|
89
|
+
when :dstr
|
90
|
+
node.node_parts.map { |child_node| text(child_node) }.join
|
91
|
+
when :str, :sym
|
92
|
+
node.value
|
93
|
+
when :begin
|
94
|
+
node.source
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
@@ -39,7 +39,7 @@ module RuboCop
|
|
39
39
|
|
40
40
|
# @!method expect_change_with_arguments(node)
|
41
41
|
def_node_matcher :expect_change_with_arguments, <<-PATTERN
|
42
|
-
(send nil? :change
|
42
|
+
(send nil? :change $_ (sym $_))
|
43
43
|
PATTERN
|
44
44
|
|
45
45
|
# @!method expect_change_with_block(node)
|
@@ -55,9 +55,9 @@ module RuboCop
|
|
55
55
|
return unless style == :block
|
56
56
|
|
57
57
|
expect_change_with_arguments(node) do |receiver, message|
|
58
|
-
msg = format(MSG_CALL, obj: receiver, attr: message)
|
58
|
+
msg = format(MSG_CALL, obj: receiver.source, attr: message)
|
59
59
|
add_offense(node, message: msg) do |corrector|
|
60
|
-
replacement = "change { #{receiver}.#{message} }"
|
60
|
+
replacement = "change { #{receiver.source}.#{message} }"
|
61
61
|
corrector.replace(node, replacement)
|
62
62
|
end
|
63
63
|
end
|
@@ -27,6 +27,7 @@ module RuboCop
|
|
27
27
|
class CreateList < Base
|
28
28
|
extend AutoCorrector
|
29
29
|
include ConfigurableEnforcedStyle
|
30
|
+
include RuboCop::RSpec::FactoryBot::Language
|
30
31
|
|
31
32
|
MSG_CREATE_LIST = 'Prefer create_list.'
|
32
33
|
MSG_N_TIMES = 'Prefer %<number>s.times.'
|
@@ -43,12 +44,12 @@ module RuboCop
|
|
43
44
|
|
44
45
|
# @!method factory_call(node)
|
45
46
|
def_node_matcher :factory_call, <<-PATTERN
|
46
|
-
(send ${
|
47
|
+
(send ${nil? #factory_bot?} :create (sym $_) $...)
|
47
48
|
PATTERN
|
48
49
|
|
49
50
|
# @!method factory_list_call(node)
|
50
51
|
def_node_matcher :factory_list_call, <<-PATTERN
|
51
|
-
(send {
|
52
|
+
(send {nil? #factory_bot?} :create_list (sym _) (int $_) ...)
|
52
53
|
PATTERN
|
53
54
|
|
54
55
|
def on_block(node)
|
@@ -160,7 +161,7 @@ module RuboCop
|
|
160
161
|
def call_with_block_replacement(node)
|
161
162
|
block = node.body
|
162
163
|
arguments = build_arguments(block, node.receiver.source)
|
163
|
-
replacement = format_receiver(block.
|
164
|
+
replacement = format_receiver(block.receiver)
|
164
165
|
replacement += format_method_call(block, 'create_list', arguments)
|
165
166
|
replacement += format_block(block)
|
166
167
|
replacement
|
@@ -0,0 +1,107 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module RSpec
|
6
|
+
module FactoryBot
|
7
|
+
# Use shorthands from `FactoryBot::Syntax::Methods` in your specs.
|
8
|
+
#
|
9
|
+
# @safety
|
10
|
+
# The auto-correction is marked as unsafe because the cop
|
11
|
+
# cannot verify whether you already include
|
12
|
+
# `FactoryBot::Syntax::Methods` in your test suite.
|
13
|
+
#
|
14
|
+
# If you're using Rails, add the following configuration to
|
15
|
+
# `spec/support/factory_bot.rb` and be sure to require that file in
|
16
|
+
# `rails_helper.rb`:
|
17
|
+
#
|
18
|
+
# [source,ruby]
|
19
|
+
# ----
|
20
|
+
# RSpec.configure do |config|
|
21
|
+
# config.include FactoryBot::Syntax::Methods
|
22
|
+
# end
|
23
|
+
# ----
|
24
|
+
#
|
25
|
+
# If you're not using Rails:
|
26
|
+
#
|
27
|
+
# [source,ruby]
|
28
|
+
# ----
|
29
|
+
# RSpec.configure do |config|
|
30
|
+
# config.include FactoryBot::Syntax::Methods
|
31
|
+
#
|
32
|
+
# config.before(:suite) do
|
33
|
+
# FactoryBot.find_definitions
|
34
|
+
# end
|
35
|
+
# end
|
36
|
+
# ----
|
37
|
+
#
|
38
|
+
# @example
|
39
|
+
# # bad
|
40
|
+
# FactoryBot.create(:bar)
|
41
|
+
# FactoryBot.build(:bar)
|
42
|
+
# FactoryBot.attributes_for(:bar)
|
43
|
+
#
|
44
|
+
# # good
|
45
|
+
# create(:bar)
|
46
|
+
# build(:bar)
|
47
|
+
# attributes_for(:bar)
|
48
|
+
#
|
49
|
+
class SyntaxMethods < Base
|
50
|
+
extend AutoCorrector
|
51
|
+
include InsideExampleGroup
|
52
|
+
include RangeHelp
|
53
|
+
include RuboCop::RSpec::FactoryBot::Language
|
54
|
+
|
55
|
+
MSG = 'Use `%<method>s` from `FactoryBot::Syntax::Methods`.'
|
56
|
+
|
57
|
+
RESTRICT_ON_SEND = %i[
|
58
|
+
attributes_for
|
59
|
+
attributes_for_list
|
60
|
+
attributes_for_pair
|
61
|
+
build
|
62
|
+
build_list
|
63
|
+
build_pair
|
64
|
+
build_stubbed
|
65
|
+
build_stubbed_list
|
66
|
+
build_stubbed_pair
|
67
|
+
create
|
68
|
+
create_list
|
69
|
+
create_pair
|
70
|
+
generate
|
71
|
+
generate_list
|
72
|
+
null
|
73
|
+
null_list
|
74
|
+
null_pair
|
75
|
+
].to_set.freeze
|
76
|
+
|
77
|
+
def on_send(node)
|
78
|
+
return unless factory_bot?(node.receiver)
|
79
|
+
return unless inside_example_group?(node)
|
80
|
+
|
81
|
+
message = format(MSG, method: node.method_name)
|
82
|
+
|
83
|
+
add_offense(crime_scene(node), message: message) do |corrector|
|
84
|
+
corrector.remove(offense(node))
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
private
|
89
|
+
|
90
|
+
def crime_scene(node)
|
91
|
+
range_between(
|
92
|
+
node.loc.expression.begin_pos,
|
93
|
+
node.loc.selector.end_pos
|
94
|
+
)
|
95
|
+
end
|
96
|
+
|
97
|
+
def offense(node)
|
98
|
+
range_between(
|
99
|
+
node.loc.expression.begin_pos,
|
100
|
+
node.loc.selector.begin_pos
|
101
|
+
)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
@@ -61,10 +61,10 @@ module RuboCop
|
|
61
61
|
|
62
62
|
MSG = 'Spec path should end with `%<suffix>s`.'
|
63
63
|
|
64
|
-
# @!method
|
65
|
-
def_node_matcher :
|
64
|
+
# @!method example_group(node)
|
65
|
+
def_node_matcher :example_group, <<~PATTERN
|
66
66
|
(block
|
67
|
-
$(send #rspec? _example_group $
|
67
|
+
$(send #rspec? _example_group $_ $...) ...
|
68
68
|
)
|
69
69
|
PATTERN
|
70
70
|
|
@@ -74,17 +74,17 @@ module RuboCop
|
|
74
74
|
def on_top_level_example_group(node)
|
75
75
|
return unless top_level_groups.one?
|
76
76
|
|
77
|
-
|
77
|
+
example_group(node) do |send_node, example_group, arguments|
|
78
78
|
next if routing_spec?(arguments)
|
79
79
|
|
80
|
-
ensure_correct_file_path(send_node,
|
80
|
+
ensure_correct_file_path(send_node, example_group, arguments)
|
81
81
|
end
|
82
82
|
end
|
83
83
|
|
84
84
|
private
|
85
85
|
|
86
|
-
def ensure_correct_file_path(send_node,
|
87
|
-
pattern = pattern_for(
|
86
|
+
def ensure_correct_file_path(send_node, example_group, arguments)
|
87
|
+
pattern = pattern_for(example_group, arguments.first)
|
88
88
|
return if filename_ends_with?(pattern)
|
89
89
|
|
90
90
|
# For the suffix shown in the offense message, modify the regular
|
@@ -99,11 +99,13 @@ module RuboCop
|
|
99
99
|
args.any?(&method(:routing_metadata?))
|
100
100
|
end
|
101
101
|
|
102
|
-
def pattern_for(
|
103
|
-
|
102
|
+
def pattern_for(example_group, method_name)
|
103
|
+
if spec_suffix_only? || !example_group.const_type?
|
104
|
+
return pattern_for_spec_suffix_only?
|
105
|
+
end
|
104
106
|
|
105
107
|
[
|
106
|
-
expected_path(
|
108
|
+
expected_path(example_group),
|
107
109
|
name_pattern(method_name),
|
108
110
|
'[^/]*_spec\.rb'
|
109
111
|
].join
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module RSpec
|
6
|
+
# Checks for equality assertions with identical expressions on both sides.
|
7
|
+
#
|
8
|
+
# @example
|
9
|
+
#
|
10
|
+
# # bad
|
11
|
+
# expect(foo.bar).to eq(foo.bar)
|
12
|
+
# expect(foo.bar).to eql(foo.bar)
|
13
|
+
#
|
14
|
+
# # good
|
15
|
+
# expect(foo.bar).to eq(2)
|
16
|
+
# expect(foo.bar).to eql(2)
|
17
|
+
#
|
18
|
+
class IdenticalEqualityAssertion < Base
|
19
|
+
MSG = 'Identical expressions on both sides of the equality ' \
|
20
|
+
'may indicate a flawed test.'
|
21
|
+
RESTRICT_ON_SEND = %i[to].freeze
|
22
|
+
|
23
|
+
# @!method equality_check?(node)
|
24
|
+
def_node_matcher :equality_check?, <<~PATTERN
|
25
|
+
(send (send nil? :expect $_) :to
|
26
|
+
{(send nil? {:eql :eq :be} $_)
|
27
|
+
(send (send nil? :be) :== $_)})
|
28
|
+
PATTERN
|
29
|
+
|
30
|
+
def on_send(node)
|
31
|
+
equality_check?(node) do |left, right|
|
32
|
+
add_offense(node) if left == right
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -7,7 +7,7 @@ module RuboCop
|
|
7
7
|
#
|
8
8
|
# This cop can be configured using the `EnforcedStyle` option
|
9
9
|
#
|
10
|
-
# @example `EnforcedStyle: single_line_only`
|
10
|
+
# @example `EnforcedStyle: single_line_only` (default)
|
11
11
|
# # bad
|
12
12
|
# it do
|
13
13
|
# is_expected.to be_truthy
|
@@ -19,6 +19,22 @@ module RuboCop
|
|
19
19
|
# expect(subject).to be_truthy
|
20
20
|
# end
|
21
21
|
#
|
22
|
+
# @example `EnforcedStyle: single_statement_only`
|
23
|
+
# # bad
|
24
|
+
# it do
|
25
|
+
# foo = 1
|
26
|
+
# is_expected.to be_truthy
|
27
|
+
# end
|
28
|
+
#
|
29
|
+
# # good
|
30
|
+
# it do
|
31
|
+
# foo = 1
|
32
|
+
# expect(subject).to be_truthy
|
33
|
+
# end
|
34
|
+
# it do
|
35
|
+
# is_expected.to be_truthy
|
36
|
+
# end
|
37
|
+
#
|
22
38
|
# @example `EnforcedStyle: disallow`
|
23
39
|
# # bad
|
24
40
|
# it { is_expected.to be_truthy }
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module RSpec
|
6
|
+
# Helps you identify whether a given node
|
7
|
+
# is within an example group or not.
|
8
|
+
module InsideExampleGroup
|
9
|
+
private
|
10
|
+
|
11
|
+
def inside_example_group?(node)
|
12
|
+
return example_group?(node) if example_group_root?(node)
|
13
|
+
|
14
|
+
root = node.ancestors.find { |parent| example_group_root?(parent) }
|
15
|
+
|
16
|
+
example_group?(root)
|
17
|
+
end
|
18
|
+
|
19
|
+
def example_group_root?(node)
|
20
|
+
node.parent.nil? || example_group_root_with_siblings?(node.parent)
|
21
|
+
end
|
22
|
+
|
23
|
+
def example_group_root_with_siblings?(node)
|
24
|
+
node.begin_type? && node.parent.nil?
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module RSpec
|
6
|
+
module Rails
|
7
|
+
# Checks that tests use RSpec `before` hook over Rails `setup` method.
|
8
|
+
#
|
9
|
+
# @example
|
10
|
+
#
|
11
|
+
# # bad
|
12
|
+
# setup do
|
13
|
+
# allow(foo).to receive(:bar)
|
14
|
+
# end
|
15
|
+
#
|
16
|
+
# # good
|
17
|
+
# before do
|
18
|
+
# allow(foo).to receive(:bar)
|
19
|
+
# end
|
20
|
+
#
|
21
|
+
class AvoidSetupHook < Base
|
22
|
+
extend AutoCorrector
|
23
|
+
|
24
|
+
MSG = 'Use `before` instead of `setup`.'
|
25
|
+
|
26
|
+
# @!method setup_call(node)
|
27
|
+
def_node_matcher :setup_call, <<-PATTERN
|
28
|
+
(block
|
29
|
+
$(send nil? :setup)
|
30
|
+
(args) _)
|
31
|
+
PATTERN
|
32
|
+
|
33
|
+
def on_block(node)
|
34
|
+
setup_call(node) do |setup|
|
35
|
+
add_offense(node) do |corrector|
|
36
|
+
corrector.replace setup, 'before'
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module RSpec
|
6
|
+
# Ensure that subject is defined using subject helper.
|
7
|
+
#
|
8
|
+
# @example
|
9
|
+
#
|
10
|
+
# # bad
|
11
|
+
# let(:subject) { foo }
|
12
|
+
# let!(:subject) { foo }
|
13
|
+
# subject(:subject) { foo }
|
14
|
+
# subject!(:subject) { foo }
|
15
|
+
#
|
16
|
+
# # bad
|
17
|
+
# block = -> {}
|
18
|
+
# let(:subject, &block)
|
19
|
+
#
|
20
|
+
# # good
|
21
|
+
# subject(:test_subject) { foo }
|
22
|
+
#
|
23
|
+
class SubjectDeclaration < Base
|
24
|
+
MSG_LET = 'Use subject explicitly rather than using let'
|
25
|
+
MSG_REDUNDANT = 'Ambiguous declaration of subject'
|
26
|
+
|
27
|
+
# @!method offensive_subject_declaration?(node)
|
28
|
+
def_node_matcher :offensive_subject_declaration?, <<~PATTERN
|
29
|
+
(send nil? ${#Subjects.all #Helpers.all} {(sym :subject) (str "subject")} ...)
|
30
|
+
PATTERN
|
31
|
+
|
32
|
+
def on_send(node)
|
33
|
+
offense = offensive_subject_declaration?(node)
|
34
|
+
return unless offense
|
35
|
+
|
36
|
+
add_offense(node, message: message_for(offense))
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def message_for(offense)
|
42
|
+
Helpers.all(offense) ? MSG_LET : MSG_REDUNDANT
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -23,6 +23,7 @@ module RuboCop
|
|
23
23
|
# subject('user') { create_user }
|
24
24
|
# let('user_name') { 'Adam' }
|
25
25
|
class VariableDefinition < Base
|
26
|
+
extend AutoCorrector
|
26
27
|
include ConfigurableEnforcedStyle
|
27
28
|
include Variable
|
28
29
|
|
@@ -30,14 +31,30 @@ module RuboCop
|
|
30
31
|
|
31
32
|
def on_send(node)
|
32
33
|
variable_definition?(node) do |variable|
|
33
|
-
|
34
|
-
|
34
|
+
next unless style_violation?(variable)
|
35
|
+
|
36
|
+
add_offense(
|
37
|
+
variable,
|
38
|
+
message: format(MSG, style: style)
|
39
|
+
) do |corrector|
|
40
|
+
corrector.replace(variable, correct_variable(variable))
|
35
41
|
end
|
36
42
|
end
|
37
43
|
end
|
38
44
|
|
39
45
|
private
|
40
46
|
|
47
|
+
def correct_variable(variable)
|
48
|
+
case variable.type
|
49
|
+
when :dsym
|
50
|
+
variable.source[1..-1]
|
51
|
+
when :sym
|
52
|
+
variable.value.to_s.inspect
|
53
|
+
else
|
54
|
+
variable.value.to_sym.inspect
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
41
58
|
def style_violation?(variable)
|
42
59
|
style == :symbols && string?(variable) ||
|
43
60
|
style == :strings && symbol?(variable)
|
@@ -7,7 +7,9 @@ require_relative 'rspec/capybara/visibility_matcher'
|
|
7
7
|
require_relative 'rspec/factory_bot/attribute_defined_statically'
|
8
8
|
require_relative 'rspec/factory_bot/create_list'
|
9
9
|
require_relative 'rspec/factory_bot/factory_class_name'
|
10
|
+
require_relative 'rspec/factory_bot/syntax_methods'
|
10
11
|
|
12
|
+
require_relative 'rspec/rails/avoid_setup_hook'
|
11
13
|
begin
|
12
14
|
require_relative 'rspec/rails/http_status'
|
13
15
|
rescue LoadError
|
@@ -39,6 +41,7 @@ require_relative 'rspec/empty_line_after_subject'
|
|
39
41
|
require_relative 'rspec/example_length'
|
40
42
|
require_relative 'rspec/example_without_description'
|
41
43
|
require_relative 'rspec/example_wording'
|
44
|
+
require_relative 'rspec/excessive_docstring_spacing'
|
42
45
|
require_relative 'rspec/expect_actual'
|
43
46
|
require_relative 'rspec/expect_change'
|
44
47
|
require_relative 'rspec/expect_in_hook'
|
@@ -47,6 +50,7 @@ require_relative 'rspec/file_path'
|
|
47
50
|
require_relative 'rspec/focus'
|
48
51
|
require_relative 'rspec/hook_argument'
|
49
52
|
require_relative 'rspec/hooks_before_examples'
|
53
|
+
require_relative 'rspec/identical_equality_assertion'
|
50
54
|
require_relative 'rspec/implicit_block_expectation'
|
51
55
|
require_relative 'rspec/implicit_expect'
|
52
56
|
require_relative 'rspec/implicit_subject'
|
@@ -86,6 +90,7 @@ require_relative 'rspec/shared_context'
|
|
86
90
|
require_relative 'rspec/shared_examples'
|
87
91
|
require_relative 'rspec/single_argument_message_chain'
|
88
92
|
require_relative 'rspec/stubbed_mock'
|
93
|
+
require_relative 'rspec/subject_declaration'
|
89
94
|
require_relative 'rspec/subject_stub'
|
90
95
|
require_relative 'rspec/unspecified_exception'
|
91
96
|
require_relative 'rspec/variable_definition'
|
@@ -5,6 +5,7 @@ module RuboCop
|
|
5
5
|
# Shared behavior for aligning braces for single line lets
|
6
6
|
class AlignLetBrace
|
7
7
|
include RuboCop::RSpec::Language
|
8
|
+
include RuboCop::Cop::Util
|
8
9
|
|
9
10
|
def initialize(root, token)
|
10
11
|
@root = root
|
@@ -34,7 +35,7 @@ module RuboCop
|
|
34
35
|
def let_group_for(let)
|
35
36
|
adjacent_let_chunks.detect do |chunk|
|
36
37
|
chunk.any? do |member|
|
37
|
-
member == let && member
|
38
|
+
member == let && same_line?(member, let)
|
38
39
|
end
|
39
40
|
end
|
40
41
|
end
|
@@ -7,6 +7,7 @@ module RuboCop
|
|
7
7
|
# Builds a YAML config file from two config hashes
|
8
8
|
class ConfigFormatter
|
9
9
|
EXTENSION_ROOT_DEPARTMENT = %r{^(RSpec/)}.freeze
|
10
|
+
SUBDEPARTMENTS = %(RSpec/Capybara RSpec/FactoryBot RSpec/Rails)
|
10
11
|
STYLE_GUIDE_BASE_URL = 'https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/'
|
11
12
|
|
12
13
|
def initialize(config, descriptions)
|
@@ -24,6 +25,8 @@ module RuboCop
|
|
24
25
|
|
25
26
|
def unified_config
|
26
27
|
cops.each_with_object(config.dup) do |cop, unified|
|
28
|
+
next if SUBDEPARTMENTS.include?(cop)
|
29
|
+
|
27
30
|
unified[cop] = config.fetch(cop)
|
28
31
|
.merge(descriptions.fetch(cop))
|
29
32
|
.merge('StyleGuide' => STYLE_GUIDE_BASE_URL + cop.sub('RSpec/', ''))
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module RSpec
|
5
|
+
module FactoryBot
|
6
|
+
# Contains node matchers for common FactoryBot DSL.
|
7
|
+
module Language
|
8
|
+
extend RuboCop::NodePattern::Macros
|
9
|
+
|
10
|
+
# @!method factory_bot?(node)
|
11
|
+
def_node_matcher :factory_bot?, <<~PATTERN
|
12
|
+
(const {nil? cbase} {:FactoryGirl :FactoryBot})
|
13
|
+
PATTERN
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/rubocop-rspec.rb
CHANGED
@@ -12,11 +12,14 @@ require_relative 'rubocop/rspec/wording'
|
|
12
12
|
require_relative 'rubocop/rspec/language/node_pattern'
|
13
13
|
require_relative 'rubocop/rspec/language'
|
14
14
|
|
15
|
+
require_relative 'rubocop/rspec/factory_bot/language'
|
16
|
+
|
15
17
|
require_relative 'rubocop/cop/rspec/mixin/top_level_group'
|
16
18
|
require_relative 'rubocop/cop/rspec/mixin/variable'
|
17
19
|
require_relative 'rubocop/cop/rspec/mixin/final_end_location'
|
18
20
|
require_relative 'rubocop/cop/rspec/mixin/comments_help'
|
19
21
|
require_relative 'rubocop/cop/rspec/mixin/empty_line_separation'
|
22
|
+
require_relative 'rubocop/cop/rspec/mixin/inside_example_group'
|
20
23
|
|
21
24
|
require_relative 'rubocop/rspec/concept'
|
22
25
|
require_relative 'rubocop/rspec/example_group'
|
@@ -31,8 +34,8 @@ RuboCop::RSpec::Inject.defaults!
|
|
31
34
|
|
32
35
|
require_relative 'rubocop/cop/rspec_cops'
|
33
36
|
|
34
|
-
# We have to register our autocorrect
|
35
|
-
# so we do not hit infinite loops
|
37
|
+
# We have to register our autocorrect incompatibilities in RuboCop's cops
|
38
|
+
# as well so we do not hit infinite loops
|
36
39
|
|
37
40
|
module RuboCop
|
38
41
|
module Cop
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocop-rspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Backus
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2021-
|
13
|
+
date: 2021-12-26 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rubocop
|
@@ -18,28 +18,14 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - "~>"
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: '1.
|
21
|
+
version: '1.19'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
26
|
- - "~>"
|
27
27
|
- !ruby/object:Gem::Version
|
28
|
-
version: '1.
|
29
|
-
- !ruby/object:Gem::Dependency
|
30
|
-
name: rubocop-ast
|
31
|
-
requirement: !ruby/object:Gem::Requirement
|
32
|
-
requirements:
|
33
|
-
- - ">="
|
34
|
-
- !ruby/object:Gem::Version
|
35
|
-
version: 1.1.0
|
36
|
-
type: :runtime
|
37
|
-
prerelease: false
|
38
|
-
version_requirements: !ruby/object:Gem::Requirement
|
39
|
-
requirements:
|
40
|
-
- - ">="
|
41
|
-
- !ruby/object:Gem::Version
|
42
|
-
version: 1.1.0
|
28
|
+
version: '1.19'
|
43
29
|
- !ruby/object:Gem::Dependency
|
44
30
|
name: rack
|
45
31
|
requirement: !ruby/object:Gem::Requirement
|
@@ -97,19 +83,19 @@ dependencies:
|
|
97
83
|
- !ruby/object:Gem::Version
|
98
84
|
version: '1.7'
|
99
85
|
- !ruby/object:Gem::Dependency
|
100
|
-
name:
|
86
|
+
name: rubocop-rake
|
101
87
|
requirement: !ruby/object:Gem::Requirement
|
102
88
|
requirements:
|
103
|
-
- - "
|
89
|
+
- - "~>"
|
104
90
|
- !ruby/object:Gem::Version
|
105
|
-
version: '0.
|
91
|
+
version: '0.6'
|
106
92
|
type: :development
|
107
93
|
prerelease: false
|
108
94
|
version_requirements: !ruby/object:Gem::Requirement
|
109
95
|
requirements:
|
110
|
-
- - "
|
96
|
+
- - "~>"
|
111
97
|
- !ruby/object:Gem::Version
|
112
|
-
version: '0.
|
98
|
+
version: '0.6'
|
113
99
|
- !ruby/object:Gem::Dependency
|
114
100
|
name: yard
|
115
101
|
requirement: !ruby/object:Gem::Requirement
|
@@ -172,6 +158,7 @@ files:
|
|
172
158
|
- lib/rubocop/cop/rspec/example_length.rb
|
173
159
|
- lib/rubocop/cop/rspec/example_without_description.rb
|
174
160
|
- lib/rubocop/cop/rspec/example_wording.rb
|
161
|
+
- lib/rubocop/cop/rspec/excessive_docstring_spacing.rb
|
175
162
|
- lib/rubocop/cop/rspec/expect_actual.rb
|
176
163
|
- lib/rubocop/cop/rspec/expect_change.rb
|
177
164
|
- lib/rubocop/cop/rspec/expect_in_hook.rb
|
@@ -179,10 +166,12 @@ files:
|
|
179
166
|
- lib/rubocop/cop/rspec/factory_bot/attribute_defined_statically.rb
|
180
167
|
- lib/rubocop/cop/rspec/factory_bot/create_list.rb
|
181
168
|
- lib/rubocop/cop/rspec/factory_bot/factory_class_name.rb
|
169
|
+
- lib/rubocop/cop/rspec/factory_bot/syntax_methods.rb
|
182
170
|
- lib/rubocop/cop/rspec/file_path.rb
|
183
171
|
- lib/rubocop/cop/rspec/focus.rb
|
184
172
|
- lib/rubocop/cop/rspec/hook_argument.rb
|
185
173
|
- lib/rubocop/cop/rspec/hooks_before_examples.rb
|
174
|
+
- lib/rubocop/cop/rspec/identical_equality_assertion.rb
|
186
175
|
- lib/rubocop/cop/rspec/implicit_block_expectation.rb
|
187
176
|
- lib/rubocop/cop/rspec/implicit_expect.rb
|
188
177
|
- lib/rubocop/cop/rspec/implicit_subject.rb
|
@@ -201,6 +190,7 @@ files:
|
|
201
190
|
- lib/rubocop/cop/rspec/mixin/comments_help.rb
|
202
191
|
- lib/rubocop/cop/rspec/mixin/empty_line_separation.rb
|
203
192
|
- lib/rubocop/cop/rspec/mixin/final_end_location.rb
|
193
|
+
- lib/rubocop/cop/rspec/mixin/inside_example_group.rb
|
204
194
|
- lib/rubocop/cop/rspec/mixin/top_level_group.rb
|
205
195
|
- lib/rubocop/cop/rspec/mixin/variable.rb
|
206
196
|
- lib/rubocop/cop/rspec/multiple_describes.rb
|
@@ -213,6 +203,7 @@ files:
|
|
213
203
|
- lib/rubocop/cop/rspec/overwriting_setup.rb
|
214
204
|
- lib/rubocop/cop/rspec/pending.rb
|
215
205
|
- lib/rubocop/cop/rspec/predicate_matcher.rb
|
206
|
+
- lib/rubocop/cop/rspec/rails/avoid_setup_hook.rb
|
216
207
|
- lib/rubocop/cop/rspec/rails/http_status.rb
|
217
208
|
- lib/rubocop/cop/rspec/receive_counts.rb
|
218
209
|
- lib/rubocop/cop/rspec/receive_never.rb
|
@@ -228,6 +219,7 @@ files:
|
|
228
219
|
- lib/rubocop/cop/rspec/shared_examples.rb
|
229
220
|
- lib/rubocop/cop/rspec/single_argument_message_chain.rb
|
230
221
|
- lib/rubocop/cop/rspec/stubbed_mock.rb
|
222
|
+
- lib/rubocop/cop/rspec/subject_declaration.rb
|
231
223
|
- lib/rubocop/cop/rspec/subject_stub.rb
|
232
224
|
- lib/rubocop/cop/rspec/unspecified_exception.rb
|
233
225
|
- lib/rubocop/cop/rspec/variable_definition.rb
|
@@ -244,6 +236,7 @@ files:
|
|
244
236
|
- lib/rubocop/rspec/example.rb
|
245
237
|
- lib/rubocop/rspec/example_group.rb
|
246
238
|
- lib/rubocop/rspec/factory_bot.rb
|
239
|
+
- lib/rubocop/rspec/factory_bot/language.rb
|
247
240
|
- lib/rubocop/rspec/hook.rb
|
248
241
|
- lib/rubocop/rspec/inject.rb
|
249
242
|
- lib/rubocop/rspec/language.rb
|
@@ -257,6 +250,7 @@ licenses:
|
|
257
250
|
metadata:
|
258
251
|
changelog_uri: https://github.com/rubocop/rubocop-rspec/blob/master/CHANGELOG.md
|
259
252
|
documentation_uri: https://docs.rubocop.org/rubocop-rspec/
|
253
|
+
rubygems_mfa_required: 'true'
|
260
254
|
post_install_message:
|
261
255
|
rdoc_options: []
|
262
256
|
require_paths:
|
@@ -272,7 +266,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
272
266
|
- !ruby/object:Gem::Version
|
273
267
|
version: '0'
|
274
268
|
requirements: []
|
275
|
-
rubygems_version: 3.
|
269
|
+
rubygems_version: 3.3.1
|
276
270
|
signing_key:
|
277
271
|
specification_version: 4
|
278
272
|
summary: Code style checking for RSpec files
|