@@ -18,7 +18,7 @@ def method
18
18
19
19
output = run_engine
20
20
21
- assert includes_check? ( output , "Lint/UselessAssignment" )
21
+ expect ( includes_check? ( output , "Lint/UselessAssignment" ) ) . to be true
22
22
end
23
23
24
24
it "reads the configured ruby_style file" do
@@ -38,8 +38,8 @@ def method
38
38
config = { "config" => "rubocop.yml" }
39
39
output = run_engine ( config )
40
40
41
- assert includes_check? ( output , "Style/AndOr" )
42
- assert ! includes_check? ( output , "Lint/UselessAssignment" )
41
+ expect ( includes_check? ( output , "Style/AndOr" ) ) . to be true
42
+ expect ( includes_check? ( output , "Lint/UselessAssignment" ) ) . to be false
43
43
end
44
44
45
45
it "respects the default .rubocop.yml file" do
@@ -58,8 +58,8 @@ def method
58
58
59
59
output = run_engine
60
60
61
- assert includes_check? ( output , "Style/AndOr" )
62
- assert ! includes_check? ( output , "Lint/UselessAssignment" )
61
+ expect ( includes_check? ( output , "Style/AndOr" ) ) . to be true
62
+ expect ( includes_check? ( output , "Lint/UselessAssignment" ) ) . to be false
63
63
end
64
64
65
65
it "reads a file with a #!.*ruby declaration at the top" do
@@ -73,7 +73,8 @@ def method
73
73
end
74
74
EORUBY
75
75
output = run_engine
76
- assert includes_check? ( output , "Lint/UselessAssignment" )
76
+
77
+ expect ( includes_check? ( output , "Lint/UselessAssignment" ) ) . to be true
77
78
end
78
79
79
80
it "uses excludes from the specified YAML config" do
@@ -92,7 +93,8 @@ def method
92
93
)
93
94
config = { "config" => "rubocop.yml" }
94
95
output = run_engine ( config )
95
- assert !includes_check? ( output , "Lint/UselessAssignment" )
96
+
97
+ expect ( includes_check? ( output , "Lint/UselessAssignment" ) ) . to be false
96
98
end
97
99
98
100
it "uses exclusions passed in via the config hash" do
@@ -107,7 +109,8 @@ def method
107
109
EORUBY
108
110
config = { "exclude_paths" => [ "my_script" ] }
109
111
output = run_engine ( config )
110
- assert !includes_check? ( output , "Lint/UselessAssignment" )
112
+
113
+ expect ( includes_check? ( output , "Lint/UselessAssignment" ) ) . to be false
111
114
end
112
115
113
116
it "layers config exclusions on top of the YAML config" do
@@ -129,11 +132,12 @@ def method
129
132
)
130
133
config = { "config" => "rubocop.yml" , "exclude_paths" => [ "bar.rb" ] }
131
134
output = run_engine ( config )
132
- assert !includes_check? ( output , "Lint/UselessAssignment" )
135
+
136
+ expect ( includes_check? ( output , "Lint/UselessAssignment" ) ) . to be false
133
137
end
134
138
135
139
it "handles different locations properly" do
136
- RuboCop ::Cop ::Team . any_instance . expects ( :inspect_file ) . returns (
140
+ allow_any_instance_of ( RuboCop ::Cop ::Team ) . to receive ( :inspect_file ) . and_return (
137
141
[
138
142
OpenStruct . new (
139
143
location : RuboCop ::Cop ::Lint ::Syntax ::PseudoSourceRange . new (
@@ -164,7 +168,8 @@ def method
164
168
"end" => { "column" => 1 , "line" => 1 }
165
169
}
166
170
}
167
- assert_equal location , result [ "location" ]
171
+
172
+ expect ( result [ "location" ] ) . to eq ( location )
168
173
end
169
174
170
175
it "includes complete method body for cyclomatic complexity issue" do
@@ -192,7 +197,7 @@ def method(a,b,c,d,e,f,g)
192
197
end
193
198
EORUBY
194
199
output = run_engine
195
- assert includes_check? ( output , "Metrics/CyclomaticComplexity" )
200
+ expect ( includes_check? ( output , "Metrics/CyclomaticComplexity" ) ) . to be true
196
201
197
202
json = JSON . parse ( '[' + output . split ( "\u0000 " ) . join ( ',' ) + ']' )
198
203
@@ -206,7 +211,8 @@ def method(a,b,c,d,e,f,g)
206
211
"end" => { "column" => 14 , "line" => 21 }
207
212
}
208
213
}
209
- assert_equal location , result [ "location" ]
214
+
215
+ expect ( result [ "location" ] ) . to eq ( location )
210
216
end
211
217
212
218
it "includes issue content when available" do
@@ -215,7 +221,7 @@ def method(a,b,c,d,e,f,g)
215
221
216
222
output = run_engine
217
223
218
- assert includes_content_for? ( output , "Metrics/ClassLength" )
224
+ expect ( includes_content_for? ( output , "Metrics/ClassLength" ) ) . to be true
219
225
end
220
226
221
227
it "uses only include_paths when they're passed in via the config hash" do
@@ -243,8 +249,9 @@ def method
243
249
output = run_engine (
244
250
"include_paths" => %w[ included_root_file.rb subdir/ ]
245
251
)
246
- assert !includes_check? ( output , "Lint/UselessAssignment" )
247
- assert !includes_check? ( output , "Style/AndOr" )
252
+
253
+ expect ( includes_check? ( output , "Lint/UselessAssignment" ) ) . to be false
254
+ expect ( includes_check? ( output , "Style/AndOr" ) ) . to be false
248
255
end
249
256
250
257
it "ignores non-Ruby files even when passed in as include_paths" do
@@ -253,9 +260,11 @@ def method
253
260
output = run_engine (
254
261
"include_paths" => %w[ config.yml ]
255
262
)
256
- refute ( issues ( output ) . detect do |i |
263
+ issue = issues ( output ) . detect do |i |
257
264
i [ "description" ] == "unexpected token tCOLON"
258
- end )
265
+ end
266
+
267
+ expect ( issue ) . to be nil
259
268
end
260
269
261
270
it "includes Ruby files even if they don't end with .rb" do
@@ -267,7 +276,8 @@ def method
267
276
end
268
277
EORUBY
269
278
output = run_engine ( "include_paths" => %w[ Rakefile ] )
270
- assert includes_check? ( output , "Lint/UselessAssignment" )
279
+
280
+ expect ( includes_check? ( output , "Lint/UselessAssignment" ) ) . to be true
271
281
end
272
282
273
283
it "skips local disables" do
@@ -280,7 +290,8 @@ def method
280
290
end
281
291
EORUBY
282
292
output = run_engine
283
- refute includes_check? ( output , "Lint/UselessAssignment" )
293
+
294
+ expect ( includes_check? ( output , "Lint/UselessAssignment" ) ) . to be false
284
295
end
285
296
286
297
it "shows full source of long methods" do
@@ -296,8 +307,8 @@ def method
296
307
i [ "check_name" ] == "Rubocop/Metrics/MethodLength"
297
308
end
298
309
299
- assert_equal 1 , issue [ "location" ] [ "positions" ] [ "begin" ] [ "line" ]
300
- assert_equal 14 , issue [ "location" ] [ "positions" ] [ "end" ] [ "line" ]
310
+ expect ( issue [ "location" ] [ "positions" ] [ "begin" ] [ "line" ] ) . to eq ( 1 )
311
+ expect ( issue [ "location" ] [ "positions" ] [ "end" ] [ "line" ] ) . to eq ( 14 )
301
312
end
302
313
303
314
it "shows full source of long classes" do
@@ -312,8 +323,8 @@ class Awesome
312
323
i [ "check_name" ] == "Rubocop/Metrics/ClassLength"
313
324
end
314
325
315
- assert_equal 1 , issue [ "location" ] [ "positions" ] [ "begin" ] [ "line" ]
316
- assert_equal 105 , issue [ "location" ] [ "positions" ] [ "end" ] [ "line" ]
326
+ expect ( issue [ "location" ] [ "positions" ] [ "begin" ] [ "line" ] ) . to eq ( 1 )
327
+ expect ( issue [ "location" ] [ "positions" ] [ "end" ] [ "line" ] ) . to eq ( 105 )
317
328
end
318
329
319
330
def includes_check? ( output , cop_name )
0 commit comments