Skip to content
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

Remove ModuleMethod#method_exists? #295

Merged
merged 1 commit into from Apr 20, 2018
Merged

Conversation

chrisroos
Copy link
Member

@chrisroos chrisroos commented Jan 28, 2017

This is similar to the change in this commit.

This commit made ModuleMethod#method_exists? redundant by changing the implementation of ClassMethod#hide_original_method so that it uses ClassMethod#method_visibility instead.

This introduced a subtle change in behaviour due to the difference in ModuleMethod#method_exists? and ClassMethod#method_visibility. The former would return false if the method being stubbed was on Kernel or Object while the latter will return true in those cases. This gist
illustrates the difference.

Practically, this meant that some stubbed module methods (those defined on Kernel and Object) wouldn't have had the correct visibility set. The tests added in this commit ensure we don't introduce
regressions in future. The tests for the visibility of the protected and private methods failed prior to this commit. I confirmed this by checking our the commit before that (git co e87c03b068efc48267fbcd5a295514077c52b901~) and running these new tests.

@chrisroos
Copy link
Member Author

I'm fairly confident this can just be merged but I don't have time to look at it right now so I'm opening this PR as a reminder that I need to do something with it.

@floehopper
Copy link
Member

@chrisroos:

This looks good to me. I'm going to remove the wem.md and wem.rb files from the commit, rebase this against master and force-push in preparation for merging. Let me know if you think we need to check anything else before merging or releasing this change.

@chrisroos
Copy link
Member Author

chrisroos commented Apr 20, 2018

Travis reported a failing test. I suspect it was an intermittent failure so I've requested the build to be restarted.

@chrisroos
Copy link
Member Author

This looks good to me. I'm going to remove the wem.md and wem.rb files from the commit, rebase this against master and force-push in preparation for merging. Let me know if you think we need to check anything else before merging or releasing this change.

@floehopper. I've had a look at this change and am fairly confident it's safe to merge if/when the Travis build passes. I'll rebase it again and get it merged.

This is similar to the change in commit
8f58edd.

Commit e87c03b made
`ModuleMethod#method_exists?` redundant by changing the implementation
of `ClassMethod#hide_original_method` so that it uses
`ClassMethod#method_visibility` instead.

This introduced a subtle change in behaviour due to the difference in
`ModuleMethod#method_exists?` and `ClassMethod#method_visibility`. The
former would return false if the method being stubbed was on `Kernel` or
`Object` while the latter will return true in those cases. This gist
illustrates the difference -
https://gist.github.com/chrisroos/12a1b032b95664448c9e987132f33988.

Practically, this meant that _some_ stubbed module methods (those
defined on Kernel and Object) wouldn't have had the correct visibility
set. The tests added in this commit ensure we don't introduce
regressions in future. The tests for the visibility of the protected and
private methods failed prior to commit
e87c03b. I confirmed this by checking
our the commit before that (`git co
e87c03b~`) and running these new tests.
@floehopper
Copy link
Member

@chrisroos Sounds good. Please go ahead and merge it.

@chrisroos chrisroos merged commit 82c9e56 into master Apr 20, 2018
@chrisroos chrisroos deleted the remove-module-method-exists branch April 20, 2018 13:49
@floehopper
Copy link
Member

Released in v1.6.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants