Struct goose_eggs::Validate [−][src]
pub struct Validate<'a> { /* fields omitted */ }
Expand description
Define one or more items to be validated in a web page response.
This structure is passed to validate_and_load_static_assets
.
Example
use goose_eggs::Validate; fn examples() { // Manually build a Validate strucuture that validates the page title and // some arbitrary texts in the response html. let _validate = Validate::new( None, Some("my page"), vec!["foo", r#"<a href="bar">"#], vec![] ); // Use `title_texts()` helper to perform the same validation. let _validate = Validate::title_texts("my page", vec!["foo", r#"<a href="bar">"#]); // Use `title_text()` helper to perform similar validation, validating only // one text on the page. let _validate = Validate::title_text("my page", r#"<a href="foo">"#); }
Implementations
Create a new Validate struct, specifying status
, title
, texts
and headers
.
Example
use goose_eggs::{Header, Validate}; let _validate = Validate::new( // Validate the response status code. Some(404), // Validate the response page title. Some("Page Not Found"), // Validate arbitrary text on the response page. vec!["Oops, something went wrong!"], // Validate that the response was sent via https. vec![&Header::name_value("scheme", "https")], );
Create a Validate object to validate the response status code.
Example
use goose_eggs::{Header, Validate}; let _validate = Validate::status(200);
Create a Validate object to validate the response title.
Example
use goose_eggs::{Header, Validate}; let _validate = Validate::title("Home page");
Create a Validate object to validate the response status code and title.
Example
use goose_eggs::{Header, Validate}; let _validate = Validate::status_title(200, "Home page");
Create a Validate object to validate specific text is on the response page.
Example
use goose_eggs::{Header, Validate}; let _validate = Validate::text("This text should be on the page.");
Create a Validate object to validate the response has the correct status code and contains specific text.
Example
use goose_eggs::{Header, Validate}; let _validate = Validate::status_text(200, "This text should be on the page.");
Create a Validate object to validate the response has the correct title and also contains specific text.
Example
use goose_eggs::{Header, Validate}; let _validate = Validate::title_text("Example", "This text should be on the page.");
Create a Validate object to validate the response code, that the page has the correct title and also contains specific text.
Example
use goose_eggs::{Header, Validate}; let _validate = Validate::status_title_text(200, "Example", "This text should be on the page.");
Create a Validate object to validate that the response page contains multiple specific texts.
Example
use goose_eggs::{Header, Validate}; let _validate = Validate::texts(vec!["This text should be on the page.", "And also this", r#"<span>and this</a>"#]);
Create a Validate object to validate response status code and that the page contains multiple specific texts.
Example
use goose_eggs::{Header, Validate}; let _validate = Validate::status_texts(200, vec!["This text should be on the page.", "And also this", r#"<span>and this</a>"#]);
Create a Validate object to validate the response title and that the page contains multiple specific texts.
Example
use goose_eggs::{Header, Validate}; let _validate = Validate::title_texts("Example", vec!["This text should be on the page.", "And also this", r#"<span>and this</a>"#]);
Create a Validate object to validate the response status code, the page title and that the page contains multiple specific texts.
Example
use goose_eggs::{Header, Validate}; let _validate = Validate::status_title_texts(200, "Example", vec!["This text should be on the page.", "And also this", r#"<span>and this</a>"#]);
Create a Validate object to validate the response included a specific header.
Example
use goose_eggs::{Header, Validate}; let _validate = Validate::header(&Header::name("x-cache"));
Create a Validate object to validate the response status code and that it included a specific header.
Example
use goose_eggs::{Header, Validate}; let _validate = Validate::status_header(200, &Header::name("x-cache"));
Create a Validate object to validate the response title and that it included a specific header.
Example
use goose_eggs::{Header, Validate}; let _validate = Validate::title_header("example", &Header::name("x-cache"));
Create a Validate object to validate the response status code, title and that it included a specific header.
Example
use goose_eggs::{Header, Validate}; let _validate = Validate::status_title_header(200, "example", &Header::name("x-cache"));
Create a Validate object to validate the response html contains specific text and that it included a specific header.
Example
use goose_eggs::{Header, Validate}; let _validate = Validate::text_header("The page has this text", &Header::name("x-cache"));
Create a Validate object to validate the response status code, that the resposne html contains specific text and that it included a specific header.
Example
use goose_eggs::{Header, Validate}; let _validate = Validate::status_text_header(200, "The page has this text", &Header::name("x-cache"));
Create a Validate object to validate the response html title, that it contains specific text and that it included a specific header.
Example
use goose_eggs::{Header, Validate}; let _validate = Validate::title_text_header("Example", "The page has this text", &Header::name("x-cache"));
Create a Validate object to validate the response status code, the html title, that it contains specific text and that it included a specific header.
Example
use goose_eggs::{Header, Validate}; let _validate = Validate::status_title_text_header(200, "Example", "The page has this text", &Header::name("x-cache"));
Create a Validate object to validate that the response included multiple specific headers.
Example
use goose_eggs::{Header, Validate}; let _validate = Validate::headers(vec![&Header::name("x-cache"), &Header::name("x-generator")]);
Create a Validate object to validate the response status code and that it included multiple specific headers.
Example
use goose_eggs::{Header, Validate}; let _validate = Validate::status_headers(200, vec![&Header::name("x-cache"), &Header::name("x-generator")]);
Create a Validate object to validate the response html title and that it included multiple specific headers.
Example
use goose_eggs::{Header, Validate}; let _validate = Validate::title_headers("Example", vec![&Header::name("x-cache"), &Header::name("x-generator")]);
Create a Validate object to validate the response status code, the html title and that it included multiple specific headers.
Example
use goose_eggs::{Header, Validate}; let _validate = Validate::status_title_headers(200, "Example", vec![&Header::name("x-cache"), &Header::name("x-generator")]);
Create a Validate object to validate the response html contained specific text and that the response also included multiple specific headers.
Example
use goose_eggs::{Header, Validate}; let _validate = Validate::text_headers("This text is on the page", vec![&Header::name("x-cache"), &Header::name("x-generator")]);
Create a Validate object to validate the response status code, that the html contained specific text and that the response also included multiple specific headers.
Example
use goose_eggs::{Header, Validate}; let _validate = Validate::status_text_headers(200, "This text is on the page", vec![&Header::name("x-cache"), &Header::name("x-generator")]);
Create a Validate object to validate the response html title, that the html contained specific text and that the response also included multiple specific headers.
Example
use goose_eggs::{Header, Validate}; let _validate = Validate::title_text_headers("Example", "This text is on the page", vec![&Header::name("x-cache"), &Header::name("x-generator")]);
Create a Validate object to validate the response html includes multiple specific texts and that the response also included multiple specific headers.
Example
use goose_eggs::{Header, Validate}; let _validate = Validate::texts_headers(vec!["This text is on the page", r#"<a href="/foo">and so is this</a>"#], vec![&Header::name("x-cache"), &Header::name("x-generator")]);
Create a Validate object to validate the response status code, that html includes multiple specific texts and that the response also included multiple specific headers.
Example
use goose_eggs::{Header, Validate}; let _validate = Validate::status_texts_headers(200, vec!["This text is on the page", r#"<a href="/foo">and so is this</a>"#], vec![&Header::name("x-cache"), &Header::name("x-generator")]);
Create a Validate object to validate the response html title, that html includes multiple specific texts and that the response also included multiple specific headers.
Example
use goose_eggs::{Header, Validate}; let _validate = Validate::title_texts_headers("Example", vec!["This text is on the page", r#"<a href="/foo">and so is this</a>"#], vec![&Header::name("x-cache"), &Header::name("x-generator")]);
Create a Validate object to validate the response code, that html includes multiple specific texts and that the response also included multiple specific headers.
Example
use goose_eggs::{Header, Validate}; let _validate = Validate::status_title_texts_headers(200, "Example", vec!["This text is on the page", r#"<a href="/foo">and so is this</a>"#], vec![&Header::name("x-cache"), &Header::name("x-generator")]);
Trait Implementations
Auto Trait Implementations
impl<'a> RefUnwindSafe for Validate<'a>
impl<'a> UnwindSafe for Validate<'a>
Blanket Implementations
Mutably borrows from an owned value. Read more
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
type Output = T
type Output = T
Should always be Self
pub fn vzip(self) -> V