pub struct Bindings<W> {
pub world: W,
/* private fields */
}Fields§
§world: WImplementations§
Source§impl<W> Bindings<W>
impl<W> Bindings<W>
pub fn new(world: W) -> Self
Sourcepub fn fresh(self, services: &[&str]) -> Self
pub fn fresh(self, services: &[&str]) -> Self
The services to start afresh before each test (a subset of those it needs).
Sourcepub fn needs(self, services: &[&str]) -> Self
pub fn needs(self, services: &[&str]) -> Self
The external services these bindings need (see crate::service).
Sourcepub fn observe<V: Into<Value>>(
self,
subject: &str,
f: impl FnMut(&W) -> V + 'static,
) -> Self
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”.
Sourcepub fn set(self, subject: &str, f: impl FnMut(&mut W, &Value) + 'static) -> Self
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.
Sourcepub fn arrange(
self,
subject: &str,
f: impl FnMut(&mut W, &Value) + 'static,
) -> Self
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.
pub fn on(self, event: &str, f: impl FnMut(&mut W) + 'static) -> Self
pub fn on_reset(self, f: impl FnMut(&mut W) + 'static) -> Self
pub fn on_settle(self, f: impl FnMut(&mut W) + 'static) -> Self
pub fn on_advance(self, f: impl FnMut(&mut W) -> Progress + 'static) -> Self
pub fn on_screenshot(self, f: impl FnMut(&W) -> Screenshot + 'static) -> Self
Trait Implementations§
Source§impl<W> Driver for Bindings<W>
impl<W> Driver for Bindings<W>
Source§fn needs(&self) -> Vec<String>
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>
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>
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>
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>
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>
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>
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)
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.
fn screenshot(&mut self) -> Result<Option<Screenshot>, String>
Source§fn supports(&self, need: Need<'_>) -> bool
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
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more