module RSpec::Mocks::ExampleMethods

def self.included(klass)

def self.included(klass)
  klass.class_eval do
    # This gets mixed in so that if `RSpec::Matchers` is included in
    # `klass` later, it's definition of `expect` will take precedence.
    include ExpectHost unless method_defined?(:expect)
  end
end

def allow_message_expectations_on_nil

early on.
nil. This is to prevent false-positives and to catch potential bugs
By default warning messages are issued when expectations are set on

Disables warning messages about expectations being set on nil.
def allow_message_expectations_on_nil
  RSpec::Mocks.space.proxy_for(nil).warn_about_expectations = false
end

def declare_double(declared_as, *args)

def declare_double(declared_as, *args)
  args << {} unless Hash === args.last
  args.last[:__declared_as] = declared_as
  RSpec::Mocks::Mock.new(*args)
end

def double(*args)

Other tags:
    See: #stub -
    See: #mock -

Returns:
  • (Mock) -

Parameters:
  • stubs (Hash) -- (optional) hash of method/return-value pairs
  • name (String/Symbol) -- (optional) used in

Overloads:
  • double(name, stubs)
  • double(stubs)
  • double(name)
  • double()
def double(*args)
  declare_double('Double', *args)
end

def have_received(method_name)

Parameters:
  • method_name (Symbol) -- name of the method expected to have been
def have_received(method_name)
  Matchers::HaveReceived.new(method_name)
end

def hide_const(constant_name)

Parameters:
  • constant_name (String) -- The fully qualified name of the constant.
def hide_const(constant_name)
  ConstantMutator.hide(constant_name)
end

def mock(*args)

Deprecated: Use [double](#double-instance_method).
def mock(*args)
  RSpec.deprecate "mock", :replacement => "double"
  declare_double('Mock', *args)
end

def stub(*args)

Deprecated: Use [double](#double-instance_method).
def stub(*args)
  RSpec.deprecate "stub", :replacement => "double"
  declare_double('Stub', *args)
end

def stub_const(constant_name, value, options = {})

Returns:
  • (Object) - the stubbed value of the constant

Options Hash: (**options)
  • :transfer_nested_constants (Boolean, Array) -- Determines

Parameters:
  • options (Hash) -- Stubbing options.
  • value (Object) -- The value to make the constant refer to. When the
  • constant_name (String) -- The fully qualified name of the constant. The current
def stub_const(constant_name, value, options = {})
  ConstantMutator.stub(constant_name, value, options)
end