Skip to content

Commit

Permalink
#794 Replace containsString with equalTo
Browse files Browse the repository at this point in the history
  • Loading branch information
Izbassar Tolegen committed Mar 3, 2018
1 parent 76917b2 commit a39db8b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/main/java/org/takes/facets/hamcrest/HmRqTextBody.java
Expand Up @@ -44,11 +44,11 @@
public final class HmRqTextBody extends AbstractHmTextBody<Request> {

/**
* Ctor with containsString matcher and default charset.
* Ctor with equalTo matcher and default charset.
* @param expected String to test against
*/
public HmRqTextBody(final String expected) {
this(Matchers.containsString(expected));
this(Matchers.equalTo(expected));
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/takes/facets/hamcrest/HmRsTextBody.java
Expand Up @@ -44,11 +44,11 @@
public final class HmRsTextBody extends AbstractHmTextBody<Response> {

/**
* Ctor with containsString matcher and default charset.
* Ctor with equalTo matcher and default charset.
* @param expected String to test against
*/
public HmRsTextBody(final String expected) {
this(Matchers.containsString(expected));
this(Matchers.equalTo(expected));
}

/**
Expand Down
9 changes: 5 additions & 4 deletions src/test/java/org/takes/facets/hamcrest/HmRqTextBodyTest.java
Expand Up @@ -39,21 +39,22 @@
public final class HmRqTextBodyTest {

/**
* HmRqTextBody can test if body contains text.
* HmRqTextBody can test if body equals text.
*/
@Test
public void testsBodyValueContainsText() {
final String same = "Same text";
MatcherAssert.assertThat(
new RqFake(
Collections.<String>emptyList(),
"Some text"
same
),
new HmRqTextBody("text")
new HmRqTextBody(same)
);
}

/**
* HmRqTextBody can test if body doesn't contains text.
* HmRqTextBody can test if body doesn't equal to text.
*/
@Test
public void testsBodyValueDoesNotContainsText() {
Expand Down
9 changes: 5 additions & 4 deletions src/test/java/org/takes/facets/hamcrest/HmRsTextBodyTest.java
Expand Up @@ -38,18 +38,19 @@
public final class HmRsTextBodyTest {

/**
* HmRsTextBody can test if body contains text.
* HmRsTextBody can test if body equals text.
*/
@Test
public void testsBodyValueContainsText() {
final String same = "<h1>Hello</h1>";
MatcherAssert.assertThat(
new RsWithBody("<html><h1>Hello</h1></html>"),
new HmRsTextBody("<h1>Hello</h1>")
new RsWithBody(same),
new HmRsTextBody(same)
);
}

/**
* HmRsTextBody can test if body doesn't contains text.
* HmRsTextBody can test if body doesn't equal to text.
*/
@Test
public void testsBodyValueDoesNotContainsText() {
Expand Down

0 comments on commit a39db8b

Please sign in to comment.