Use format.Object() for PanicMatcher failure message
Addresses https://github.com/onsi/gomega/pull/176#issuecomment-255612218
diff --git a/matchers/panic_matcher.go b/matchers/panic_matcher.go
index 1e5d4d8..640f4db 100644
--- a/matchers/panic_matcher.go
+++ b/matchers/panic_matcher.go
@@ -42,5 +42,5 @@
}
func (matcher *PanicMatcher) NegatedFailureMessage(actual interface{}) (message string) {
- return format.Message(actual, fmt.Sprintf("not to panic, but panicked with <%T>: %v", matcher.object, matcher.object))
+ return format.Message(actual, fmt.Sprintf("not to panic, but panicked with\n%s", format.Object(matcher.object, 1)))
}
diff --git a/matchers/panic_matcher_test.go b/matchers/panic_matcher_test.go
index bb58a78..6b859a7 100644
--- a/matchers/panic_matcher_test.go
+++ b/matchers/panic_matcher_test.go
@@ -39,7 +39,7 @@
failuresMessages := InterceptGomegaFailures(func() {
Ω(func() { panic("ack!") }).ShouldNot(Panic())
})
- Ω(failuresMessages).Should(ConsistOf(ContainSubstring("not to panic, but panicked with <string>: ack!")))
+ Ω(failuresMessages).Should(ConsistOf(MatchRegexp("not to panic, but panicked with\\s*<string>: ack!")))
})
})
})