1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
extern crate rspec;
use std::io;
use std::sync::Arc;
// An example of a single runner running multiple semantically equivalent,
// yet syntactically different test suites in succession:
pub fn main() {
let logger = Arc::new(rspec::Logger::new(io::stdout()));
let configuration = rspec::ConfigurationBuilder::default().build().unwrap();
let runner = rspec::Runner::new(configuration, vec![logger]);
// A test suite using the `suite`, `context`, `example` syntax family:
runner.run(&rspec::suite("an value of ten", 10, |ctx| {
ctx.context("adding 5 to it", |ctx| {
ctx.example("results in fifteen", |num| {
assert_eq!(*num, 15);
});
});
}));
// A test suite using the `describe`, `specify`, `it` syntax family:
runner.run(&rspec::describe("an value of ten", 10, |ctx| {
ctx.specify("adding 5 to it", |ctx| {
ctx.it("results in fifteen", |num| {
assert_eq!(*num, 15);
});
});
}));
// A test suite using the `given`, `when`, `then` syntax family:
runner.run(&rspec::given("an value of ten", 10, |ctx| {
ctx.when("adding 5 to it", |ctx| {
ctx.then("results in fifteen", |num| {
assert_eq!(*num, 15);
});
});
}));
}
|