rubocop-rspec 1.15.1 → 1.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +20 -1
- data/Gemfile +0 -1
- data/config/default.yml +105 -0
- data/lib/rubocop-rspec.rb +27 -0
- data/lib/rubocop/cop/rspec/align_left_let_brace.rb +51 -0
- data/lib/rubocop/cop/rspec/align_right_let_brace.rb +51 -0
- data/lib/rubocop/cop/rspec/any_instance.rb +1 -1
- data/lib/rubocop/cop/rspec/cop.rb +4 -2
- data/lib/rubocop/cop/rspec/expect_in_hook.rb +61 -0
- data/lib/rubocop/cop/rspec/factory_girl/dynamic_attribute_defined_statically.rb +84 -0
- data/lib/rubocop/cop/rspec/hook_argument.rb +11 -5
- data/lib/rubocop/cop/rspec/invalid_predicate_matcher.rb +42 -0
- data/lib/rubocop/cop/rspec/let_before_examples.rb +66 -0
- data/lib/rubocop/cop/rspec/multiple_expectations.rb +3 -5
- data/lib/rubocop/cop/rspec/multiple_subjects.rb +80 -0
- data/lib/rubocop/cop/rspec/named_subject.rb +5 -6
- data/lib/rubocop/cop/rspec/overwriting_setup.rb +1 -1
- data/lib/rubocop/cop/rspec/predicate_matcher.rb +337 -0
- data/lib/rubocop/cop/rspec/return_from_stub.rb +83 -0
- data/lib/rubocop/cop/rspec/void_expect.rb +52 -0
- data/lib/rubocop/rspec/align_let_brace.rb +64 -0
- data/lib/rubocop/rspec/config_formatter.rb +7 -4
- data/lib/rubocop/rspec/description_extractor.rb +2 -2
- data/lib/rubocop/rspec/example_group.rb +25 -2
- data/lib/rubocop/rspec/factory_girl.rb +7 -0
- data/lib/rubocop/rspec/language.rb +6 -1
- data/lib/rubocop/rspec/version.rb +1 -1
- data/rubocop-rspec.gemspec +1 -4
- data/spec/project/default_config_spec.rb +8 -4
- data/spec/rubocop/cop/rspec/align_left_let_brace_spec.rb +62 -0
- data/spec/rubocop/cop/rspec/align_right_let_brace_spec.rb +62 -0
- data/spec/rubocop/cop/rspec/any_instance_spec.rb +3 -3
- data/spec/rubocop/cop/rspec/around_block_spec.rb +11 -11
- data/spec/rubocop/cop/rspec/be_eql_spec.rb +7 -7
- data/spec/rubocop/cop/rspec/before_after_all_spec.rb +4 -4
- data/spec/rubocop/cop/rspec/cop_spec.rb +7 -7
- data/spec/rubocop/cop/rspec/describe_class_spec.rb +18 -18
- data/spec/rubocop/cop/rspec/describe_method_spec.rb +4 -4
- data/spec/rubocop/cop/rspec/describe_symbol_spec.rb +6 -6
- data/spec/rubocop/cop/rspec/described_class_spec.rb +18 -18
- data/spec/rubocop/cop/rspec/empty_example_group_spec.rb +5 -5
- data/spec/rubocop/cop/rspec/empty_line_after_final_let_spec.rb +9 -9
- data/spec/rubocop/cop/rspec/empty_line_after_subject_spec.rb +5 -5
- data/spec/rubocop/cop/rspec/example_length_spec.rb +6 -6
- data/spec/rubocop/cop/rspec/example_wording_spec.rb +10 -10
- data/spec/rubocop/cop/rspec/expect_actual_spec.rb +10 -10
- data/spec/rubocop/cop/rspec/expect_in_hook_spec.rb +79 -0
- data/spec/rubocop/cop/rspec/expect_output_spec.rb +7 -7
- data/spec/rubocop/cop/rspec/factory_girl/dynamic_attribute_defined_statically_spec.rb +87 -0
- data/spec/rubocop/cop/rspec/file_path_spec.rb +29 -29
- data/spec/rubocop/cop/rspec/focus_spec.rb +6 -6
- data/spec/rubocop/cop/rspec/hook_argument_spec.rb +35 -23
- data/spec/rubocop/cop/rspec/implicit_expect_spec.rb +10 -10
- data/spec/rubocop/cop/rspec/instance_spy_spec.rb +4 -4
- data/spec/rubocop/cop/rspec/instance_variable_spec.rb +7 -7
- data/spec/rubocop/cop/rspec/invalid_predicate_matcher_spec.rb +37 -0
- data/spec/rubocop/cop/rspec/it_behaves_like_spec.rb +4 -4
- data/spec/rubocop/cop/rspec/iterated_expectation_spec.rb +8 -8
- data/spec/rubocop/cop/rspec/leading_subject_spec.rb +5 -5
- data/spec/rubocop/cop/rspec/let_before_examples_spec.rb +83 -0
- data/spec/rubocop/cop/rspec/let_setup_spec.rb +4 -4
- data/spec/rubocop/cop/rspec/message_chain_spec.rb +2 -2
- data/spec/rubocop/cop/rspec/message_expectation_spec.rb +4 -4
- data/spec/rubocop/cop/rspec/message_spies_spec.rb +18 -18
- data/spec/rubocop/cop/rspec/multiple_describes_spec.rb +3 -3
- data/spec/rubocop/cop/rspec/multiple_expectations_spec.rb +45 -9
- data/spec/rubocop/cop/rspec/multiple_subjects_spec.rb +96 -0
- data/spec/rubocop/cop/rspec/named_subject_spec.rb +4 -4
- data/spec/rubocop/cop/rspec/nested_groups_spec.rb +3 -3
- data/spec/rubocop/cop/rspec/not_to_not_spec.rb +4 -4
- data/spec/rubocop/cop/rspec/overwriting_setup_spec.rb +4 -4
- data/spec/rubocop/cop/rspec/predicate_matcher_spec.rb +335 -0
- data/spec/rubocop/cop/rspec/repeated_description_spec.rb +5 -5
- data/spec/rubocop/cop/rspec/repeated_example_spec.rb +5 -5
- data/spec/rubocop/cop/rspec/return_from_stub_spec.rb +85 -0
- data/spec/rubocop/cop/rspec/scattered_let_spec.rb +2 -2
- data/spec/rubocop/cop/rspec/scattered_setup_spec.rb +8 -8
- data/spec/rubocop/cop/rspec/shared_context_spec.rb +10 -10
- data/spec/rubocop/cop/rspec/single_argument_message_chain_spec.rb +10 -10
- data/spec/rubocop/cop/rspec/subject_stub_spec.rb +9 -9
- data/spec/rubocop/cop/rspec/verified_doubles_spec.rb +7 -7
- data/spec/rubocop/cop/rspec/void_expect_spec.rb +47 -0
- data/spec/rubocop/rspec/config_formatter_spec.rb +2 -0
- data/spec/spec_helper.rb +1 -1
- data/spec/support/expect_offense.rb +17 -0
- metadata +39 -51
- data/spec/expect_violation/expectation_spec.rb +0 -85
- data/spec/support/expect_violation.rb +0 -170
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da531fd6da6c4bc5ffa7012451f5d496e876621d
|
4
|
+
data.tar.gz: 68cf66d909464963445c3d5edff27f434bea6d5c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b97442d8f7fa551ffd4c85f76ca2bdfea664bc09a5ca5f3580f70c5c4f498da522017ef6a02b48caa0b8c8b9c6925f1edbfaf3f524265a6808b1cc01746732e
|
7
|
+
data.tar.gz: 4f228565a1e5842f9332b4af0dbd02084dc4203ab58c0f3f888560ac385af243ed66b4789596e621d669bdf1da1bdb3dd664f0d094981f54b525668b2fcc07a8
|
data/CHANGELOG.md
CHANGED
@@ -2,13 +2,29 @@
|
|
2
2
|
|
3
3
|
## Master (Unreleased)
|
4
4
|
|
5
|
+
## 1.16.0 (2017-09-06)
|
6
|
+
|
7
|
+
* Add `RSpec/FactoryGirl` namespace including the first cop for factories: `FactoryGirl/DynamicAttributeDefinedStatically`. ([@jonatas][])
|
8
|
+
* Add disabled by default `RSpec/AlignLeftLetBrace`. ([@backus][])
|
9
|
+
* Add disabled by default `RSpec/AlignRightLetBrace`. ([@backus][])
|
10
|
+
* Add `RSpec/LetBeforeExamples` cop. ([@Darhazer][])
|
11
|
+
* Add `RSpec/MultipleSubjects` cop. ([@backus][])
|
12
|
+
* Add `RSpec/ReturnFromStub` cop. ([@Darhazer][])
|
13
|
+
* Add `RSpec/VoidExpect` cop. ([@pocke][])
|
14
|
+
* Add `RSpec/InvalidPredicateMatcher` cop. ([@pocke][])
|
15
|
+
* Change HookArgument cop to detect when hook has a receiver. ([@pocke][])
|
16
|
+
* Add `RSpec/PredicateMatcher` cop. ([@pocke][])
|
17
|
+
* Add `RSpec/ExpectInHook` cop. ([@pocke][])
|
18
|
+
* `RSpec/MultipleExpectations` now detects usage of expect_any_instance_of. ([@Darhazer][])
|
19
|
+
* `RSpec/MultipleExpectations` now detects usage of is_expected. ([@bmorrall][])
|
20
|
+
|
5
21
|
## 1.15.1 (2017-04-30)
|
6
22
|
|
7
23
|
* Fix the handling of various edge cases in the `RSpec/ExampleWording` cop, including one that would cause autocorrect to crash. ([@dgollahon][])
|
8
24
|
* Fix `RSpec/IteratedExpectation` crashing when there is an assignment in the iteration. ([@Darhazer][])
|
9
25
|
* Fix false positive in `RSpec/SingleArgumentMessageChain` cop when the single argument is a hash. ([@Darhazer][])
|
10
26
|
|
11
|
-
## 1.15.0 (2017-03-
|
27
|
+
## 1.15.0 (2017-03-24)
|
12
28
|
|
13
29
|
* Add `RSpec/DescribeSymbol` cop. ([@tsigo][])
|
14
30
|
* Fix error when `RSpec/OverwritingSetup` and `RSpec/ScatteredLet` analyzed empty example groups. ([@backus][])
|
@@ -218,3 +234,6 @@
|
|
218
234
|
[@cfabianski]: https://github.com/cfabianski
|
219
235
|
[@dgollahon]: https://github.com/dgollahon
|
220
236
|
[@tsigo]: https://github.com/tsigo
|
237
|
+
[@jonatas]: https://github.com/jonatas
|
238
|
+
[@pocke]: https://github.com/pocke
|
239
|
+
[@bmorrall]: https:/github.com/bmorrall
|
data/Gemfile
CHANGED
data/config/default.yml
CHANGED
@@ -4,18 +4,35 @@ AllCops:
|
|
4
4
|
Patterns:
|
5
5
|
- _spec.rb
|
6
6
|
- "(?:^|/)spec/"
|
7
|
+
RSpec/FactoryGirl:
|
8
|
+
Patterns:
|
9
|
+
- spec/factories/**/*.rb
|
10
|
+
- features/support/factories/**/*.rb
|
7
11
|
|
8
12
|
RSpec/AnyInstance:
|
9
13
|
Description: Check that instances are not being stubbed globally.
|
10
14
|
Enabled: true
|
15
|
+
StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/AnyInstance
|
11
16
|
|
12
17
|
RSpec/AroundBlock:
|
13
18
|
Description: Checks that around blocks actually run the test.
|
14
19
|
Enabled: true
|
20
|
+
StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/AroundBlock
|
21
|
+
|
22
|
+
RSpec/AlignLeftLetBrace:
|
23
|
+
Description: Checks that left braces for adjacent single line lets are aligned.
|
24
|
+
Enabled: false
|
25
|
+
StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/AlignLeftLetBrace
|
26
|
+
|
27
|
+
RSpec/AlignRightLetBrace:
|
28
|
+
Description: Checks that right braces for adjacent single line lets are aligned.
|
29
|
+
Enabled: false
|
30
|
+
StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/AlignRightLetBrace
|
15
31
|
|
16
32
|
RSpec/BeEql:
|
17
33
|
Description: Check for expectations where `be(...)` can replace `eql(...)`.
|
18
34
|
Enabled: true
|
35
|
+
StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/BeEql
|
19
36
|
|
20
37
|
RSpec/BeforeAfterAll:
|
21
38
|
Description: Check that before/after(:all) isn't being used.
|
@@ -24,10 +41,12 @@ RSpec/BeforeAfterAll:
|
|
24
41
|
- spec/spec_helper.rb
|
25
42
|
- spec/rails_helper.rb
|
26
43
|
- spec/support/**/*.rb
|
44
|
+
StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/BeforeAfterAll
|
27
45
|
|
28
46
|
RSpec/DescribeClass:
|
29
47
|
Description: Check that the first argument to the top level describe is a constant.
|
30
48
|
Enabled: true
|
49
|
+
StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/DescribeClass
|
31
50
|
|
32
51
|
RSpec/DescribedClass:
|
33
52
|
Description: Checks that tests use `described_class`.
|
@@ -37,36 +56,44 @@ RSpec/DescribedClass:
|
|
37
56
|
SupportedStyles:
|
38
57
|
- described_class
|
39
58
|
- explicit
|
59
|
+
StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/DescribedClass
|
40
60
|
|
41
61
|
RSpec/DescribeMethod:
|
42
62
|
Description: Checks that the second argument to `describe` specifies a method.
|
43
63
|
Enabled: true
|
64
|
+
StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/DescribeMethod
|
44
65
|
|
45
66
|
RSpec/DescribeSymbol:
|
46
67
|
Description: Avoid describing symbols.
|
47
68
|
Enabled: true
|
69
|
+
StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/DescribeSymbol
|
48
70
|
|
49
71
|
RSpec/IteratedExpectation:
|
50
72
|
Description: Check that `all` matcher is used instead of iterating over an array.
|
51
73
|
Enabled: true
|
74
|
+
StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/IteratedExpectation
|
52
75
|
|
53
76
|
RSpec/EmptyExampleGroup:
|
54
77
|
Description: Checks if an example group does not include any tests.
|
55
78
|
Enabled: true
|
56
79
|
CustomIncludeMethods: []
|
80
|
+
StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/EmptyExampleGroup
|
57
81
|
|
58
82
|
RSpec/EmptyLineAfterFinalLet:
|
59
83
|
Description: Checks if there is an empty line after the last let block.
|
60
84
|
Enabled: true
|
85
|
+
StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/EmptyLineAfterFinalLet
|
61
86
|
|
62
87
|
RSpec/EmptyLineAfterSubject:
|
63
88
|
Description: Checks if there is an empty line after subject block.
|
64
89
|
Enabled: true
|
90
|
+
StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/EmptyLineAfterSubject
|
65
91
|
|
66
92
|
RSpec/ExampleLength:
|
67
93
|
Description: Checks for long examples.
|
68
94
|
Enabled: true
|
69
95
|
Max: 5
|
96
|
+
StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ExampleLength
|
70
97
|
|
71
98
|
RSpec/ExampleWording:
|
72
99
|
Description: Checks for common mistakes in example descriptions.
|
@@ -77,16 +104,24 @@ RSpec/ExampleWording:
|
|
77
104
|
have: has
|
78
105
|
HAVE: HAS
|
79
106
|
IgnoredWords: []
|
107
|
+
StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ExampleWording
|
80
108
|
|
81
109
|
RSpec/ExpectActual:
|
82
110
|
Description: Checks for `expect(...)` calls containing literal values.
|
83
111
|
Enabled: true
|
84
112
|
Exclude:
|
85
113
|
- spec/routing/**/*
|
114
|
+
StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ExpectActual
|
115
|
+
|
116
|
+
RSpec/ExpectInHook:
|
117
|
+
Enabled: true
|
118
|
+
Description: Do not use `expect` in hooks such as `before`.
|
119
|
+
StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ExpectInHook
|
86
120
|
|
87
121
|
RSpec/ExpectOutput:
|
88
122
|
Description: Checks for opportunities to use `expect { ... }.to output`.
|
89
123
|
Enabled: true
|
124
|
+
StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ExpectOutput
|
90
125
|
|
91
126
|
RSpec/FilePath:
|
92
127
|
Description: Checks that spec file paths are consistent with the test subject.
|
@@ -95,10 +130,12 @@ RSpec/FilePath:
|
|
95
130
|
RuboCop: rubocop
|
96
131
|
RSpec: rspec
|
97
132
|
IgnoreMethods: false
|
133
|
+
StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/FilePath
|
98
134
|
|
99
135
|
RSpec/Focus:
|
100
136
|
Description: Checks if examples are focused.
|
101
137
|
Enabled: true
|
138
|
+
StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Focus
|
102
139
|
|
103
140
|
RSpec/HookArgument:
|
104
141
|
Description: Checks the arguments passed to `before`, `around`, and `after`.
|
@@ -108,6 +145,7 @@ RSpec/HookArgument:
|
|
108
145
|
- implicit
|
109
146
|
- each
|
110
147
|
- example
|
148
|
+
StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/HookArgument
|
111
149
|
|
112
150
|
RSpec/ImplicitExpect:
|
113
151
|
Description: Check that a consistent implicit expectation style is used.
|
@@ -116,15 +154,23 @@ RSpec/ImplicitExpect:
|
|
116
154
|
SupportedStyles:
|
117
155
|
- is_expected
|
118
156
|
- should
|
157
|
+
StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ImplicitExpect
|
119
158
|
|
120
159
|
RSpec/InstanceSpy:
|
121
160
|
Description: Checks for `instance_double` used with `have_received`.
|
122
161
|
Enabled: true
|
162
|
+
StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/InstanceSpy
|
123
163
|
|
124
164
|
RSpec/InstanceVariable:
|
125
165
|
Description: Checks for instance variable usage in specs.
|
126
166
|
AssignmentOnly: false
|
127
167
|
Enabled: true
|
168
|
+
StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/InstanceVariable
|
169
|
+
|
170
|
+
RSpec/InvalidPredicateMatcher:
|
171
|
+
Description: Checks invalid usage for predicate matcher.
|
172
|
+
Enabled: true
|
173
|
+
StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/InvalidPredicateMatcher
|
128
174
|
|
129
175
|
RSpec/ItBehavesLike:
|
130
176
|
Description: Checks that only one `it_behaves_like` style is used.
|
@@ -133,18 +179,27 @@ RSpec/ItBehavesLike:
|
|
133
179
|
SupportedStyles:
|
134
180
|
- it_behaves_like
|
135
181
|
- it_should_behave_like
|
182
|
+
StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ItBehavesLike
|
136
183
|
|
137
184
|
RSpec/LeadingSubject:
|
138
185
|
Description: Checks for `subject` definitions that come after `let` definitions.
|
139
186
|
Enabled: true
|
187
|
+
StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/LeadingSubject
|
188
|
+
|
189
|
+
RSpec/LetBeforeExamples:
|
190
|
+
Description: Checks for `let` definitions that come after an example.
|
191
|
+
Enabled: true
|
192
|
+
StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/LetBeforeExamples
|
140
193
|
|
141
194
|
RSpec/LetSetup:
|
142
195
|
Description: Checks unreferenced `let!` calls being used for test setup.
|
143
196
|
Enabled: true
|
197
|
+
StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/LetSetup
|
144
198
|
|
145
199
|
RSpec/MessageChain:
|
146
200
|
Description: Check that chains of messages are not being stubbed.
|
147
201
|
Enabled: true
|
202
|
+
StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/MessageChain
|
148
203
|
|
149
204
|
RSpec/MessageExpectation:
|
150
205
|
Description: Checks for consistent message expectation style.
|
@@ -153,6 +208,7 @@ RSpec/MessageExpectation:
|
|
153
208
|
SupportedStyles:
|
154
209
|
- allow
|
155
210
|
- expect
|
211
|
+
StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/MessageExpectation
|
156
212
|
|
157
213
|
RSpec/MessageSpies:
|
158
214
|
Description: Checks that message expectations are set using spies.
|
@@ -161,24 +217,34 @@ RSpec/MessageSpies:
|
|
161
217
|
SupportedStyles:
|
162
218
|
- have_received
|
163
219
|
- receive
|
220
|
+
StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/MessageSpies
|
164
221
|
|
165
222
|
RSpec/MultipleDescribes:
|
166
223
|
Description: Checks for multiple top level describes.
|
167
224
|
Enabled: true
|
225
|
+
StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/MultipleDescribes
|
168
226
|
|
169
227
|
RSpec/MultipleExpectations:
|
170
228
|
Description: Checks if examples contain too many `expect` calls.
|
171
229
|
Enabled: true
|
172
230
|
Max: 1
|
231
|
+
StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/MultipleExpectations
|
232
|
+
|
233
|
+
RSpec/MultipleSubjects:
|
234
|
+
Description: Checks if an example group defines `subject` multiple times.
|
235
|
+
Enabled: true
|
236
|
+
StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/MultipleSubjects
|
173
237
|
|
174
238
|
RSpec/NamedSubject:
|
175
239
|
Description: Checks for explicitly referenced test subjects.
|
176
240
|
Enabled: true
|
241
|
+
StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/NamedSubject
|
177
242
|
|
178
243
|
RSpec/NestedGroups:
|
179
244
|
Description: Checks for nested example groups.
|
180
245
|
Enabled: true
|
181
246
|
Max: 3
|
247
|
+
StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/NestedGroups
|
182
248
|
|
183
249
|
RSpec/NotToNot:
|
184
250
|
Description: Checks for consistent method usage for negating expectations.
|
@@ -187,40 +253,79 @@ RSpec/NotToNot:
|
|
187
253
|
- not_to
|
188
254
|
- to_not
|
189
255
|
Enabled: true
|
256
|
+
StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/NotToNot
|
190
257
|
|
191
258
|
RSpec/OverwritingSetup:
|
192
259
|
Enabled: true
|
193
260
|
Description: Checks if there is a let/subject that overwrites an existing one.
|
261
|
+
StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/OverwritingSetup
|
194
262
|
|
195
263
|
RSpec/RepeatedDescription:
|
196
264
|
Enabled: true
|
197
265
|
Description: Check for repeated description strings in example groups.
|
266
|
+
StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/RepeatedDescription
|
198
267
|
|
199
268
|
RSpec/RepeatedExample:
|
200
269
|
Enabled: true
|
201
270
|
Description: Check for repeated examples within example groups.
|
271
|
+
StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/RepeatedExample
|
272
|
+
|
273
|
+
RSpec/ReturnFromStub:
|
274
|
+
Enabled: true
|
275
|
+
Description: Checks for consistent style of stub's return setting.
|
276
|
+
EnforcedStyle: and_return
|
277
|
+
SupportedStyles:
|
278
|
+
- and_return
|
279
|
+
- block
|
280
|
+
StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ReturnFromStub
|
202
281
|
|
203
282
|
RSpec/SharedContext:
|
204
283
|
Description: Checks for proper shared_context and shared_examples usage.
|
205
284
|
Enabled: true
|
285
|
+
StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/SharedContext
|
206
286
|
|
207
287
|
RSpec/SingleArgumentMessageChain:
|
208
288
|
Description: Checks that chains of messages contain more than one element.
|
209
289
|
Enabled: true
|
290
|
+
StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/SingleArgumentMessageChain
|
210
291
|
|
211
292
|
RSpec/ScatteredLet:
|
212
293
|
Description: Checks for let scattered across the example group.
|
213
294
|
Enabled: true
|
295
|
+
StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ScatteredLet
|
214
296
|
|
215
297
|
RSpec/ScatteredSetup:
|
216
298
|
Description: Checks for setup scattered across multiple hooks in an example group.
|
217
299
|
Enabled: true
|
300
|
+
StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ScatteredSetup
|
218
301
|
|
219
302
|
RSpec/SubjectStub:
|
220
303
|
Description: Checks for stubbed test subjects.
|
221
304
|
Enabled: true
|
305
|
+
StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/SubjectStub
|
306
|
+
|
307
|
+
RSpec/PredicateMatcher:
|
308
|
+
Description: Prefer using predicate matcher over using predicate method directly.
|
309
|
+
Enabled: true
|
310
|
+
Strict: true
|
311
|
+
EnforcedStyle: inflected
|
312
|
+
SupportedStyles:
|
313
|
+
- inflected
|
314
|
+
- explicit
|
315
|
+
StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/PredicateMatcher
|
222
316
|
|
223
317
|
RSpec/VerifiedDoubles:
|
224
318
|
Description: Prefer using verifying doubles over normal doubles.
|
225
319
|
Enabled: true
|
226
320
|
IgnoreSymbolicNames: false
|
321
|
+
StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/VerifiedDoubles
|
322
|
+
|
323
|
+
RSpec/VoidExpect:
|
324
|
+
Description: This cop checks void `expect()`.
|
325
|
+
Enabled: true
|
326
|
+
StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/VoidExpect
|
327
|
+
|
328
|
+
FactoryGirl/DynamicAttributeDefinedStatically:
|
329
|
+
Description: Prefer declaring dynamic attribute values in a block.
|
330
|
+
Enabled: true
|
331
|
+
StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/FactoryGirl/DynamicAttributeDefinedStatically
|
data/lib/rubocop-rspec.rb
CHANGED
@@ -16,10 +16,14 @@ require 'rubocop/rspec/example_group'
|
|
16
16
|
require 'rubocop/rspec/example'
|
17
17
|
require 'rubocop/rspec/hook'
|
18
18
|
require 'rubocop/cop/rspec/cop'
|
19
|
+
require 'rubocop/rspec/align_let_brace'
|
20
|
+
require 'rubocop/rspec/factory_girl'
|
19
21
|
|
20
22
|
RuboCop::RSpec::Inject.defaults!
|
21
23
|
|
22
24
|
# cops
|
25
|
+
require 'rubocop/cop/rspec/align_left_let_brace'
|
26
|
+
require 'rubocop/cop/rspec/align_right_let_brace'
|
23
27
|
require 'rubocop/cop/rspec/any_instance'
|
24
28
|
require 'rubocop/cop/rspec/around_block'
|
25
29
|
require 'rubocop/cop/rspec/be_eql'
|
@@ -34,31 +38,54 @@ require 'rubocop/cop/rspec/empty_line_after_subject'
|
|
34
38
|
require 'rubocop/cop/rspec/example_length'
|
35
39
|
require 'rubocop/cop/rspec/example_wording'
|
36
40
|
require 'rubocop/cop/rspec/expect_actual'
|
41
|
+
require 'rubocop/cop/rspec/expect_in_hook'
|
37
42
|
require 'rubocop/cop/rspec/expect_output'
|
43
|
+
require 'rubocop/cop/rspec/factory_girl/dynamic_attribute_defined_statically'
|
38
44
|
require 'rubocop/cop/rspec/file_path'
|
39
45
|
require 'rubocop/cop/rspec/focus'
|
40
46
|
require 'rubocop/cop/rspec/hook_argument'
|
41
47
|
require 'rubocop/cop/rspec/implicit_expect'
|
42
48
|
require 'rubocop/cop/rspec/instance_spy'
|
43
49
|
require 'rubocop/cop/rspec/instance_variable'
|
50
|
+
require 'rubocop/cop/rspec/invalid_predicate_matcher'
|
44
51
|
require 'rubocop/cop/rspec/it_behaves_like'
|
45
52
|
require 'rubocop/cop/rspec/iterated_expectation'
|
46
53
|
require 'rubocop/cop/rspec/leading_subject'
|
54
|
+
require 'rubocop/cop/rspec/let_before_examples'
|
47
55
|
require 'rubocop/cop/rspec/let_setup'
|
48
56
|
require 'rubocop/cop/rspec/message_chain'
|
49
57
|
require 'rubocop/cop/rspec/message_expectation'
|
50
58
|
require 'rubocop/cop/rspec/message_spies'
|
51
59
|
require 'rubocop/cop/rspec/multiple_describes'
|
52
60
|
require 'rubocop/cop/rspec/multiple_expectations'
|
61
|
+
require 'rubocop/cop/rspec/multiple_subjects'
|
53
62
|
require 'rubocop/cop/rspec/named_subject'
|
54
63
|
require 'rubocop/cop/rspec/nested_groups'
|
55
64
|
require 'rubocop/cop/rspec/not_to_not'
|
56
65
|
require 'rubocop/cop/rspec/overwriting_setup'
|
57
66
|
require 'rubocop/cop/rspec/repeated_description'
|
58
67
|
require 'rubocop/cop/rspec/repeated_example'
|
68
|
+
require 'rubocop/cop/rspec/return_from_stub'
|
59
69
|
require 'rubocop/cop/rspec/scattered_let'
|
60
70
|
require 'rubocop/cop/rspec/scattered_setup'
|
61
71
|
require 'rubocop/cop/rspec/shared_context'
|
62
72
|
require 'rubocop/cop/rspec/single_argument_message_chain'
|
63
73
|
require 'rubocop/cop/rspec/subject_stub'
|
74
|
+
require 'rubocop/cop/rspec/predicate_matcher'
|
64
75
|
require 'rubocop/cop/rspec/verified_doubles'
|
76
|
+
require 'rubocop/cop/rspec/void_expect'
|
77
|
+
|
78
|
+
# We have to register our autocorrect incompatibilies in RuboCop's cops as well
|
79
|
+
# so we do not hit infinite loops
|
80
|
+
|
81
|
+
module RuboCop
|
82
|
+
module Cop
|
83
|
+
module Layout
|
84
|
+
class ExtraSpacing # rubocop:disable Style/Documentation
|
85
|
+
def self.autocorrect_incompatible_with
|
86
|
+
[RSpec::AlignLeftLetBrace, RSpec::AlignRightLetBrace]
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module RSpec
|
6
|
+
# Checks that left braces for adjacent single line lets are aligned.
|
7
|
+
#
|
8
|
+
# @example
|
9
|
+
#
|
10
|
+
# # bad
|
11
|
+
# let(:foobar) { blahblah }
|
12
|
+
# let(:baz) { bar }
|
13
|
+
# let(:a) { b }
|
14
|
+
#
|
15
|
+
# # good
|
16
|
+
# let(:foobar) { blahblah }
|
17
|
+
# let(:baz) { bar }
|
18
|
+
# let(:a) { b }
|
19
|
+
#
|
20
|
+
class AlignLeftLetBrace < Cop
|
21
|
+
MSG = 'Align left let brace'.freeze
|
22
|
+
|
23
|
+
def self.autocorrect_incompatible_with
|
24
|
+
[Layout::ExtraSpacing]
|
25
|
+
end
|
26
|
+
|
27
|
+
def investigate(_)
|
28
|
+
token_aligner.offending_tokens.each do |let|
|
29
|
+
add_offense(let, :begin)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def autocorrect(let)
|
34
|
+
lambda do |corrector|
|
35
|
+
corrector.insert_before(
|
36
|
+
let.loc.begin,
|
37
|
+
token_aligner.indent_for(let)
|
38
|
+
)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def token_aligner
|
45
|
+
@token_aligner ||=
|
46
|
+
RuboCop::RSpec::AlignLetBrace.new(processed_source.ast, :begin)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|