Module rspec::context
[−]
[src]
The Context module holds all the functionality for the test declaration, that is: describe
,
before
, after
, it
and their variants.
A Context can also holds reference to children Contextes, for whom the before closures will be executed after the before closures of the current context. The order of execution of tests respect the order of declaration of theses tests.
Running these tests and doing asserts is not the job of the Context, but the Runner, which is a struct returned by the root context declaration.
Examples
use rspec::context::*; // `rdescribe` instanciate a runner and run it transparently rdescribe("Context", |ctx| { describe("Context::describe", |ctx| { ctx.it("can be nested", || Ok(()) as Result<(),()>); ctx.it("use a `ctx` object", || Ok(()) as Result<(),()>) }); describe("Context::it", |ctx| { ctx.it("uses a Result returns", || Ok(()) as Result<(),()>); ctx.it("can also use asserts", || { assert_eq!(42, 12 + 30); Ok(()) as Result<(),()> // don't forget the result type }) }); });
Structs
Context |
A Context holds a collection of tests, a collection of closures to call before running any tests, and a collection of closure to call after all the tests.. |
Enums
Testable |
This enum is used to build a tree of named tests and contextes. |
Functions
describe |
This is the root describe. It will instanciate a root |
rdescribe |
This is the root describe with a sugar. It will instanciate a root |
Type Definitions
AfterFunction |
This is the type used by the closure given as argument of a |
BeforeFunction |
This is the type used by the closure given as argument of a |
TestFunction |
This is the type used by the closure given as argument of a |
TestResult |
The type used for a test result |