Skip to content

Commit

Permalink
Migrate Truth subjects from the old fail(String, Object) to the new f…
Browse files Browse the repository at this point in the history
…ailWithActual(String, Object), tweaking verbs for the new grammar.

Before:
  fail("has foo", expected);

After:
  failWithActual("expected to have foo", expected);

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=244518456
  • Loading branch information
cpovirk committed Apr 24, 2019
1 parent 1093f73 commit 3f1f222
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void isEqualTo(@Nullable Object other) {
JavaFileObject otherFile = (JavaFileObject) other;
try {
if (!asByteSource(actual()).contentEquals(asByteSource(otherFile))) {
fail("is equal to", other);
failWithActual("expected to be equal to", other);
}
} catch (IOException e) {
throw new RuntimeException(e);
Expand All @@ -85,7 +85,7 @@ public void isEqualTo(@Nullable Object other) {
public void hasContents(ByteSource expected) {
try {
if (!asByteSource(actual()).contentEquals(expected)) {
fail("has contents", expected);
failWithActual("expected to have contents", expected);
}
} catch (IOException e) {
throw new RuntimeException(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,8 @@ public void compilesWithoutError_throws() {
.that(JavaFileObjects.forResource("HelloWorld-broken.java"))
.compilesWithoutError();
AssertionError expected = expectFailure.getFailure();
assertThat(expected.getMessage()).startsWith("Compilation produced the following diagnostics:\n");
assertThat(expected.getMessage()).startsWith("Compilation produced the following"
+ " diagnostics:\n");
assertThat(expected.getMessage()).contains("No files were generated.");
}

Expand Down Expand Up @@ -883,7 +884,7 @@ public void generatesFileNamed_failOnFileContents() {
.withContents(ByteSource.wrap("Bogus".getBytes(UTF_8)));
AssertionError expected = expectFailure.getFailure();
assertThat(expected.getMessage()).contains("Foo");
assertThat(expected.getMessage()).contains(" has contents ");
assertThat(expected.getMessage()).contains(" have contents");
}

@Test
Expand Down

0 comments on commit 3f1f222

Please sign in to comment.