@@ -25,25 +25,30 @@ fun Descriptive.DescriptionOption<Descriptive.FinalStep>.withHelpOnFailure(
2525/* *
2626 * Option to create a [DescriptiveAssertion] like assertion with an additional hint
2727 * which is based on the subject of the expectation and
28- * which is only shown the subject is defined.
28+ * which is only shown if the subject is defined (and optionally based on a given [showOnlyIf] predicate) .
2929 *
3030 * You can use [withHelpOnFailureBasedOnSubject] in case you want to:
3131 * - provide a hint also if the subject is absent.
32- * - do not show the hint in certain cases even if the subject is defined
32+ * - show the hint even if the subject is absent.
3333 *
3434 * Or use [withHelpOnFailure] which does not expect an [Expect] in case your [DescriptiveAssertion] is not based
3535 * on the subject of the expectation.
36+ *
37+ * @param expect The [Expect] from which the subject is taken to check if it is defined or not
38+ * @param showOnlyIf A predicate which is passed on to [DescriptiveAssertionWithFailureHint.ShowOption.showBasedOnDefinedSubjectOnlyIf].
39+ * @param failureHintFactory The factory which creates the failure hint as such in the form of an [Assertion].
3640 */
3741// TODO if we introduce Proof or something else as replacement for Assertion then not but if we keep Assertion
3842// then move to logic and expect ProofContainer with 1.2.0
3943fun <T > Descriptive.DescriptionOption<Descriptive.FinalStep>.withHelpOnFailureBasedOnDefinedSubject (
4044 expect : Expect <T >,
45+ showOnlyIf : (T ) -> Boolean = { _ -> true },
4146 failureHintFactory : (T ) -> Assertion
4247): Descriptive .DescriptionOption <DescriptiveAssertionWithFailureHint .FinalStep > {
4348 return withHelpOnFailureBasedOnSubject(expect) {
4449 ifDefined(failureHintFactory)
4550 .ifAbsent(::createShouldNotBeShownToUserWarning)
46- }.showOnlyIfSubjectDefined (expect)
51+ }.showBasedOnDefinedSubjectOnlyIf (expect, showOnlyIf )
4752}
4853
4954/* *
0 commit comments