1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
use crate::{implementation, AssertionConnector, BasicAsserter};

impl<AssertedType> BasicAsserter<AssertedType>
where
    AssertedType: AsRef<str>,
{
    /// Asserts that the value contains the pattern
    ///
    /// # Examples
    /// ```
    /// # use smoothy::{assert_that, BasicAsserter};
    /// #
    /// assert_that("Hello World").contains("Hello").and().contains("World");
    /// ```
    ///
    /// # Panics
    /// When the value does not contain the pattern
    pub fn contains(self, pattern: impl AsRef<str>) -> AssertionConnector<AssertedType> {
        let asserted_value = self.value.as_ref();

        implementation::assert(
            asserted_value.contains(pattern.as_ref()),
            "Input contains pattern",
            self.value.as_ref(),
        );

        AssertionConnector { value: self.value }
    }
}