Parent

Included Modules

Files

RSpec::Mocks::Mock

Public Class Methods

new(name=nil, stubs_and_options={}) click to toggle source

Creates a new test double with a `name` (that will be used in error messages only)

# File lib/rspec/mocks/mock.rb, line 8
def initialize(name=nil, stubs_and_options={})
  if name.is_a?(Hash) && stubs_and_options.empty?
    stubs_and_options = name
    @name = nil
  else
    @name = name
  end
  @options = extract_options(stubs_and_options)
  assign_stubs(stubs_and_options)
end

Public Instance Methods

==(other) click to toggle source

This allows for comparing the mock to other objects that proxy such as ActiveRecords belongs_to proxy objects. By making the other object run the comparison, we're sure the call gets delegated to the proxy target.

# File lib/rspec/mocks/mock.rb, line 23
def ==(other)
  other == __mock_proxy
end
inspect() click to toggle source

@private

# File lib/rspec/mocks/mock.rb, line 28
def inspect
  "#<#{self.class}:#{sprintf '0x%x', self.object_id} @name=#{@name.inspect}>"
end
respond_to?(sym, incl_private=false) click to toggle source

@private

# File lib/rspec/mocks/mock.rb, line 40
def respond_to?(sym, incl_private=false)
  __mock_proxy.null_object? && sym != :to_ary ? true : super
end
to_s() click to toggle source

@private

# File lib/rspec/mocks/mock.rb, line 33
def to_s
  inspect.gsub('<','[').gsub('>',']')
end
Also aliased as: to_str
to_str() click to toggle source
Alias for: to_s

[Validate]

Generated with the Darkfish Rdoc Generator 2.