Crate rxpect

Source
Expand description

§RXpect

A Rust library for fluently building expectations in tests.

§What does it mean?

Either Rust Expect or Raniz Expect, pick whichever you like best.

§How do I use this thing?

It’s pretty simple actually, wrap whatever you’re having expectations on with expect and then call the different extension methods.

use rxpect::expect;
use rxpect::expectations::EqualityExpectations;

// Expect 1 plus 1 to equal 2
expect(1 + 1).to_equal(2);
running 1 test
test tests::that_one_plus_one_equals_two ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

Failures are neatly reported:

use rxpect::expect;
use rxpect::expectations::EqualityExpectations;

// Expect 1 plus 1 to equal 3
expect(1 + 1).to_equal(3);
thread 'main' panicked at 'Expectation failed (expected == actual)
expected: `3`
actual: `2`'

Modules§

expectations

Structs§

RootExpectations
Container for expectations on a value.

Enums§

CheckResult

Traits§

ExpectProjection
Expectation
An expectation on a value
ExpectationBuilder
Trait to enable fluent building of expectations

Functions§

expect
Create expectations for a value. Used as an entrypoint for fluently building expectations