Only call value method if it has zero arity#496
Open
sikachu wants to merge 1 commit intozipmark:masterfrom
Open
Only call value method if it has zero arity#496sikachu wants to merge 1 commit intozipmark:masterfrom
sikachu wants to merge 1 commit intozipmark:masterfrom
Conversation
|
@davidstosik @jakehow It looks good. Can it will be merged and released? |
|
This fix was great! We needed it asap so we had to fork this and add it manually for the time being to regenerate docs quickly. If anyone else is using this in your application remember to add |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 fixes a compatibility problem with Rails when the user specifies
parameterwith the same name asActionDispatch::Integration::RequestHelpersmethods.This came up in our application because we are accepting a parameter name
options, and when upgrading to Rails 6.1 we starting to get this error:After some investigation, it seems like Rails 6.1 has added
optionsmethod toActionDispatch::Integration::RequestHelperswhich get included to Request specs:https://github.com/rails/rails/blob/v6.1.1/actionpack/lib/action_dispatch/testing/integration.rb#L49-L53
Therefore when rspec_api_documentation tries to call
optionsmethod to get the value, it accidentally calling this helper method from Rails instead and resulting inArgumentError.Since it's a bit tricky to detect where the method was defined, I propose a solution in this PR in which we just check if the value method has an arity of zero (i.e. doesn't take any argument) before calling it. This way,
rspec_api_documentationwill still automatically call a value method if it's defined or overridden by the user.