Skip to content
This repository has been archived by the owner on Nov 30, 2024. It is now read-only.

Commit

Permalink
Merge pull request #403 from rspec/use-method-handle-for-from-support
Browse files Browse the repository at this point in the history
Use `method_handle_for` from rspec-support.
  • Loading branch information
myronmarston committed Jan 1, 2014
2 parents 3425ab3 + ec38a55 commit bc292d8
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 79 deletions.
26 changes: 0 additions & 26 deletions lib/rspec/expectations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,31 +57,5 @@ module Expectations
else
Class.new(::StandardError)
end

# @api private
KERNEL_METHOD_METHOD = ::Kernel.instance_method(:method)

# @api private
#
# Used internally to get a method handle for a particular object
# and method name.
#
# Includes handling for a few special cases:
#
# - Objects that redefine #method (e.g. an HTTPRequest struct)
# - BasicObject subclasses that mixin a Kernel dup (e.g. SimpleDelegator)
if RUBY_VERSION.to_i >= 2
def self.method_handle_for(object, method_name)
KERNEL_METHOD_METHOD.bind(object).call(method_name)
end
else
def self.method_handle_for(object, method_name)
if ::Kernel === object
KERNEL_METHOD_METHOD.bind(object).call(method_name)
else
object.method(method_name)
end
end
end
end
end
4 changes: 3 additions & 1 deletion lib/rspec/matchers/built_in/operators.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require 'rspec/support'

module RSpec
module Matchers
module BuiltIn
Expand Down Expand Up @@ -66,7 +68,7 @@ def description
private

def uses_generic_implementation_of?(op)
Expectations.method_handle_for(@actual, op).owner == ::Kernel
Support.method_handle_for(@actual, op).owner == ::Kernel
rescue NameError
false
end
Expand Down
52 changes: 0 additions & 52 deletions spec/rspec/expectations_spec.rb

This file was deleted.

0 comments on commit bc292d8

Please sign in to comment.