Skip to content

Commit

Permalink
Add error message to README
Browse files Browse the repository at this point in the history
  • Loading branch information
TehPers committed Aug 15, 2024
1 parent 748ed62 commit f7ffb87
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 2 deletions.
27 changes: 25 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ async fn test() {
expect!(1..=5, count, to_equal(5));

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

Expand All @@ -26,6 +26,29 @@ async fn get_cat_url(id: u32) -> String {
}
```

Error message:

```text
thread 'test' panicked at README.md:13:6:
assertion failed:
at: README.md:8:5 [readme_example]
subject: [get_cat_url(0), get_cat_url(40), get_cat_url(42)]
steps:
all:
received: ? (no debug representation)
index: 2
when_ready:
received: ? (no debug representation)
to_end_with: substring not found
received: "cats/42.png"
expected: "0.png"
```

Supports colored messages with the `colors` feature.

## Built-in assertions

### General
Expand Down
20 changes: 20 additions & 0 deletions tests/readme_example.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
use expecters::prelude::*;

#[tokio::test]
#[ignore = "run this manually to see the output from the README"]
async fn test() {
expect!(1, as_display, to_equal("1"));
expect!(1..=5, count, to_equal(5));

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

async fn get_cat_url(id: u32) -> String {
format!("cats/{id}.png")
}

0 comments on commit f7ffb87

Please sign in to comment.