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

stubbee -> stubba_object, mock_owner -> stubbee #463

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/mocha/any_instance_method.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@ module Mocha
class AnyInstanceMethod < StubbedMethod
private

def mock_owner
stubbee.any_instance
def stubbee
stubba_object.any_instance
end

def method_body(method)
method
end

def stubbee_method(method_name)
stubbee.instance_method(method_name)
stubba_object.instance_method(method_name)
end

def original_method_owner
stubbee
stubba_object
end
end
end
8 changes: 4 additions & 4 deletions lib/mocha/instance_method.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ module Mocha
class InstanceMethod < StubbedMethod
private

def mock_owner
stubbee
def stubbee
stubba_object
end

def method_body(method)
PRE_RUBY_V19 ? proc { |*args, &block| method.call(*args, &block) } : method
end

def stubbee_method(method_name)
stubbee._method(method_name)
stubba_object._method(method_name)
end

def original_method_owner
stubbee.singleton_class
stubba_object.singleton_class
end
end
end
14 changes: 7 additions & 7 deletions lib/mocha/stubbed_method.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ module Mocha
class StubbedMethod
PrependedModule = Class.new(Module)

attr_reader :stubbee, :method_name
attr_reader :stubba_object, :method_name

def initialize(stubbee, method_name)
@stubbee = stubbee
def initialize(stubba_object, method_name)
@stubba_object = stubba_object
@original_method = nil
@original_visibility = nil
@method_name = PRE_RUBY_V19 ? method_name.to_s : method_name.to_sym
Expand All @@ -28,11 +28,11 @@ def unstub
end

def mock
mock_owner.mocha
stubbee.mocha
end

def reset_mocha
mock_owner.reset_mocha
stubbee.reset_mocha
end

def hide_original_method
Expand Down Expand Up @@ -81,13 +81,13 @@ def restore_original_method

def matches?(other)
return false unless other.class == self.class
(stubbee.object_id == other.stubbee.object_id) && (method_name == other.method_name)
(stubba_object.object_id == other.stubba_object.object_id) && (method_name == other.method_name)
end

alias_method :==, :eql?

def to_s
"#{stubbee}.#{method_name}"
"#{stubba_object}.#{method_name}"
end

private
Expand Down
2 changes: 1 addition & 1 deletion test/unit/instance_method_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def reset_mocha
self.reset_mocha_called = true
end
end.new
replace_instance_method(method, :stubbee) { stubbee }
replace_instance_method(method, :stubba_object) { stubbee }

method.unstub

Expand Down