-
-
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
Add docs to expectations methods #5092
Add docs to expectations methods #5092
Conversation
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.
In general there doesn't seem to be much documentation on what an Expectation
is and how to use it (should
)
src/spec/expectations.cr
Outdated
def be_close(expected, delta) | ||
Spec::CloseExpectation.new(expected, delta) | ||
end | ||
|
||
# Returns a factory to create a comparison `Expectation` that: | ||
# | ||
# * passes if actual is lesser than *value*: `be.<(value)` |
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.
Perhaps using the longer be < value
is clearer here?
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.
Yes. For some reason I assumed the .
was require (dunno why, something failed when I was experimenting with it).
src/spec/expectations.cr
Outdated
macro be_a(type) | ||
Spec::BeAExpectation({{type}}).new | ||
end | ||
|
||
# Creates an `Expectation` that passes if the block raises an exception. |
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.
These expect_*
macros don't create an expectation, they raise themselves.
src/spec/expectations.cr
Outdated
macro be_a(type) | ||
Spec::BeAExpectation({{type}}).new | ||
end | ||
|
||
# Runs the block and passes if it raises an exception. |
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.
Worth noting about this method is that this variant that doesn't verify it against an actual exception type has been deprecated in rspec. From the places where I fixed the deprecation errors for that, I can say that the reason for the deprecation was very motivated, as there was lots of hidden errors and unexpected exceptions being accepted when they really shouldn't have.
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.
Good point! I'll add a note about this and suggest removing the matcher in a separate issue.
@RX14 Yes, there is still a lot missing. I'll try to condense some of the testing guide to a API doc for |
@straight-shoota just "Expectations are used by |
@RX14 The module |
3fb6bb0
to
a33223f
Compare
Needs a rebase. |
Ready to merge! 💯 |
src/spec.cr
Outdated
@@ -1,13 +1,16 @@ | |||
require "./spec/dsl" | |||
|
|||
# Crystal's built-in testing library. | |||
# Crystal's built-in testing library. It provides the structure for writing executable examples |
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.
"a structure"
src/spec.cr
Outdated
@@ -1,13 +1,16 @@ | |||
require "./spec/dsl" | |||
|
|||
# Crystal's built-in testing library. | |||
# Crystal's built-in testing library. It provides the structure for writing executable examples | |||
# of how your code should behave. A domain specific language allows to write them similar to natural language. |
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.
"allows you to write them in a way similar to natural language"
09af8f2
to
12490ab
Compare
Ready to 🎲 ! |
No description provided.