Skip to main content

assert_difference

Function assert_difference 

Source
pub fn assert_difference<R>(
    expression: impl FnMut() -> i64,
    difference: i64,
    block: impl FnOnce() -> R,
) -> R
Expand description

Asserts that block changes the number expression returns by difference (Rails’ assert_difference), and returns the block’s value.

§Examples

let count = std::cell::Cell::new(1);
ocre::testing::assert_difference(|| count.get(), 1, || count.set(2));