Skip to content

Commit f109182

Browse files
committed
Merge branch 'main' into refactor/rename-has-display-message-to-has-display-string
# Conflicts: # src/equality.rs
2 parents ae462c3 + 35e4e6d commit f109182

5 files changed

Lines changed: 35 additions & 35 deletions

File tree

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -364,10 +364,10 @@ for types that implement `std::error::Error`.
364364

365365
for types that implement `core::fmt::Debug`:
366366

367-
| assertion | description |
368-
|-----------------------------|----------------------------------------------------------------------------|
369-
| has_debug_message | verify that a type formatted for debug is equal to the expected string |
370-
| does_not_have_debug_message | verify that a type formatted for debug is not equal to the expected string |
367+
| assertion | description |
368+
|----------------------------|----------------------------------------------------------------------------|
369+
| has_debug_string | verify that a type formatted for debug is equal to the expected string |
370+
| does_not_have_debug_string | verify that a type formatted for debug is not equal to the expected string |
371371

372372
for types that implement `core::fmt::Display`:
373373

src/assertions.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2287,10 +2287,10 @@ pub trait AssertErrorHasSource<'a, R> {
22872287
///
22882288
/// let subject = Foo { hello: "World".into() };
22892289
///
2290-
/// assert_that!(&subject).has_debug_message("Foo { hello: \"World\" }");
2291-
/// assert_that!(&subject).does_not_have_debug_message("Bar { hello: \"World\" }");
2290+
/// assert_that!(&subject).has_debug_string("Foo { hello: \"World\" }");
2291+
/// assert_that!(&subject).does_not_have_debug_string("Bar { hello: \"World\" }");
22922292
/// ```
2293-
pub trait AssertHasDebugMessage<E> {
2293+
pub trait AssertHasDebugString<E> {
22942294
/// Verifies that a subject formatted for debugging results in the expected
22952295
/// string.
22962296
///
@@ -2306,10 +2306,10 @@ pub trait AssertHasDebugMessage<E> {
23062306
///
23072307
/// let subject = Foo { hello: "World".into() };
23082308
///
2309-
/// assert_that!(subject).has_debug_message("Foo { hello: \"World\" }");
2309+
/// assert_that!(subject).has_debug_string("Foo { hello: \"World\" }");
23102310
/// ```
23112311
#[track_caller]
2312-
fn has_debug_message(self, expected: E) -> Self;
2312+
fn has_debug_string(self, expected: E) -> Self;
23132313

23142314
/// Verifies that a subject formatted for debugging does not result in the
23152315
/// expected string.
@@ -2326,10 +2326,10 @@ pub trait AssertHasDebugMessage<E> {
23262326
///
23272327
/// let subject = Foo { hello: "World".into() };
23282328
///
2329-
/// assert_that!(subject).does_not_have_debug_message("Hello World");
2329+
/// assert_that!(subject).does_not_have_debug_string("Hello World");
23302330
/// ```
23312331
#[track_caller]
2332-
fn does_not_have_debug_message(self, expected: E) -> Self;
2332+
fn does_not_have_debug_string(self, expected: E) -> Self;
23332333
}
23342334

23352335
/// Assert a type formatted into a display string.

src/equality.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
//! Implementation of the equality assertions.
22
33
use crate::assertions::{
4-
AssertEquality, AssertHasDebugMessage, AssertHasDisplayString, AssertSameAs,
4+
AssertEquality, AssertHasDebugString, AssertHasDisplayString, AssertSameAs,
55
};
66
use crate::colored::{mark_diff, mark_diff_str};
77
use crate::expectations::{
8-
has_debug_message, has_display_string, is_equal_to, is_same_as, not, HasDebugMessage,
8+
has_debug_string, has_display_string, is_equal_to, is_same_as, not, HasDebugString,
99
HasDisplayString, IsEqualTo, IsSameAs,
1010
};
1111
use crate::spec::{DiffFormat, Expectation, Expression, FailingStrategy, Invertible, Spec};
@@ -95,22 +95,22 @@ where
9595

9696
impl<E> Invertible for IsSameAs<E> {}
9797

98-
impl<S, E, R> AssertHasDebugMessage<E> for Spec<'_, S, R>
98+
impl<S, E, R> AssertHasDebugString<E> for Spec<'_, S, R>
9999
where
100100
S: Debug,
101101
E: AsRef<str>,
102102
R: FailingStrategy,
103103
{
104-
fn has_debug_message(self, expected: E) -> Self {
105-
self.expecting(has_debug_message(expected))
104+
fn has_debug_string(self, expected: E) -> Self {
105+
self.expecting(has_debug_string(expected))
106106
}
107107

108-
fn does_not_have_debug_message(self, expected: E) -> Self {
109-
self.expecting(not(has_debug_message(expected)))
108+
fn does_not_have_debug_string(self, expected: E) -> Self {
109+
self.expecting(not(has_debug_string(expected)))
110110
}
111111
}
112112

113-
impl<S, E> Expectation<S> for HasDebugMessage<E>
113+
impl<S, E> Expectation<S> for HasDebugString<E>
114114
where
115115
S: Debug,
116116
E: AsRef<str>,
@@ -131,12 +131,12 @@ where
131131
let (marked_actual, marked_expected) =
132132
mark_diff_str(&format!("{actual:?}"), expected, format);
133133
format!(
134-
"expected {expression} to {not}have debug message {expected:?}\n but was: {marked_actual}\n expected: {not}{marked_expected}",
134+
"expected {expression} to {not}have a debug string equal to {expected:?}\n but was: {marked_actual}\n expected: {not}{marked_expected}",
135135
)
136136
}
137137
}
138138

139-
impl<E> Invertible for HasDebugMessage<E> {}
139+
impl<E> Invertible for HasDebugString<E> {}
140140

141141
impl<S, E, R> AssertHasDisplayString<E> for Spec<'_, S, R>
142142
where

src/error/tests.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,28 +38,28 @@ impl Display for SourceError {
3838
impl Error for SourceError {}
3939

4040
#[test]
41-
fn error_has_debug_message() {
41+
fn error_has_debug_string() {
4242
let error = SuperError {
4343
source: SourceError::Bar,
4444
};
4545

46-
assert_that(error).has_debug_message("SuperError { source: Bar }");
46+
assert_that(error).has_debug_string("SuperError { source: Bar }");
4747
}
4848

4949
#[test]
50-
fn verify_error_has_debug_message_fails() {
50+
fn verify_error_has_debug_string_fails() {
5151
let error = SuperError {
5252
source: SourceError::Foo,
5353
};
5454

5555
let failures = verify_that(error)
56-
.has_debug_message("SuperError { source: Bar }")
56+
.has_debug_string("SuperError { source: Bar }")
5757
.display_failures();
5858

5959
assert_eq!(
6060
failures,
6161
&[
62-
r#"expected subject to have debug message "SuperError { source: Bar }"
62+
r#"expected subject to have a debug string equal to "SuperError { source: Bar }"
6363
but was: SuperError { source: Foo }
6464
expected: SuperError { source: Bar }
6565
"#
@@ -68,28 +68,28 @@ fn verify_error_has_debug_message_fails() {
6868
}
6969

7070
#[test]
71-
fn error_does_not_have_debug_message() {
71+
fn error_does_not_have_debug_string() {
7272
let error = SuperError {
7373
source: SourceError::Bar,
7474
};
7575

76-
assert_that(error).does_not_have_debug_message("SuperError { source: Foo }");
76+
assert_that(error).does_not_have_debug_string("SuperError { source: Foo }");
7777
}
7878

7979
#[test]
80-
fn verify_error_does_not_have_debug_message_fails() {
80+
fn verify_error_does_not_have_debug_string_fails() {
8181
let error = SuperError {
8282
source: SourceError::Bar,
8383
};
8484

8585
let failures = verify_that(error)
86-
.does_not_have_debug_message("SuperError { source: Bar }")
86+
.does_not_have_debug_string("SuperError { source: Bar }")
8787
.display_failures();
8888

8989
assert_eq!(
9090
failures,
9191
&[
92-
r#"expected subject to not have debug message "SuperError { source: Bar }"
92+
r#"expected subject to not have a debug string equal to "SuperError { source: Bar }"
9393
but was: SuperError { source: Bar }
9494
expected: not SuperError { source: Bar }
9595
"#

src/expectations.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -637,12 +637,12 @@ pub struct ErrorHasSourceMessage {
637637
pub expected_source_message: String,
638638
}
639639

640-
/// Creates a [`HasDebugMessage`] expectation.
641-
pub fn has_debug_message<E>(expected: E) -> HasDebugMessage<E> {
642-
HasDebugMessage { expected }
640+
/// Creates a [`HasDebugString`] expectation.
641+
pub fn has_debug_string<E>(expected: E) -> HasDebugString<E> {
642+
HasDebugString { expected }
643643
}
644644

645-
pub struct HasDebugMessage<E> {
645+
pub struct HasDebugString<E> {
646646
pub expected: E,
647647
}
648648

0 commit comments

Comments
 (0)