-
-
Notifications
You must be signed in to change notification settings - Fork 91
Feature rspec failed with reason #281
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
base: master
Are you sure you want to change the base?
Conversation
8ab2319 to
9aa3c43
Compare
palkan
left a comment
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.
Thanks!
Left some suggestions in the comments.
ced2396 to
16992cd
Compare
1670161 to
787e137
Compare
0db0722 to
e9d5724
Compare
9aa3c43 to
da6daa6
Compare
|
|
||
| failed "when user is not an admin", reason: {user: [{not_admin?: {username: "admin"}}]} | ||
|
|
||
| failed "when user is not an admin", reason: a_hash_including(user: anything) |
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.
Failure/Error: failed "when user is not an admin", reason: a_hash_including(user: anything)
`anything` is not available on an example group (e.g. a `describe` or `context` block). It is only available from within individual examples (e.g. `it` blocks) or from constructs that run in the scope of an example (e.g. `before`, `let`, etc).
Oh, I see. That's the problem with this kind of DSL and a good indicator that we should find a better API.
@inkstak What about smth like that:
failed "when user is not an admin" do
# it could be an alias for `let(:failure_reason)` and we can define the default (`nil`) in the shared example
failure_reason { a_hash_including(user: anything) }
endWDYT?
P.S. The more I work with this DSL today, the more I think if we should deprecate it 🤔. It looks cool and fancy for simple use cases but not for complex policies and requirements.
What is the purpose of this pull request?
As suggested in this discussion #271, it allows to match reasons when using RSpec DSL
PR checklist: