Class: RSpec::Mocks::DirectObjectReference

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/mocks/object_reference.rb

Overview

Used when an object is passed to `object_double`. Represents a reference to that object.

Direct Known Subclasses

DirectModuleReference

Instance Method Summary (collapse)

Constructor Details

- (DirectObjectReference) initialize(object)



28
29
30
# File 'lib/rspec/mocks/object_reference.rb', line 28

def initialize(object)
  @object = object
end

Instance Method Details

- (Object) const_to_replace

Raises:

  • (ArgumentError)


36
37
38
39
# File 'lib/rspec/mocks/object_reference.rb', line 36

def const_to_replace
  raise ArgumentError,
    "Can not perform constant replacement with an object."
end

- (Boolean) defined?



41
42
43
# File 'lib/rspec/mocks/object_reference.rb', line 41

def defined?
  true
end

- (Object) description



32
33
34
# File 'lib/rspec/mocks/object_reference.rb', line 32

def description
  @object.inspect
end

- (Object) when_loaded {|@object| ... }

Yields:

  • (@object)


45
46
47
# File 'lib/rspec/mocks/object_reference.rb', line 45

def when_loaded
  yield @object
end