Skip to content

Commit ae462c3

Browse files
committed
refactor!: rename assertions has_display_message to has_display_string and does_not_have_display_message to does_not_have_display_string
1 parent c8747e1 commit ae462c3

5 files changed

Lines changed: 36 additions & 36 deletions

File tree

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -371,10 +371,10 @@ for types that implement `core::fmt::Debug`:
371371

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

374-
| assertion | description |
375-
|-------------------------------|------------------------------------------------------------------------------|
376-
| has_display_message | verify that a type formatted for display is equal to the expected string |
377-
| does_not_have_display_message | verify that a type formatted for display is not equal to the expected string |
374+
| assertion | description |
375+
|------------------------------|------------------------------------------------------------------------------|
376+
| has_display_string | verify that a type formatted for display is equal to the expected string |
377+
| does_not_have_display_string | verify that a type formatted for display is not equal to the expected string |
378378

379379
### Emptiness
380380

src/assertions.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2354,10 +2354,10 @@ pub trait AssertHasDebugMessage<E> {
23542354
///
23552355
/// let subject = Foo { hello: "World".into() };
23562356
///
2357-
/// assert_that!(&subject).has_display_message("Hello World");
2358-
/// assert_that!(&subject).does_not_have_display_message("Foo { hello: \"World\" }");
2357+
/// assert_that!(&subject).has_display_string("Hello World");
2358+
/// assert_that!(&subject).does_not_have_display_string("Foo { hello: \"World\" }");
23592359
/// ```
2360-
pub trait AssertHasDisplayMessage<E> {
2360+
pub trait AssertHasDisplayString<E> {
23612361
/// Verifies that a subject formatted for display results in the expected
23622362
/// string.
23632363
///
@@ -2378,10 +2378,10 @@ pub trait AssertHasDisplayMessage<E> {
23782378
///
23792379
/// let subject = Foo { hello: "World".into() };
23802380
///
2381-
/// assert_that!(&subject).has_display_message("Hello World");
2381+
/// assert_that!(&subject).has_display_string("Hello World");
23822382
/// ```
23832383
#[track_caller]
2384-
fn has_display_message(self, expected: E) -> Self;
2384+
fn has_display_string(self, expected: E) -> Self;
23852385

23862386
/// Verifies that a subject formatted for display does not result in the
23872387
/// expected string.
@@ -2403,10 +2403,10 @@ pub trait AssertHasDisplayMessage<E> {
24032403
///
24042404
/// let subject = Foo { hello: "World".into() };
24052405
///
2406-
/// assert_that!(&subject).does_not_have_display_message("Foo { hello: \"World\" }");
2406+
/// assert_that!(&subject).does_not_have_display_string("Foo { hello: \"World\" }");
24072407
/// ```
24082408
#[track_caller]
2409-
fn does_not_have_display_message(self, expected: E) -> Self;
2409+
fn does_not_have_display_string(self, expected: E) -> Self;
24102410
}
24112411

24122412
/// Assert that a string contains a substring or character.

src/equality.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
//! Implementation of the equality assertions.
22
33
use crate::assertions::{
4-
AssertEquality, AssertHasDebugMessage, AssertHasDisplayMessage, AssertSameAs,
4+
AssertEquality, AssertHasDebugMessage, AssertHasDisplayString, AssertSameAs,
55
};
66
use crate::colored::{mark_diff, mark_diff_str};
77
use crate::expectations::{
8-
has_debug_message, has_display_message, is_equal_to, is_same_as, not, HasDebugMessage,
9-
HasDisplayMessage, IsEqualTo, IsSameAs,
8+
has_debug_message, has_display_string, is_equal_to, is_same_as, not, HasDebugMessage,
9+
HasDisplayString, IsEqualTo, IsSameAs,
1010
};
1111
use crate::spec::{DiffFormat, Expectation, Expression, FailingStrategy, Invertible, Spec};
1212
use crate::std::fmt::{Debug, Display};
@@ -138,22 +138,22 @@ where
138138

139139
impl<E> Invertible for HasDebugMessage<E> {}
140140

141-
impl<S, E, R> AssertHasDisplayMessage<E> for Spec<'_, S, R>
141+
impl<S, E, R> AssertHasDisplayString<E> for Spec<'_, S, R>
142142
where
143143
S: Display,
144144
E: AsRef<str>,
145145
R: FailingStrategy,
146146
{
147-
fn has_display_message(self, expected: E) -> Self {
148-
self.expecting(has_display_message(expected))
147+
fn has_display_string(self, expected: E) -> Self {
148+
self.expecting(has_display_string(expected))
149149
}
150150

151-
fn does_not_have_display_message(self, expected: E) -> Self {
152-
self.expecting(not(has_display_message(expected)))
151+
fn does_not_have_display_string(self, expected: E) -> Self {
152+
self.expecting(not(has_display_string(expected)))
153153
}
154154
}
155155

156-
impl<S, E> Expectation<S> for HasDisplayMessage<E>
156+
impl<S, E> Expectation<S> for HasDisplayString<E>
157157
where
158158
S: Display,
159159
E: AsRef<str>,
@@ -173,9 +173,9 @@ where
173173
let expected = self.expected.as_ref();
174174
let (marked_actual, marked_expected) = mark_diff_str(&actual.to_string(), expected, format);
175175
format!(
176-
"expected {expression} to {not}have display message {expected:?}\n but was: \"{marked_actual}\"\n expected: {not}\"{marked_expected}\"",
176+
"expected {expression} to {not}have a display string equal to {expected:?}\n but was: \"{marked_actual}\"\n expected: {not}\"{marked_expected}\"",
177177
)
178178
}
179179
}
180180

181-
impl<E> Invertible for HasDisplayMessage<E> {}
181+
impl<E> Invertible for HasDisplayString<E> {}

src/error/tests.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -98,28 +98,28 @@ fn verify_error_does_not_have_debug_message_fails() {
9898
}
9999

100100
#[test]
101-
fn error_has_display_message() {
101+
fn error_has_display_string() {
102102
let error = SuperError {
103103
source: SourceError::Bar,
104104
};
105105

106-
assert_that(error).has_display_message("super-error caused by bar error");
106+
assert_that(error).has_display_string("super-error caused by bar error");
107107
}
108108

109109
#[test]
110-
fn verify_error_has_display_message_fails() {
110+
fn verify_error_has_display_string_fails() {
111111
let error = SuperError {
112112
source: SourceError::Foo,
113113
};
114114

115115
let failures = verify_that(error)
116-
.has_display_message("super-error caused by bar error")
116+
.has_display_string("super-error caused by bar error")
117117
.display_failures();
118118

119119
assert_eq!(
120120
failures,
121121
&[
122-
r#"expected subject to have display message "super-error caused by bar error"
122+
r#"expected subject to have a display string equal to "super-error caused by bar error"
123123
but was: "super-error caused by foo error"
124124
expected: "super-error caused by bar error"
125125
"#
@@ -128,28 +128,28 @@ fn verify_error_has_display_message_fails() {
128128
}
129129

130130
#[test]
131-
fn error_does_not_have_display_message() {
131+
fn error_does_not_have_display_string() {
132132
let error = SuperError {
133133
source: SourceError::Bar,
134134
};
135135

136-
assert_that(error).does_not_have_display_message("super-error caused by foo error");
136+
assert_that(error).does_not_have_display_string("super-error caused by foo error");
137137
}
138138

139139
#[test]
140-
fn verify_error_does_not_have_display_message_fails() {
140+
fn verify_error_does_not_have_display_string_fails() {
141141
let error = SuperError {
142142
source: SourceError::Foo,
143143
};
144144

145145
let failures = verify_that(error)
146-
.does_not_have_display_message("super-error caused by foo error")
146+
.does_not_have_display_string("super-error caused by foo error")
147147
.display_failures();
148148

149149
assert_eq!(
150150
failures,
151151
&[
152-
r#"expected subject to not have display message "super-error caused by foo error"
152+
r#"expected subject to not have a display string equal to "super-error caused by foo error"
153153
but was: "super-error caused by foo error"
154154
expected: not "super-error caused by foo error"
155155
"#

src/expectations.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -646,12 +646,12 @@ pub struct HasDebugMessage<E> {
646646
pub expected: E,
647647
}
648648

649-
/// Creates a [`HasDisplayMessage`] expectation.
650-
pub fn has_display_message<E>(expected: E) -> HasDisplayMessage<E> {
651-
HasDisplayMessage { expected }
649+
/// Creates a [`HasDisplayString`] expectation.
650+
pub fn has_display_string<E>(expected: E) -> HasDisplayString<E> {
651+
HasDisplayString { expected }
652652
}
653653

654-
pub struct HasDisplayMessage<E> {
654+
pub struct HasDisplayString<E> {
655655
pub expected: E,
656656
}
657657

0 commit comments

Comments
 (0)