-
Notifications
You must be signed in to change notification settings - Fork 82
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
Make KeywordArgs fail if unexpected keys are passed in #187
Make KeywordArgs fail if unexpected keys are passed in #187
Conversation
Hmm weird, specs passed with 2.2 on my machine. I'll look into the failures. |
Ah |
61f67c9
to
31e2066
Compare
Looks like you actually want to fix this spec. Because it tries to pass in unexpected argument and expects it to not fail. Seems like a buggy behavior to me. |
Okay I think I fixed it - let me know if I violated the intent of the spec or whatnot |
options.all? do |key, contract| | ||
Optional._valid?(hash, key, contract) | ||
end | ||
(hash.keys - options.keys == []) && |
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.
Can you use guard statement here instead - current code makes it hard to read. Example:
def valid?(hash)
return false unless hash.keys - options.keys == [] # <--- this is a guard statement
# .. do the main job here ..
end
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.
Oh yeah for sure, should've asked about that
Other than that, looks good. |
31e2066
to
1960743
Compare
@abevoelker Thanks! |
Make KeywordArgs fail if unexpected keys are passed in
Wasn't sure where to put the KeywordArgs specs - let me know if it should go in spec/contracts_spec.rb or whatnot (or if I'm otherwise way off base)