Skip to content

Commit

Permalink
Doctest the README
Browse files Browse the repository at this point in the history
  • Loading branch information
TehPers committed Aug 13, 2024
1 parent 2af3060 commit 4a48072
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,16 @@ Supports both synchronous and asynchronous assertions.
use expecters::prelude::*;

#[tokio::test]
async fn test() {
async fn test() {
expect!(1, as_display, to_equal("1"));
expect!(1..=5, count, to_equal(5));

expect!(get_cat_url(0), when_ready, to_contain_substr(".png")).await;
expect!(
[get_cat_url(0), get_cat_url(5), get_cat_url(42)],
all,
when_ready,
to_end_with(".png"),
).await;
}

async fn get_cat_url(id: u32) -> String {
Expand Down
6 changes: 6 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,9 @@ pub mod specialization;
mod macros;

pub use assertions::AssertionOutput;

#[cfg(doctest)]
#[doc = include_str!("../README.md")]
mod readme_tests {
// Runs doc tests on the readme
}

0 comments on commit 4a48072

Please sign in to comment.