Skip to main content

Bindings

Struct Bindings 

Source
pub struct Bindings<W> {
    pub world: W,
    /* private fields */
}

Fields§

§world: W

Implementations§

Source§

impl<W> Bindings<W>

Source

pub fn new(world: W) -> Self

Source

pub fn fresh(self, services: &[&str]) -> Self

The services to start afresh before each test (a subset of those it needs).

Source

pub fn needs(self, services: &[&str]) -> Self

The external services these bindings need (see crate::service).

Source

pub fn observe<V: Into<Value>>( self, subject: &str, f: impl FnMut(&W) -> V + 'static, ) -> Self

How to read a state. Subjects match the vocabulary ignoring case and a leading “the”.

Source

pub fn set(self, subject: &str, f: impl FnMut(&mut W, &Value) + 'static) -> Self

How to change a state, as an action and (unless Bindings::arrange says otherwise) when arranging the start.

Source

pub fn arrange( self, subject: &str, f: impl FnMut(&mut W, &Value) + 'static, ) -> Self

How to put a state in place before the first step, when that differs from Bindings::set.

Source

pub fn on(self, event: &str, f: impl FnMut(&mut W) + 'static) -> Self

Source

pub fn on_reset(self, f: impl FnMut(&mut W) + 'static) -> Self

Source

pub fn on_settle(self, f: impl FnMut(&mut W) + 'static) -> Self

Source

pub fn on_advance(self, f: impl FnMut(&mut W) -> Progress + 'static) -> Self

Source

pub fn on_screenshot(self, f: impl FnMut(&W) -> Screenshot + 'static) -> Self

Trait Implementations§

Source§

impl<W> Driver for Bindings<W>

Source§

fn needs(&self) -> Vec<String>

The external services this driver needs for its tests (see crate::service): a controller, a database. The runner starts them before a plan, and when one cannot be had here the plans are “not supported yet”, with what to do about it.
Source§

fn fresh(&self) -> Vec<String>

The services that must be started afresh before each test (a database the last test wrote to): a subset of Driver::needs.
Source§

fn reset(&mut self) -> Result<(), String>

Put the system in its starting state (what the Background describes), before each test.
Source§

fn arrange(&mut self, var: &Variable, value: &Value) -> Result<(), String>

Make var hold value before the first step (“Given …”).
Source§

fn set(&mut self, var: &Variable, value: &Value) -> Result<(), String>

Make var hold value as an action (“When the dial is 80 %”).
Source§

fn perform(&mut self, event: &Event) -> Result<(), String>

Make event happen (“When the user presses reset”).
Source§

fn observe(&mut self, var: &Variable) -> Result<Value, String>

What var is now. Enumerated values are matched to the vocabulary ignoring case.
Source§

fn settle(&mut self)

Let the system settle after an action, before anything is observed: long enough for what should happen to happen, and for what shouldn’t to show. Without it, “Then the kettle is off” could pass in the instant before it switches on.
Source§

fn advance(&mut self) -> Progress

Let a little time pass before the runner observes again.
Source§

fn screenshot(&mut self) -> Result<Option<Screenshot>, String>

Source§

fn supports(&self, need: Need<'_>) -> bool

Can it do need? The runner checks every plan up front, so a missing binding fails the test before it starts instead of halfway through.
Source§

fn can_arrange(&self, var: &Variable, value: &Value) -> bool

Can it put var in value to start a test? Driver::supports only knows the state; a driver that can arrange some of its values and not others (a test account that can’t be emptied can’t start with no messages) says so here, and the tests that need the rest are “not supported yet” instead of failing.

Auto Trait Implementations§

§

impl<W> !RefUnwindSafe for Bindings<W>

§

impl<W> !Send for Bindings<W>

§

impl<W> !Sync for Bindings<W>

§

impl<W> !UnwindSafe for Bindings<W>

§

impl<W> Freeze for Bindings<W>
where W: Freeze,

§

impl<W> Unpin for Bindings<W>
where W: Unpin,

§

impl<W> UnsafeUnpin for Bindings<W>
where W: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.