-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Spec: restrict the type returned by should_not be_nil
and others
#8412
Conversation
a017286
to
25c7247
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is technically missing should be_nil
. I assume that's on purpose because it's hard to think of a use case for this?
src/spec/expectations.cr
Outdated
@@ -417,6 +417,26 @@ module Spec | |||
end | |||
|
|||
module ObjectExtensions | |||
# Validates an expectation and fails the example if it does not match. | |||
# | |||
# This overload will be called when doing: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd avoid placing an example block inside a sentence.
# This overload will be called when doing: | |
# This overload accepts a `be_a(Type)` expectation and makes sure, at compile-time, that the returned object is of type `Type`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason for not mentioning the be_a
method here? It would make the documentation more accessible for readers familiar with the DSL.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, what do you mean? I changed the code example and be_a
is used there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant mentioning it in the text.
But yeah, having it in the sample is probably fine.
Right, the resulting type will always be |
2cc5802
to
945d4bf
Compare
Fixed once more. Let me know if this is good now. |
Co-Authored-By: Johannes Müller <[email protected]>
Co-Authored-By: Johannes Müller <[email protected]>
Fixes #8369
Follow up to #8240