@@ -163,18 +163,13 @@ impl ShouldColorize {
163
163
mod specs {
164
164
use super :: * ;
165
165
use rspec;
166
- use rspec:: context:: * ;
167
166
use std:: env;
168
167
169
168
#[ test]
170
169
fn clicolor_behavior ( ) {
171
- use std:: io;
172
-
173
- let stdout = & mut io:: stdout ( ) ;
174
- let mut formatter = rspec:: formatter:: Simple :: new ( stdout) ;
175
- let mut runner = describe ( "ShouldColorize" , |ctx| {
176
- ctx. describe ( "::normalize_env" , |ctx| {
177
- ctx. it ( "should return None if error" , || {
170
+ rspec:: run ( & rspec:: describe ( "ShouldColorize" , ( ) , |ctx| {
171
+ ctx. specify ( "::normalize_env" , |ctx| {
172
+ ctx. it ( "should return None if error" , |_| {
178
173
assert_eq ! (
179
174
None ,
180
175
ShouldColorize :: normalize_env( Err ( env:: VarError :: NotPresent ) )
@@ -185,19 +180,19 @@ mod specs {
185
180
)
186
181
} ) ;
187
182
188
- ctx. it ( "should return Some(true) if != 0" , || {
183
+ ctx. it ( "should return Some(true) if != 0" , |_ | {
189
184
Some ( true ) == ShouldColorize :: normalize_env ( Ok ( String :: from ( "1" ) ) )
190
185
} ) ;
191
186
192
- ctx. it ( "should return Some(false) if == 0" , || {
187
+ ctx. it ( "should return Some(false) if == 0" , |_ | {
193
188
Some ( false ) == ShouldColorize :: normalize_env ( Ok ( String :: from ( "0" ) ) )
194
189
} ) ;
195
190
} ) ;
196
191
197
- ctx. describe ( "::resolve_clicolor_force" , |ctx| {
192
+ ctx. specify ( "::resolve_clicolor_force" , |ctx| {
198
193
ctx. it (
199
194
"should return None if NO_COLOR is not set and CLICOLOR_FORCE is not set or set to 0" ,
200
- || {
195
+ |_ | {
201
196
assert_eq ! (
202
197
None ,
203
198
ShouldColorize :: resolve_clicolor_force(
@@ -217,7 +212,7 @@ mod specs {
217
212
218
213
ctx. it (
219
214
"should return Some(false) if NO_COLOR is set and CLICOLOR_FORCE is not enabled" ,
220
- || {
215
+ |_ | {
221
216
assert_eq ! (
222
217
Some ( false ) ,
223
218
ShouldColorize :: resolve_clicolor_force(
@@ -244,7 +239,7 @@ mod specs {
244
239
245
240
ctx. it (
246
241
"should prioritize CLICOLOR_FORCE over NO_COLOR if CLICOLOR_FORCE is set to non-zero value" ,
247
- || {
242
+ |_ | {
248
243
assert_eq ! (
249
244
Some ( true ) ,
250
245
ShouldColorize :: resolve_clicolor_force(
@@ -270,42 +265,42 @@ mod specs {
270
265
) ;
271
266
} ) ;
272
267
273
- ctx. describe ( "constructors" , |ctx| {
274
- ctx. it ( "should have a default constructor" , || {
268
+ ctx. specify ( "constructors" , |ctx| {
269
+ ctx. it ( "should have a default constructor" , |_ | {
275
270
ShouldColorize :: default ( ) ;
276
271
} ) ;
277
272
278
- ctx. it ( "should have an environment constructor" , || {
273
+ ctx. it ( "should have an environment constructor" , |_ | {
279
274
ShouldColorize :: from_env ( ) ;
280
275
} ) ;
281
276
} ) ;
282
277
283
- ctx. describe ( "when only changing clicolors" , |ctx| {
284
- ctx. it ( "clicolor == false means no colors" , || {
278
+ ctx. specify ( "when only changing clicolors" , |ctx| {
279
+ ctx. it ( "clicolor == false means no colors" , |_ | {
285
280
let colorize_control = ShouldColorize {
286
281
clicolor : false ,
287
282
..ShouldColorize :: default ( )
288
283
} ;
289
284
false == colorize_control. should_colorize ( )
290
285
} ) ;
291
286
292
- ctx. it ( "clicolor == true means colors !" , || {
287
+ ctx. it ( "clicolor == true means colors !" , |_ | {
293
288
let colorize_control = ShouldColorize {
294
289
clicolor : true ,
295
290
..ShouldColorize :: default ( )
296
291
} ;
297
292
true == colorize_control. should_colorize ( )
298
293
} ) ;
299
294
300
- ctx. it ( "unset clicolors implies true" , || {
295
+ ctx. it ( "unset clicolors implies true" , |_ | {
301
296
true == ShouldColorize :: default ( ) . should_colorize ( )
302
297
} ) ;
303
298
} ) ;
304
299
305
- ctx. describe ( "when using clicolor_force" , |ctx| {
300
+ ctx. specify ( "when using clicolor_force" , |ctx| {
306
301
ctx. it (
307
302
"clicolor_force should force to true no matter clicolor" ,
308
- || {
303
+ |_ | {
309
304
let colorize_control = ShouldColorize {
310
305
clicolor : false ,
311
306
clicolor_force : Some ( true ) ,
@@ -318,7 +313,7 @@ mod specs {
318
313
319
314
ctx. it (
320
315
"clicolor_force should force to false no matter clicolor" ,
321
- || {
316
+ |_ | {
322
317
let colorize_control = ShouldColorize {
323
318
clicolor : true ,
324
319
clicolor_force : Some ( false ) ,
@@ -330,8 +325,8 @@ mod specs {
330
325
) ;
331
326
} ) ;
332
327
333
- ctx. describe ( "using a manual override" , |ctx| {
334
- ctx. it ( "shoud colorize if manual_override is true, but clicolor is false and clicolor_force also false" , || {
328
+ ctx. specify ( "using a manual override" , |ctx| {
329
+ ctx. it ( "shoud colorize if manual_override is true, but clicolor is false and clicolor_force also false" , |_ | {
335
330
let colorize_control = ShouldColorize {
336
331
clicolor : false ,
337
332
clicolor_force : None ,
@@ -343,7 +338,7 @@ mod specs {
343
338
true == colorize_control. should_colorize ( )
344
339
} ) ;
345
340
346
- ctx. it ( "should not colorize if manual_override is false, but clicolor is true or clicolor_force is true" , || {
341
+ ctx. it ( "should not colorize if manual_override is false, but clicolor is true or clicolor_force is true" , |_ | {
347
342
let colorize_control = ShouldColorize {
348
343
clicolor : true ,
349
344
clicolor_force : Some ( true ) ,
@@ -356,13 +351,13 @@ mod specs {
356
351
} )
357
352
} ) ;
358
353
359
- ctx. describe ( "::set_override" , |ctx| {
360
- ctx. it ( "should exists" , || {
354
+ ctx. specify ( "::set_override" , |ctx| {
355
+ ctx. it ( "should exists" , |_ | {
361
356
let colorize_control = ShouldColorize :: default ( ) ;
362
357
colorize_control. set_override ( true ) ;
363
358
} ) ;
364
359
365
- ctx. it ( "set the manual_override property" , || {
360
+ ctx. it ( "set the manual_override property" , |_ | {
366
361
let colorize_control = ShouldColorize :: default ( ) ;
367
362
colorize_control. set_override ( true ) ;
368
363
{
@@ -385,13 +380,13 @@ mod specs {
385
380
} ) ;
386
381
} ) ;
387
382
388
- ctx. describe ( "::unset_override" , |ctx| {
389
- ctx. it ( "should exists" , || {
383
+ ctx. specify ( "::unset_override" , |ctx| {
384
+ ctx. it ( "should exists" , |_ | {
390
385
let colorize_control = ShouldColorize :: default ( ) ;
391
386
colorize_control. unset_override ( ) ;
392
387
} ) ;
393
388
394
- ctx. it ( "unset the manual_override property" , || {
389
+ ctx. it ( "unset the manual_override property" , |_ | {
395
390
let colorize_control = ShouldColorize :: default ( ) ;
396
391
colorize_control. set_override ( true ) ;
397
392
colorize_control. unset_override ( ) ;
@@ -401,8 +396,6 @@ mod specs {
401
396
) ;
402
397
} ) ;
403
398
} ) ;
404
- } ) ;
405
- runner. add_event_handler ( & mut formatter) ;
406
- runner. run ( ) . unwrap ( ) ;
399
+ } ) ) ;
407
400
}
408
401
}
0 commit comments