Skip to content

Commit e55e26c

Browse files
authored
Update rspec (#177)
1 parent 775ec9f commit e55e26c

File tree

2 files changed

+30
-37
lines changed

2 files changed

+30
-37
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ features = [
2828
[dev_dependencies]
2929
ansi_term = "0.12"
3030
insta = "1"
31-
rspec = "=1.0.0-beta.3"
31+
rspec = "1"

src/control.rs

+29-36
Original file line numberDiff line numberDiff line change
@@ -163,18 +163,13 @@ impl ShouldColorize {
163163
mod specs {
164164
use super::*;
165165
use rspec;
166-
use rspec::context::*;
167166
use std::env;
168167

169168
#[test]
170169
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", |_| {
178173
assert_eq!(
179174
None,
180175
ShouldColorize::normalize_env(Err(env::VarError::NotPresent))
@@ -185,19 +180,19 @@ mod specs {
185180
)
186181
});
187182

188-
ctx.it("should return Some(true) if != 0", || {
183+
ctx.it("should return Some(true) if != 0", |_| {
189184
Some(true) == ShouldColorize::normalize_env(Ok(String::from("1")))
190185
});
191186

192-
ctx.it("should return Some(false) if == 0", || {
187+
ctx.it("should return Some(false) if == 0", |_| {
193188
Some(false) == ShouldColorize::normalize_env(Ok(String::from("0")))
194189
});
195190
});
196191

197-
ctx.describe("::resolve_clicolor_force", |ctx| {
192+
ctx.specify("::resolve_clicolor_force", |ctx| {
198193
ctx.it(
199194
"should return None if NO_COLOR is not set and CLICOLOR_FORCE is not set or set to 0",
200-
|| {
195+
|_| {
201196
assert_eq!(
202197
None,
203198
ShouldColorize::resolve_clicolor_force(
@@ -217,7 +212,7 @@ mod specs {
217212

218213
ctx.it(
219214
"should return Some(false) if NO_COLOR is set and CLICOLOR_FORCE is not enabled",
220-
|| {
215+
|_| {
221216
assert_eq!(
222217
Some(false),
223218
ShouldColorize::resolve_clicolor_force(
@@ -244,7 +239,7 @@ mod specs {
244239

245240
ctx.it(
246241
"should prioritize CLICOLOR_FORCE over NO_COLOR if CLICOLOR_FORCE is set to non-zero value",
247-
|| {
242+
|_| {
248243
assert_eq!(
249244
Some(true),
250245
ShouldColorize::resolve_clicolor_force(
@@ -270,42 +265,42 @@ mod specs {
270265
);
271266
});
272267

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", |_| {
275270
ShouldColorize::default();
276271
});
277272

278-
ctx.it("should have an environment constructor", || {
273+
ctx.it("should have an environment constructor", |_| {
279274
ShouldColorize::from_env();
280275
});
281276
});
282277

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", |_| {
285280
let colorize_control = ShouldColorize {
286281
clicolor: false,
287282
..ShouldColorize::default()
288283
};
289284
false == colorize_control.should_colorize()
290285
});
291286

292-
ctx.it("clicolor == true means colors !", || {
287+
ctx.it("clicolor == true means colors !", |_| {
293288
let colorize_control = ShouldColorize {
294289
clicolor: true,
295290
..ShouldColorize::default()
296291
};
297292
true == colorize_control.should_colorize()
298293
});
299294

300-
ctx.it("unset clicolors implies true", || {
295+
ctx.it("unset clicolors implies true", |_| {
301296
true == ShouldColorize::default().should_colorize()
302297
});
303298
});
304299

305-
ctx.describe("when using clicolor_force", |ctx| {
300+
ctx.specify("when using clicolor_force", |ctx| {
306301
ctx.it(
307302
"clicolor_force should force to true no matter clicolor",
308-
|| {
303+
|_| {
309304
let colorize_control = ShouldColorize {
310305
clicolor: false,
311306
clicolor_force: Some(true),
@@ -318,7 +313,7 @@ mod specs {
318313

319314
ctx.it(
320315
"clicolor_force should force to false no matter clicolor",
321-
|| {
316+
|_| {
322317
let colorize_control = ShouldColorize {
323318
clicolor: true,
324319
clicolor_force: Some(false),
@@ -330,8 +325,8 @@ mod specs {
330325
);
331326
});
332327

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", |_| {
335330
let colorize_control = ShouldColorize {
336331
clicolor: false,
337332
clicolor_force: None,
@@ -343,7 +338,7 @@ mod specs {
343338
true == colorize_control.should_colorize()
344339
});
345340

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", |_| {
347342
let colorize_control = ShouldColorize {
348343
clicolor: true,
349344
clicolor_force: Some(true),
@@ -356,13 +351,13 @@ mod specs {
356351
})
357352
});
358353

359-
ctx.describe("::set_override", |ctx| {
360-
ctx.it("should exists", || {
354+
ctx.specify("::set_override", |ctx| {
355+
ctx.it("should exists", |_| {
361356
let colorize_control = ShouldColorize::default();
362357
colorize_control.set_override(true);
363358
});
364359

365-
ctx.it("set the manual_override property", || {
360+
ctx.it("set the manual_override property", |_| {
366361
let colorize_control = ShouldColorize::default();
367362
colorize_control.set_override(true);
368363
{
@@ -385,13 +380,13 @@ mod specs {
385380
});
386381
});
387382

388-
ctx.describe("::unset_override", |ctx| {
389-
ctx.it("should exists", || {
383+
ctx.specify("::unset_override", |ctx| {
384+
ctx.it("should exists", |_| {
390385
let colorize_control = ShouldColorize::default();
391386
colorize_control.unset_override();
392387
});
393388

394-
ctx.it("unset the manual_override property", || {
389+
ctx.it("unset the manual_override property", |_| {
395390
let colorize_control = ShouldColorize::default();
396391
colorize_control.set_override(true);
397392
colorize_control.unset_override();
@@ -401,8 +396,6 @@ mod specs {
401396
);
402397
});
403398
});
404-
});
405-
runner.add_event_handler(&mut formatter);
406-
runner.run().unwrap();
399+
}));
407400
}
408401
}

0 commit comments

Comments
 (0)