Quick / Nimble

A Matcher Framework for Swift and Objective-C
https://quick.github.io/Nimble/documentation/nimble/
Apache License 2.0
4.81k stars 601 forks source link

Suggestion: Allow passing description to unwrap requirements #1160

Closed noamfreeman closed 1 month ago

noamfreeman commented 2 months ago

Suggestion

When useing require(optionalSubject).toNot(beNil()), i could always add a custom description: require(optionalSubject).toNot(beNil(), description: "repository missing value for \(key)")

this ability is lost when using the unwrap shortcut, which doesn't take a description parameter.

will it be possible to add a description argument and just pass it to the underlying toNot?

while this isn't very usefull in unwrap calls directly in tests, it's very important in helper functions doing many complex assertions, where there is a need to simply explain the error to the caller. in these helpers, i find myself using require().toNot(beNil())

possible problems

while any expectation/requirement using to( or toNot( can pass both a custom error and a description, making the custom error override the description, here both will be in the same functions, since unwrap already takes a optional custom error. this may be confusing, arguably more/less then the expect(cutromError:).to(..., description:)

younata commented 1 month ago

This'll be released in the next version of Nimble, whenever I get around to fixing https://github.com/Quick/Nimble/issues/1157.

younata commented 1 month ago

This is now available in Nimble 13.6.0