Class: RSpec::Mocks::NamedObjectReference

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

Overview

Used when a string is passed to `class_double`, `instance_double` or `object_double`. Represents a reference to the object named (via a constant lookup) by the string.

Instance Method Summary (collapse)

Constructor Details

- (NamedObjectReference) initialize(const_name)



68
69
70
# File 'lib/rspec/mocks/object_reference.rb', line 68

def initialize(const_name)
  @const_name = const_name
end

Instance Method Details

- (Object) const_to_replace Also known as: description



76
77
78
# File 'lib/rspec/mocks/object_reference.rb', line 76

def const_to_replace
  @const_name
end

- (Boolean) defined?



72
73
74
# File 'lib/rspec/mocks/object_reference.rb', line 72

def defined?
  !!object
end

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

Yields:

  • (object)


81
82
83
# File 'lib/rspec/mocks/object_reference.rb', line 81

def when_loaded(&block)
  yield object if object
end