rubocop-rspec 1.15.1 → 1.16.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +20 -1
  3. data/Gemfile +0 -1
  4. data/config/default.yml +105 -0
  5. data/lib/rubocop-rspec.rb +27 -0
  6. data/lib/rubocop/cop/rspec/align_left_let_brace.rb +51 -0
  7. data/lib/rubocop/cop/rspec/align_right_let_brace.rb +51 -0
  8. data/lib/rubocop/cop/rspec/any_instance.rb +1 -1
  9. data/lib/rubocop/cop/rspec/cop.rb +4 -2
  10. data/lib/rubocop/cop/rspec/expect_in_hook.rb +61 -0
  11. data/lib/rubocop/cop/rspec/factory_girl/dynamic_attribute_defined_statically.rb +84 -0
  12. data/lib/rubocop/cop/rspec/hook_argument.rb +11 -5
  13. data/lib/rubocop/cop/rspec/invalid_predicate_matcher.rb +42 -0
  14. data/lib/rubocop/cop/rspec/let_before_examples.rb +66 -0
  15. data/lib/rubocop/cop/rspec/multiple_expectations.rb +3 -5
  16. data/lib/rubocop/cop/rspec/multiple_subjects.rb +80 -0
  17. data/lib/rubocop/cop/rspec/named_subject.rb +5 -6
  18. data/lib/rubocop/cop/rspec/overwriting_setup.rb +1 -1
  19. data/lib/rubocop/cop/rspec/predicate_matcher.rb +337 -0
  20. data/lib/rubocop/cop/rspec/return_from_stub.rb +83 -0
  21. data/lib/rubocop/cop/rspec/void_expect.rb +52 -0
  22. data/lib/rubocop/rspec/align_let_brace.rb +64 -0
  23. data/lib/rubocop/rspec/config_formatter.rb +7 -4
  24. data/lib/rubocop/rspec/description_extractor.rb +2 -2
  25. data/lib/rubocop/rspec/example_group.rb +25 -2
  26. data/lib/rubocop/rspec/factory_girl.rb +7 -0
  27. data/lib/rubocop/rspec/language.rb +6 -1
  28. data/lib/rubocop/rspec/version.rb +1 -1
  29. data/rubocop-rspec.gemspec +1 -4
  30. data/spec/project/default_config_spec.rb +8 -4
  31. data/spec/rubocop/cop/rspec/align_left_let_brace_spec.rb +62 -0
  32. data/spec/rubocop/cop/rspec/align_right_let_brace_spec.rb +62 -0
  33. data/spec/rubocop/cop/rspec/any_instance_spec.rb +3 -3
  34. data/spec/rubocop/cop/rspec/around_block_spec.rb +11 -11
  35. data/spec/rubocop/cop/rspec/be_eql_spec.rb +7 -7
  36. data/spec/rubocop/cop/rspec/before_after_all_spec.rb +4 -4
  37. data/spec/rubocop/cop/rspec/cop_spec.rb +7 -7
  38. data/spec/rubocop/cop/rspec/describe_class_spec.rb +18 -18
  39. data/spec/rubocop/cop/rspec/describe_method_spec.rb +4 -4
  40. data/spec/rubocop/cop/rspec/describe_symbol_spec.rb +6 -6
  41. data/spec/rubocop/cop/rspec/described_class_spec.rb +18 -18
  42. data/spec/rubocop/cop/rspec/empty_example_group_spec.rb +5 -5
  43. data/spec/rubocop/cop/rspec/empty_line_after_final_let_spec.rb +9 -9
  44. data/spec/rubocop/cop/rspec/empty_line_after_subject_spec.rb +5 -5
  45. data/spec/rubocop/cop/rspec/example_length_spec.rb +6 -6
  46. data/spec/rubocop/cop/rspec/example_wording_spec.rb +10 -10
  47. data/spec/rubocop/cop/rspec/expect_actual_spec.rb +10 -10
  48. data/spec/rubocop/cop/rspec/expect_in_hook_spec.rb +79 -0
  49. data/spec/rubocop/cop/rspec/expect_output_spec.rb +7 -7
  50. data/spec/rubocop/cop/rspec/factory_girl/dynamic_attribute_defined_statically_spec.rb +87 -0
  51. data/spec/rubocop/cop/rspec/file_path_spec.rb +29 -29
  52. data/spec/rubocop/cop/rspec/focus_spec.rb +6 -6
  53. data/spec/rubocop/cop/rspec/hook_argument_spec.rb +35 -23
  54. data/spec/rubocop/cop/rspec/implicit_expect_spec.rb +10 -10
  55. data/spec/rubocop/cop/rspec/instance_spy_spec.rb +4 -4
  56. data/spec/rubocop/cop/rspec/instance_variable_spec.rb +7 -7
  57. data/spec/rubocop/cop/rspec/invalid_predicate_matcher_spec.rb +37 -0
  58. data/spec/rubocop/cop/rspec/it_behaves_like_spec.rb +4 -4
  59. data/spec/rubocop/cop/rspec/iterated_expectation_spec.rb +8 -8
  60. data/spec/rubocop/cop/rspec/leading_subject_spec.rb +5 -5
  61. data/spec/rubocop/cop/rspec/let_before_examples_spec.rb +83 -0
  62. data/spec/rubocop/cop/rspec/let_setup_spec.rb +4 -4
  63. data/spec/rubocop/cop/rspec/message_chain_spec.rb +2 -2
  64. data/spec/rubocop/cop/rspec/message_expectation_spec.rb +4 -4
  65. data/spec/rubocop/cop/rspec/message_spies_spec.rb +18 -18
  66. data/spec/rubocop/cop/rspec/multiple_describes_spec.rb +3 -3
  67. data/spec/rubocop/cop/rspec/multiple_expectations_spec.rb +45 -9
  68. data/spec/rubocop/cop/rspec/multiple_subjects_spec.rb +96 -0
  69. data/spec/rubocop/cop/rspec/named_subject_spec.rb +4 -4
  70. data/spec/rubocop/cop/rspec/nested_groups_spec.rb +3 -3
  71. data/spec/rubocop/cop/rspec/not_to_not_spec.rb +4 -4
  72. data/spec/rubocop/cop/rspec/overwriting_setup_spec.rb +4 -4
  73. data/spec/rubocop/cop/rspec/predicate_matcher_spec.rb +335 -0
  74. data/spec/rubocop/cop/rspec/repeated_description_spec.rb +5 -5
  75. data/spec/rubocop/cop/rspec/repeated_example_spec.rb +5 -5
  76. data/spec/rubocop/cop/rspec/return_from_stub_spec.rb +85 -0
  77. data/spec/rubocop/cop/rspec/scattered_let_spec.rb +2 -2
  78. data/spec/rubocop/cop/rspec/scattered_setup_spec.rb +8 -8
  79. data/spec/rubocop/cop/rspec/shared_context_spec.rb +10 -10
  80. data/spec/rubocop/cop/rspec/single_argument_message_chain_spec.rb +10 -10
  81. data/spec/rubocop/cop/rspec/subject_stub_spec.rb +9 -9
  82. data/spec/rubocop/cop/rspec/verified_doubles_spec.rb +7 -7
  83. data/spec/rubocop/cop/rspec/void_expect_spec.rb +47 -0
  84. data/spec/rubocop/rspec/config_formatter_spec.rb +2 -0
  85. data/spec/spec_helper.rb +1 -1
  86. data/spec/support/expect_offense.rb +17 -0
  87. metadata +39 -51
  88. data/spec/expect_violation/expectation_spec.rb +0 -85
  89. data/spec/support/expect_violation.rb +0 -170
@@ -2,7 +2,7 @@ RSpec.describe RuboCop::Cop::RSpec::VerifiedDoubles, :config do
2
2
  subject(:cop) { described_class.new(config) }
3
3
 
4
4
  it 'finds a `double` instead of an `instance_double`' do
5
- expect_violation(<<-RUBY)
5
+ expect_offense(<<-RUBY)
6
6
  it do
7
7
  foo = double("Widget")
8
8
  ^^^^^^^^^^^^^^^^ Prefer using verifying doubles over normal doubles.
@@ -14,7 +14,7 @@ RSpec.describe RuboCop::Cop::RSpec::VerifiedDoubles, :config do
14
14
  let(:cop_config) { {} }
15
15
 
16
16
  it 'find doubles whose name is a symbol' do
17
- expect_violation(<<-RUBY)
17
+ expect_offense(<<-RUBY)
18
18
  it do
19
19
  foo = double(:widget)
20
20
  ^^^^^^^^^^^^^^^ Prefer using verifying doubles over normal doubles.
@@ -23,7 +23,7 @@ RSpec.describe RuboCop::Cop::RSpec::VerifiedDoubles, :config do
23
23
  end
24
24
 
25
25
  it 'finds a `spy` instead of an `instance_spy`' do
26
- expect_violation(<<-RUBY)
26
+ expect_offense(<<-RUBY)
27
27
  it do
28
28
  foo = spy("Widget")
29
29
  ^^^^^^^^^^^^^ Prefer using verifying doubles over normal doubles.
@@ -36,7 +36,7 @@ RSpec.describe RuboCop::Cop::RSpec::VerifiedDoubles, :config do
36
36
  let(:cop_config) { { 'IgnoreSymbolicNames' => true } }
37
37
 
38
38
  it 'ignores doubles whose name is a symbol' do
39
- expect_no_violations(<<-RUBY)
39
+ expect_no_offenses(<<-RUBY)
40
40
  it do
41
41
  foo = double(:widget)
42
42
  end
@@ -44,7 +44,7 @@ RSpec.describe RuboCop::Cop::RSpec::VerifiedDoubles, :config do
44
44
  end
45
45
 
46
46
  it 'still flags doubles whose name is a string' do
47
- expect_violation(<<-RUBY)
47
+ expect_offense(<<-RUBY)
48
48
  it do
49
49
  foo = double("widget")
50
50
  ^^^^^^^^^^^^^^^^ Prefer using verifying doubles over normal doubles.
@@ -54,7 +54,7 @@ RSpec.describe RuboCop::Cop::RSpec::VerifiedDoubles, :config do
54
54
  end
55
55
 
56
56
  it 'ignores doubles without a name' do
57
- expect_no_violations(<<-RUBY)
57
+ expect_no_offenses(<<-RUBY)
58
58
  it do
59
59
  foo = double
60
60
  end
@@ -62,7 +62,7 @@ RSpec.describe RuboCop::Cop::RSpec::VerifiedDoubles, :config do
62
62
  end
63
63
 
64
64
  it 'ignores instance_doubles' do
65
- expect_no_violations(<<-RUBY)
65
+ expect_no_offenses(<<-RUBY)
66
66
  it do
67
67
  foo = instance_double("Foo")
68
68
  end
@@ -0,0 +1,47 @@
1
+ RSpec.describe RuboCop::Cop::RSpec::VoidExpect do
2
+ subject(:cop) { described_class.new }
3
+
4
+ it 'registers offenses to void `expect`' do
5
+ expect_offense(<<-RUBY)
6
+ it 'something' do
7
+ something = 1
8
+ expect(something)
9
+ ^^^^^^^^^^^^^^^^^ Do not use `expect()` without `.to` or `.not_to`. Chain the methods or remove it.
10
+ end
11
+ RUBY
12
+ end
13
+
14
+ it 'registers offenses to void `expect` when block has one expression' do
15
+ expect_offense(<<-RUBY)
16
+ it 'something' do
17
+ expect(something)
18
+ ^^^^^^^^^^^^^^^^^ Do not use `expect()` without `.to` or `.not_to`. Chain the methods or remove it.
19
+ end
20
+ RUBY
21
+ end
22
+
23
+ it 'registers offenses to void `expect` with block' do
24
+ expect_offense(<<-RUBY)
25
+ it 'something' do
26
+ expect{something}
27
+ ^^^^^^^^^^^^^^^^^ Do not use `expect()` without `.to` or `.not_to`. Chain the methods or remove it.
28
+ end
29
+ RUBY
30
+ end
31
+
32
+ it 'accepts non-void `expect`' do
33
+ expect_no_offenses(<<-RUBY)
34
+ it 'something' do
35
+ expect(something).to be 1
36
+ end
37
+ RUBY
38
+ end
39
+
40
+ it 'accepts non-void `expect` with block' do
41
+ expect_no_offenses(<<-RUBY)
42
+ it 'something' do
43
+ expect{something}.to raise_error(StandardError)
44
+ end
45
+ RUBY
46
+ end
47
+ end
@@ -39,10 +39,12 @@ RSpec.describe RuboCop::RSpec::ConfigFormatter do
39
39
  | Config: 2
40
40
  | Enabled: true
41
41
  | Description: Blah
42
+ | StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Foo
42
43
  |
43
44
  |RSpec/Bar:
44
45
  | Enabled: true
45
46
  | Description: Wow
47
+ | StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Bar
46
48
  YAML
47
49
  end
48
50
  end
data/spec/spec_helper.rb CHANGED
@@ -35,7 +35,7 @@ RSpec.configure do |config|
35
35
  # We should take their advice!
36
36
  config.raise_on_warning = true
37
37
 
38
- config.include(ExpectViolation)
38
+ config.include(ExpectOffense)
39
39
  end
40
40
 
41
41
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
@@ -0,0 +1,17 @@
1
+ # rubocop-rspec gem extension of RuboCop's ExpectOffense module.
2
+ #
3
+ # This mixin is the same as rubocop's ExpectOffense except the default
4
+ # filename ends with `_spec.rb`
5
+ module ExpectOffense
6
+ include RuboCop::RSpec::ExpectOffense
7
+
8
+ DEFAULT_FILENAME = 'example_spec.rb'.freeze
9
+
10
+ def expect_offense(source, filename = DEFAULT_FILENAME)
11
+ super
12
+ end
13
+
14
+ def expect_no_offenses(source, filename = DEFAULT_FILENAME)
15
+ super
16
+ end
17
+ end
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: 1.15.1
4
+ version: 1.16.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: 2017-05-01 00:00:00.000000000 Z
13
+ date: 2017-09-06 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rubocop
@@ -18,14 +18,14 @@ dependencies:
18
18
  requirements:
19
19
  - - ">="
20
20
  - !ruby/object:Gem::Version
21
- version: 0.42.0
21
+ version: 0.49.0
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: 0.42.0
28
+ version: 0.49.0
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: rake
31
31
  requirement: !ruby/object:Gem::Requirement
@@ -68,48 +68,6 @@ dependencies:
68
68
  - - ">="
69
69
  - !ruby/object:Gem::Version
70
70
  version: '0'
71
- - !ruby/object:Gem::Dependency
72
- name: anima
73
- requirement: !ruby/object:Gem::Requirement
74
- requirements:
75
- - - ">="
76
- - !ruby/object:Gem::Version
77
- version: '0'
78
- type: :development
79
- prerelease: false
80
- version_requirements: !ruby/object:Gem::Requirement
81
- requirements:
82
- - - ">="
83
- - !ruby/object:Gem::Version
84
- version: '0'
85
- - !ruby/object:Gem::Dependency
86
- name: concord
87
- requirement: !ruby/object:Gem::Requirement
88
- requirements:
89
- - - ">="
90
- - !ruby/object:Gem::Version
91
- version: '0'
92
- type: :development
93
- prerelease: false
94
- version_requirements: !ruby/object:Gem::Requirement
95
- requirements:
96
- - - ">="
97
- - !ruby/object:Gem::Version
98
- version: '0'
99
- - !ruby/object:Gem::Dependency
100
- name: adamantium
101
- requirement: !ruby/object:Gem::Requirement
102
- requirements:
103
- - - ">="
104
- - !ruby/object:Gem::Version
105
- version: '0'
106
- type: :development
107
- prerelease: false
108
- version_requirements: !ruby/object:Gem::Requirement
109
- requirements:
110
- - - ">="
111
- - !ruby/object:Gem::Version
112
- version: '0'
113
71
  - !ruby/object:Gem::Dependency
114
72
  name: yard
115
73
  requirement: !ruby/object:Gem::Requirement
@@ -144,6 +102,8 @@ files:
144
102
  - Rakefile
145
103
  - config/default.yml
146
104
  - lib/rubocop-rspec.rb
105
+ - lib/rubocop/cop/rspec/align_left_let_brace.rb
106
+ - lib/rubocop/cop/rspec/align_right_let_brace.rb
147
107
  - lib/rubocop/cop/rspec/any_instance.rb
148
108
  - lib/rubocop/cop/rspec/around_block.rb
149
109
  - lib/rubocop/cop/rspec/be_eql.rb
@@ -159,40 +119,50 @@ files:
159
119
  - lib/rubocop/cop/rspec/example_length.rb
160
120
  - lib/rubocop/cop/rspec/example_wording.rb
161
121
  - lib/rubocop/cop/rspec/expect_actual.rb
122
+ - lib/rubocop/cop/rspec/expect_in_hook.rb
162
123
  - lib/rubocop/cop/rspec/expect_output.rb
124
+ - lib/rubocop/cop/rspec/factory_girl/dynamic_attribute_defined_statically.rb
163
125
  - lib/rubocop/cop/rspec/file_path.rb
164
126
  - lib/rubocop/cop/rspec/focus.rb
165
127
  - lib/rubocop/cop/rspec/hook_argument.rb
166
128
  - lib/rubocop/cop/rspec/implicit_expect.rb
167
129
  - lib/rubocop/cop/rspec/instance_spy.rb
168
130
  - lib/rubocop/cop/rspec/instance_variable.rb
131
+ - lib/rubocop/cop/rspec/invalid_predicate_matcher.rb
169
132
  - lib/rubocop/cop/rspec/it_behaves_like.rb
170
133
  - lib/rubocop/cop/rspec/iterated_expectation.rb
171
134
  - lib/rubocop/cop/rspec/leading_subject.rb
135
+ - lib/rubocop/cop/rspec/let_before_examples.rb
172
136
  - lib/rubocop/cop/rspec/let_setup.rb
173
137
  - lib/rubocop/cop/rspec/message_chain.rb
174
138
  - lib/rubocop/cop/rspec/message_expectation.rb
175
139
  - lib/rubocop/cop/rspec/message_spies.rb
176
140
  - lib/rubocop/cop/rspec/multiple_describes.rb
177
141
  - lib/rubocop/cop/rspec/multiple_expectations.rb
142
+ - lib/rubocop/cop/rspec/multiple_subjects.rb
178
143
  - lib/rubocop/cop/rspec/named_subject.rb
179
144
  - lib/rubocop/cop/rspec/nested_groups.rb
180
145
  - lib/rubocop/cop/rspec/not_to_not.rb
181
146
  - lib/rubocop/cop/rspec/overwriting_setup.rb
147
+ - lib/rubocop/cop/rspec/predicate_matcher.rb
182
148
  - lib/rubocop/cop/rspec/repeated_description.rb
183
149
  - lib/rubocop/cop/rspec/repeated_example.rb
150
+ - lib/rubocop/cop/rspec/return_from_stub.rb
184
151
  - lib/rubocop/cop/rspec/scattered_let.rb
185
152
  - lib/rubocop/cop/rspec/scattered_setup.rb
186
153
  - lib/rubocop/cop/rspec/shared_context.rb
187
154
  - lib/rubocop/cop/rspec/single_argument_message_chain.rb
188
155
  - lib/rubocop/cop/rspec/subject_stub.rb
189
156
  - lib/rubocop/cop/rspec/verified_doubles.rb
157
+ - lib/rubocop/cop/rspec/void_expect.rb
190
158
  - lib/rubocop/rspec.rb
159
+ - lib/rubocop/rspec/align_let_brace.rb
191
160
  - lib/rubocop/rspec/concept.rb
192
161
  - lib/rubocop/rspec/config_formatter.rb
193
162
  - lib/rubocop/rspec/description_extractor.rb
194
163
  - lib/rubocop/rspec/example.rb
195
164
  - lib/rubocop/rspec/example_group.rb
165
+ - lib/rubocop/rspec/factory_girl.rb
196
166
  - lib/rubocop/rspec/hook.rb
197
167
  - lib/rubocop/rspec/inject.rb
198
168
  - lib/rubocop/rspec/language.rb
@@ -202,10 +172,11 @@ files:
202
172
  - lib/rubocop/rspec/version.rb
203
173
  - lib/rubocop/rspec/wording.rb
204
174
  - rubocop-rspec.gemspec
205
- - spec/expect_violation/expectation_spec.rb
206
175
  - spec/project/changelog_spec.rb
207
176
  - spec/project/default_config_spec.rb
208
177
  - spec/project/project_requires_spec.rb
178
+ - spec/rubocop/cop/rspec/align_left_let_brace_spec.rb
179
+ - spec/rubocop/cop/rspec/align_right_let_brace_spec.rb
209
180
  - spec/rubocop/cop/rspec/any_instance_spec.rb
210
181
  - spec/rubocop/cop/rspec/around_block_spec.rb
211
182
  - spec/rubocop/cop/rspec/be_eql_spec.rb
@@ -221,34 +192,42 @@ files:
221
192
  - spec/rubocop/cop/rspec/example_length_spec.rb
222
193
  - spec/rubocop/cop/rspec/example_wording_spec.rb
223
194
  - spec/rubocop/cop/rspec/expect_actual_spec.rb
195
+ - spec/rubocop/cop/rspec/expect_in_hook_spec.rb
224
196
  - spec/rubocop/cop/rspec/expect_output_spec.rb
197
+ - spec/rubocop/cop/rspec/factory_girl/dynamic_attribute_defined_statically_spec.rb
225
198
  - spec/rubocop/cop/rspec/file_path_spec.rb
226
199
  - spec/rubocop/cop/rspec/focus_spec.rb
227
200
  - spec/rubocop/cop/rspec/hook_argument_spec.rb
228
201
  - spec/rubocop/cop/rspec/implicit_expect_spec.rb
229
202
  - spec/rubocop/cop/rspec/instance_spy_spec.rb
230
203
  - spec/rubocop/cop/rspec/instance_variable_spec.rb
204
+ - spec/rubocop/cop/rspec/invalid_predicate_matcher_spec.rb
231
205
  - spec/rubocop/cop/rspec/it_behaves_like_spec.rb
232
206
  - spec/rubocop/cop/rspec/iterated_expectation_spec.rb
233
207
  - spec/rubocop/cop/rspec/leading_subject_spec.rb
208
+ - spec/rubocop/cop/rspec/let_before_examples_spec.rb
234
209
  - spec/rubocop/cop/rspec/let_setup_spec.rb
235
210
  - spec/rubocop/cop/rspec/message_chain_spec.rb
236
211
  - spec/rubocop/cop/rspec/message_expectation_spec.rb
237
212
  - spec/rubocop/cop/rspec/message_spies_spec.rb
238
213
  - spec/rubocop/cop/rspec/multiple_describes_spec.rb
239
214
  - spec/rubocop/cop/rspec/multiple_expectations_spec.rb
215
+ - spec/rubocop/cop/rspec/multiple_subjects_spec.rb
240
216
  - spec/rubocop/cop/rspec/named_subject_spec.rb
241
217
  - spec/rubocop/cop/rspec/nested_groups_spec.rb
242
218
  - spec/rubocop/cop/rspec/not_to_not_spec.rb
243
219
  - spec/rubocop/cop/rspec/overwriting_setup_spec.rb
220
+ - spec/rubocop/cop/rspec/predicate_matcher_spec.rb
244
221
  - spec/rubocop/cop/rspec/repeated_description_spec.rb
245
222
  - spec/rubocop/cop/rspec/repeated_example_spec.rb
223
+ - spec/rubocop/cop/rspec/return_from_stub_spec.rb
246
224
  - spec/rubocop/cop/rspec/scattered_let_spec.rb
247
225
  - spec/rubocop/cop/rspec/scattered_setup_spec.rb
248
226
  - spec/rubocop/cop/rspec/shared_context_spec.rb
249
227
  - spec/rubocop/cop/rspec/single_argument_message_chain_spec.rb
250
228
  - spec/rubocop/cop/rspec/subject_stub_spec.rb
251
229
  - spec/rubocop/cop/rspec/verified_doubles_spec.rb
230
+ - spec/rubocop/cop/rspec/void_expect_spec.rb
252
231
  - spec/rubocop/rspec/config_formatter_spec.rb
253
232
  - spec/rubocop/rspec/description_extractor_spec.rb
254
233
  - spec/rubocop/rspec/example_group_spec.rb
@@ -260,7 +239,7 @@ files:
260
239
  - spec/shared/autocorrect_behavior.rb
261
240
  - spec/shared/detects_style_behavior.rb
262
241
  - spec/spec_helper.rb
263
- - spec/support/expect_violation.rb
242
+ - spec/support/expect_offense.rb
264
243
  homepage: http://github.com/backus/rubocop-rspec
265
244
  licenses:
266
245
  - MIT
@@ -281,15 +260,16 @@ required_rubygems_version: !ruby/object:Gem::Requirement
281
260
  version: '0'
282
261
  requirements: []
283
262
  rubyforge_project:
284
- rubygems_version: 2.6.11
263
+ rubygems_version: 2.6.13
285
264
  signing_key:
286
265
  specification_version: 4
287
266
  summary: Code style checking for RSpec files
288
267
  test_files:
289
- - spec/expect_violation/expectation_spec.rb
290
268
  - spec/project/changelog_spec.rb
291
269
  - spec/project/default_config_spec.rb
292
270
  - spec/project/project_requires_spec.rb
271
+ - spec/rubocop/cop/rspec/align_left_let_brace_spec.rb
272
+ - spec/rubocop/cop/rspec/align_right_let_brace_spec.rb
293
273
  - spec/rubocop/cop/rspec/any_instance_spec.rb
294
274
  - spec/rubocop/cop/rspec/around_block_spec.rb
295
275
  - spec/rubocop/cop/rspec/be_eql_spec.rb
@@ -305,34 +285,42 @@ test_files:
305
285
  - spec/rubocop/cop/rspec/example_length_spec.rb
306
286
  - spec/rubocop/cop/rspec/example_wording_spec.rb
307
287
  - spec/rubocop/cop/rspec/expect_actual_spec.rb
288
+ - spec/rubocop/cop/rspec/expect_in_hook_spec.rb
308
289
  - spec/rubocop/cop/rspec/expect_output_spec.rb
290
+ - spec/rubocop/cop/rspec/factory_girl/dynamic_attribute_defined_statically_spec.rb
309
291
  - spec/rubocop/cop/rspec/file_path_spec.rb
310
292
  - spec/rubocop/cop/rspec/focus_spec.rb
311
293
  - spec/rubocop/cop/rspec/hook_argument_spec.rb
312
294
  - spec/rubocop/cop/rspec/implicit_expect_spec.rb
313
295
  - spec/rubocop/cop/rspec/instance_spy_spec.rb
314
296
  - spec/rubocop/cop/rspec/instance_variable_spec.rb
297
+ - spec/rubocop/cop/rspec/invalid_predicate_matcher_spec.rb
315
298
  - spec/rubocop/cop/rspec/it_behaves_like_spec.rb
316
299
  - spec/rubocop/cop/rspec/iterated_expectation_spec.rb
317
300
  - spec/rubocop/cop/rspec/leading_subject_spec.rb
301
+ - spec/rubocop/cop/rspec/let_before_examples_spec.rb
318
302
  - spec/rubocop/cop/rspec/let_setup_spec.rb
319
303
  - spec/rubocop/cop/rspec/message_chain_spec.rb
320
304
  - spec/rubocop/cop/rspec/message_expectation_spec.rb
321
305
  - spec/rubocop/cop/rspec/message_spies_spec.rb
322
306
  - spec/rubocop/cop/rspec/multiple_describes_spec.rb
323
307
  - spec/rubocop/cop/rspec/multiple_expectations_spec.rb
308
+ - spec/rubocop/cop/rspec/multiple_subjects_spec.rb
324
309
  - spec/rubocop/cop/rspec/named_subject_spec.rb
325
310
  - spec/rubocop/cop/rspec/nested_groups_spec.rb
326
311
  - spec/rubocop/cop/rspec/not_to_not_spec.rb
327
312
  - spec/rubocop/cop/rspec/overwriting_setup_spec.rb
313
+ - spec/rubocop/cop/rspec/predicate_matcher_spec.rb
328
314
  - spec/rubocop/cop/rspec/repeated_description_spec.rb
329
315
  - spec/rubocop/cop/rspec/repeated_example_spec.rb
316
+ - spec/rubocop/cop/rspec/return_from_stub_spec.rb
330
317
  - spec/rubocop/cop/rspec/scattered_let_spec.rb
331
318
  - spec/rubocop/cop/rspec/scattered_setup_spec.rb
332
319
  - spec/rubocop/cop/rspec/shared_context_spec.rb
333
320
  - spec/rubocop/cop/rspec/single_argument_message_chain_spec.rb
334
321
  - spec/rubocop/cop/rspec/subject_stub_spec.rb
335
322
  - spec/rubocop/cop/rspec/verified_doubles_spec.rb
323
+ - spec/rubocop/cop/rspec/void_expect_spec.rb
336
324
  - spec/rubocop/rspec/config_formatter_spec.rb
337
325
  - spec/rubocop/rspec/description_extractor_spec.rb
338
326
  - spec/rubocop/rspec/example_group_spec.rb
@@ -344,4 +332,4 @@ test_files:
344
332
  - spec/shared/autocorrect_behavior.rb
345
333
  - spec/shared/detects_style_behavior.rb
346
334
  - spec/spec_helper.rb
347
- - spec/support/expect_violation.rb
335
+ - spec/support/expect_offense.rb
@@ -1,85 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe ExpectViolation::Expectation do
4
- subject(:expectation) { described_class.new(string) }
5
-
6
- context 'when given a single assertion on class end' do
7
- let(:string) do
8
- <<-SRC
9
- class Foo
10
- end
11
- ^^^ The end of `Foo` should be annotated.
12
- SRC
13
- end
14
-
15
- let(:assertion) { expectation.assertions.first }
16
-
17
- it 'has one assertion' do
18
- expect(expectation.assertions.size).to be(1)
19
- end
20
-
21
- it 'has an assertion on line 2' do
22
- expect(assertion.line_number).to be(2)
23
- end
24
-
25
- it 'has an assertion on column range 1-3' do
26
- expect(assertion.column_range).to eql(8...11)
27
- end
28
-
29
- it 'has an assertion with correct violation message' do
30
- expect(assertion.message).to eql('The end of `Foo` should be annotated.')
31
- end
32
-
33
- it 'recreates source' do
34
- expect(expectation.source).to eql(<<-RUBY)
35
- class Foo
36
- end
37
- RUBY
38
- end
39
- end
40
-
41
- context 'when given many assertions on two lines' do
42
- let(:string) do
43
- <<-SRC
44
- foo bar
45
- ^ Charlie
46
- ^^ Charlie
47
- ^^ Bronco
48
- ^^ Alpha
49
- baz
50
- ^ Delta
51
- SRC
52
- end
53
-
54
- let(:assertions) { expectation.assertions.sort }
55
-
56
- it 'has two assertions' do
57
- expect(expectation.assertions.size).to be(5)
58
- end
59
-
60
- it 'has assertions on lines 1 and 2' do
61
- expect(assertions.map(&:line_number)).to eql(
62
- [1, 1, 1, 1, 2]
63
- )
64
- end
65
-
66
- it 'has assertions on column range 1-3' do
67
- expect(assertions.map(&:column_range)).to eql(
68
- [11...13, 12...13, 12...14, 12...14, 8...9]
69
- )
70
- end
71
-
72
- it 'has an assertion with correct violation message' do
73
- expect(assertions.map(&:message)).to eql(
74
- %w[Charlie Charlie Alpha Bronco Delta]
75
- )
76
- end
77
-
78
- it 'recreates source' do
79
- expect(expectation.source).to eql(<<-RUBY)
80
- foo bar
81
- baz
82
- RUBY
83
- end
84
- end
85
- end