Skip to main content

Fake

Struct Fake 

Source
pub struct Fake { /* private fields */ }
Expand description

A script of URL patterns to responses, plus a record of what was asked.

Implementations§

Source§

impl Fake

Source

pub fn new() -> Self

Source

pub fn on(self, pattern: &str, response: FakeResponse) -> Self

Answer any URL containing pattern, or matching it with a * wildcard.

Source

pub fn fallback(self, response: FakeResponse) -> Self

Answer anything not matched above. Without this, an unexpected request is an error — a test should not silently pass because a call went somewhere nobody scripted.

Source

pub fn recorded(&self) -> Vec<Recorded>

Every request the fake saw, in order.

Source

pub fn count(&self) -> usize

Source

pub fn sent(&self, pattern: &str) -> bool

Whether a request matching this pattern was sent.

Source

pub fn assert_sent(&self, pattern: &str)

Source

pub fn assert_not_sent(&self, pattern: &str)

Source

pub fn assert_count(&self, expected: usize)

Trait Implementations§

Source§

impl Default for Fake

Source§

fn default() -> Fake

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl !Freeze for Fake

§

impl RefUnwindSafe for Fake

§

impl Send for Fake

§

impl Sync for Fake

§

impl Unpin for Fake

§

impl UnsafeUnpin for Fake

§

impl UnwindSafe for Fake

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.