Skip to content

Commit

Permalink
Rename Mock to Double in class names, etc.
Browse files Browse the repository at this point in the history
We've already removed `mock` as an alias for `double`,
might as well make class names and descriptions consistent.
  • Loading branch information
myronmarston committed Nov 9, 2013
1 parent 86abf8d commit ef4aa3b
Show file tree
Hide file tree
Showing 19 changed files with 844 additions and 854 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -125,7 +125,7 @@ generic kind of object: a Test Double.

### Test-Specific Extension

a.k.a. Partial Stub/Mock, a Test-Specific Extension is an extension of a
a.k.a. Partial Double, a Test-Specific Extension is an extension of a
real object in a system that is instrumented with test-double like
behaviour in the context of a test. This technique is very common in Ruby
because we often see class objects acting as global namespaces for methods.
Expand Down
6 changes: 3 additions & 3 deletions lib/rspec/mocks/example_methods.rb
Expand Up @@ -12,9 +12,9 @@ module ExampleMethods
# @param name [String/Symbol] (optional) used in
# clarify intent
# @param stubs (Hash) (optional) hash of message/return-value pairs
# @return (Mock)
# @return (Double)
#
# Constructs an instance of [RSpec::Mocks::Mock](RSpec::Mocks::Mock) configured
# Constructs an instance of [RSpec::Mocks::Double](RSpec::Mocks::Double) configured
# with an optional name, used for reporting in failure messages, and an optional
# hash of message/return-value pairs.
#
Expand All @@ -28,7 +28,7 @@ module ExampleMethods
# card.rank #=> "A"
#
def double(*args)
ExampleMethods.declare_double(Mock, *args)
ExampleMethods.declare_double(Double, *args)
end

# @overload instance_double(doubled_class)
Expand Down
1 change: 0 additions & 1 deletion lib/rspec/mocks/framework.rb
Expand Up @@ -11,7 +11,6 @@
require 'rspec/mocks/proxy'
require 'rspec/mocks/proxy_for_nil'
require 'rspec/mocks/test_double'
require 'rspec/mocks/mock'
require 'rspec/mocks/argument_list_matcher'
require 'rspec/mocks/message_expectation'
require 'rspec/mocks/order_group'
Expand Down
7 changes: 0 additions & 7 deletions lib/rspec/mocks/mock.rb

This file was deleted.

2 changes: 1 addition & 1 deletion lib/rspec/mocks/proxy.rb
Expand Up @@ -231,7 +231,7 @@ def find_almost_matching_stub(method_name, *args)
end
end

class PartialMockProxy < Proxy
class PartialDoubleProxy < Proxy
def method_handle_for(message)
if any_instance_class_recorder_observing_method?(@object.class, message)
message = ::RSpec::Mocks.
Expand Down
4 changes: 2 additions & 2 deletions lib/rspec/mocks/space.rb
Expand Up @@ -58,9 +58,9 @@ def proxy_for(object)
when TestDouble then object.__build_mock_proxy(expectation_ordering)
else
if RSpec::Mocks.configuration.verify_partial_doubles?
VerifyingPartialMockProxy.new(object, expectation_ordering)
VerifyingPartialDoubleProxy.new(object, expectation_ordering)
else
PartialMockProxy.new(object, expectation_ordering)
PartialDoubleProxy.new(object, expectation_ordering)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/rspec/mocks/stub_chain.rb
Expand Up @@ -19,7 +19,7 @@ def stub_chain
chain.shift
matching_stub.invoke(nil).stub_chain(*chain, &block)
else
next_in_chain = Mock.new
next_in_chain = Double.new
object.stub(chain.shift) { next_in_chain }
StubChain.stub_chain_on(next_in_chain, *chain, &block)
end
Expand Down
10 changes: 8 additions & 2 deletions lib/rspec/mocks/test_double.rb
@@ -1,8 +1,8 @@
module RSpec
module Mocks
# Implements the methods needed for a pure test double. RSpec::Mocks::Mock
# Implements the methods needed for a pure test double. RSpec::Mocks::Double
# includes this module, and it is provided for cases where you want a
# pure test double without subclassing RSpec::Mocks::Mock.
# pure test double without subclassing RSpec::Mocks::Double.
module TestDouble
# Extends the TestDouble module onto the given object and
# initializes it as a test double.
Expand Down Expand Up @@ -105,5 +105,11 @@ def __mock_proxy
::RSpec::Mocks.proxy_for(self)
end
end

# A generic test double object. `double`, `instance_double` and friends
# return an instance of this.
class Double
include TestDouble
end
end
end
1 change: 0 additions & 1 deletion lib/rspec/mocks/verifying_double.rb
@@ -1,4 +1,3 @@
require 'rspec/mocks/mock'
require 'rspec/mocks/verifying_proxy'

module RSpec
Expand Down
2 changes: 1 addition & 1 deletion lib/rspec/mocks/verifying_proxy.rb
Expand Up @@ -70,7 +70,7 @@ def method_reference
end
end

class VerifyingPartialMockProxy < PartialMockProxy
class VerifyingPartialDoubleProxy < PartialDoubleProxy
include VerifyingProxyMethods

def initialize(object, expectation_ordering)
Expand Down
2 changes: 1 addition & 1 deletion spec/rspec/mocks/and_yield_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'

describe RSpec::Mocks::Mock do
describe RSpec::Mocks::Double do

let(:obj) { double }

Expand Down

0 comments on commit ef4aa3b

Please sign in to comment.