StringEqualsMatcher adds to mismatchDescription instead of replace mismatchDescription (#55)
diff --git a/lib/src/core_matchers.dart b/lib/src/core_matchers.dart
index 12274cf..b513d5e 100644
--- a/lib/src/core_matchers.dart
+++ b/lib/src/core_matchers.dart
@@ -329,7 +329,7 @@
buff.write('^\n Differ at offset $start');
}
- return mismatchDescription.replace(buff.toString());
+ return mismatchDescription.add(buff.toString());
}
}
diff --git a/test/string_matchers_test.dart b/test/string_matchers_test.dart
index 5b5afe4..28d085c 100644
--- a/test/string_matchers_test.dart
+++ b/test/string_matchers_test.dart
@@ -13,6 +13,16 @@
contains('Differ at offset 7'));
});
+ test("Retains outer matcher mismatch text", () {
+ shouldFail(
+ {'word': 'thing'},
+ containsPair('word', equals('notthing')),
+ allOf([
+ contains("contains key 'word' but with value is different"),
+ contains("Differ at offset 0")
+ ]));
+ });
+
test('collapseWhitespace', () {
var source = '\t\r\n hello\t\r\n world\r\t \n';
expect(collapseWhitespace(source), 'hello world');