Add support for custom failure messages in Spec expectations #10127
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces a breaking change if people happened to be using file and line as positional parameters, which is why I'd like to get this in before 1.0. The reason I introduced this breaking change is because as a user I'd expect the failure message to come immediately after the expectation (as it is in RSpec), and I believe it will be much more likely for users to use custom error messages than file and line (based on my experience in Ruby with RSpec).
The fix for the file and line change is very straightforward. In this PR I've fixed the core specs by using keyword notation, since core had both keyword-style and positional-style, and keyword-style seemed cleaner. I had even considered "forcing" keywords to be used for the file and line parameters, but thought that might warrant some discussion first.
See also the brief discussion in this thread: https://forum.crystal-lang.org/t/spec-assertion-with-custom-message/1781