Skip to main content

TestResponse

Struct TestResponse 

Source
pub struct TestResponse {
    pub response: Response,
}
Expand description

A response with assertions attached, each returning self so they chain.

Fields§

§response: Response

Implementations§

Source§

impl TestResponse

Source

pub fn status(&self) -> u16

Source

pub fn body(&self) -> String

Source

pub fn body_bytes(&self) -> &[u8]

The raw body, for a response that is not text — a compressed one, say.

Source

pub fn json(&self) -> Json

Source

pub fn header(&self, name: &str) -> Option<&str>

Source

pub fn assert_status(self, expected: u16) -> Self

Source

pub fn assert_ok(self) -> Self

Source

pub fn assert_not_found(self) -> Self

Source

pub fn assert_see(self, needle: &str) -> Self

Assert the body contains this text.

Source

pub fn assert_dont_see(self, needle: &str) -> Self

Source

pub fn assert_header(self, name: &str, expected: &str) -> Self

Source

pub fn assert_redirect(self, location: &str) -> Self

Source

pub fn assert_json(self, path: &str, expected: impl Into<Json>) -> Self

Assert a dotted path in the JSON body equals a value.

Source

pub fn assert_json_missing(self, path: &str) -> Self

Auto Trait Implementations§

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.