-
-
Notifications
You must be signed in to change notification settings - Fork 766
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
doc_string which is the first argument of example, must be string object #3072
Comments
@JonRowe do you agree with the expected behaviour section here?
It confuses me when the first argument is not a string and we accept it as metadata. To me, the “must” in the “must be a string object” means we raise an argument error when it’s not. In my defense, I can foresee misuse and workarounds like I find it hard to justify the I’d love to see more examples of what we are going to break if we go with a more strict approach. It’s more of a gut feeling, but going with accepting the first argument as metadata where it previously wasn’t, makes me uncomfortable when thinking of side effects that might be introduced by such metadata. |
@pirj What happens to this issue may depend on Mr. @JonRowe 's reply. |
Sounds good, and no worries. Thanks for your contributions! |
doc_string which is the first argument of example, must be string object
RSpec example recognize the first argument as the description.
But when even symbol or hash object which set intended as metadata is given in the first argument, it is recognized as the description and metadata does not work.
I want to add some change to keep doc_string a string object.
Your environment
Steps to reproduce
prepare rspec test below
Actual behavior
metadata is recognized as description and pending does not work, failing two examples
Expected behavior
To prevent metadata as first argument which does not work properly, it raises ArgumentError like below when execute each example above whose first argument is not nil or string object.
Note
First, I created PR #3074 not to set doc_string when first argument is metadata.
But I think that keeping the first argument of example doc_string is much more appropriate.
(In the first place, as commented here it's the specification.)
Related Pull Request
I proposed this new specification in the PR below,
After the discussion, we decided to add this in upcoming 4.x and add warning in 3.99
#3071
What to do
The text was updated successfully, but these errors were encountered: