ready-active-safe 0.1.3

Lifecycle engine for externally driven systems
Documentation
# Macros

Test assertion macros for lifecycle decisions.

## `assert_transitions_to!(decision, expected)`

Asserts that a decision transitions to the expected mode.

```rust
use ready_active_safe::prelude::*;
use ready_active_safe::assert_transitions_to;

let d: Decision<&str, ()> = transition("active");
assert_transitions_to!(d, "active");
```

With enum modes:

```rust
use ready_active_safe::prelude::*;
use ready_active_safe::assert_transitions_to;

#[derive(Debug, Clone, PartialEq, Eq)]
enum Mode { Ready, Active, Safe }

let d: Decision<Mode, ()> = transition(Mode::Active);
assert_transitions_to!(d, Mode::Active);
```

## `assert_stays!(decision)`

Asserts that a decision stays in the current mode.

```rust
use ready_active_safe::prelude::*;
use ready_active_safe::assert_stays;

let d: Decision<&str, ()> = stay();
assert_stays!(d);
```

Also works with `ignore()`:

```rust
use ready_active_safe::prelude::*;
use ready_active_safe::assert_stays;

let d: Decision<&str, ()> = ignore();
assert_stays!(d);
```

## `assert_emits!(decision, [commands])`

Asserts that a decision emits the expected commands, in order.

```rust
use ready_active_safe::prelude::*;
use ready_active_safe::assert_emits;

let d: Decision<(), &str> = stay().emit("init").emit("begin");
assert_emits!(d, ["init", "begin"]);
```

Empty command list:

```rust
use ready_active_safe::prelude::*;
use ready_active_safe::assert_emits;

let d: Decision<(), &str> = stay();
assert_emits!(d, []);
```

## Combining Macros

```rust
use ready_active_safe::prelude::*;
use ready_active_safe::{assert_transitions_to, assert_emits};

#[derive(Debug, Clone, PartialEq, Eq)]
enum Mode { Ready, Active }

let d: Decision<Mode, &str> = transition(Mode::Active).emit("go");
assert_transitions_to!(d, Mode::Active);
assert_emits!(d, ["go"]);
```

## See Also

- [`Decision`]decision.md — the type these macros inspect
- [Free functions]functions.md`stay()`, `transition()`, `ignore()`