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

Define respond_to_missing? on Mocha::Mock #323

Merged
merged 1 commit into from
Mar 20, 2018

Commits on Feb 13, 2018

  1. Define respond_to_missing? on Mocha::Mock

    Fixes freerange#321.
    
    As of Ruby 2.4, Forwardable warns when delegating to a private method.
    Warnings are shown when delegating methods to a Mocha::Mock.
    
    To determine whether to show a warning, Forwardable tests the delegated
    method with the defined? operator. Mocha uses method_missing to respond
    to mocked methods. defined? uses respond_to_missing? to determine
    whether or not a missing method is defined. Defining respond_to_missing?
    on Mocha::Mock, in place of respond_to?, prevents warnings from being
    shown.
    
    To preserve compatibility with Ruby 1.8.7, we continue to conditionally
    define respond_to?. Prior to Ruby 1.9.3, defined? returns nil for method
    calls handled via method_missing, so we also only test that mocked
    methods are defined? in later Ruby versions.
    tjvc committed Feb 13, 2018
    Configuration menu
    Copy the full SHA
    befb416 View commit details
    Browse the repository at this point in the history