Class: Crispy::CrispyInternal::ClassSpy
- Inherits:
-
SpyBase
- Object
- Module
- SpyBase
- Crispy::CrispyInternal::ClassSpy
show all
- Defined in:
- lib/crispy/crispy_internal/class_spy.rb
Constant Summary
Constants inherited
from SpyBase
SpyBase::BLACK_LISTED_METHODS, SpyBase::COMMON_RECEIVED_MESSAGE_METHODS_DEFINITION
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from SpyBase
#append_received_message_when_spying, #assert_symbol!, new, #reinitialize, #reinitialize_stubber, #restart, #stop, #stub
Constructor Details
#initialize(klass, stubs_map = {}) ⇒ ClassSpy
Returns a new instance of ClassSpy.
10
11
12
13
14
15
16
|
# File 'lib/crispy/crispy_internal/class_spy.rb', line 10
def initialize klass, stubs_map = {}
@received_messages_with_receiver = []
super
self.class.register spy: self, of_class: klass
end
|
Class Method Details
.of_target(klass) ⇒ Object
18
19
20
|
# File 'lib/crispy/crispy_internal/class_spy.rb', line 18
def self.of_target klass
@registry[klass]
end
|
.register(spy: nil, of_class: nil) ⇒ Object
69
70
71
|
# File 'lib/crispy/crispy_internal/class_spy.rb', line 69
def self.register(spy: nil, of_class: nil)
@registry[of_class] = spy
end
|
.reset_all ⇒ Object
73
74
75
|
# File 'lib/crispy/crispy_internal/class_spy.rb', line 73
def self.reset_all
@registry.each_value {|spy| spy.reinitialize }
end
|
Instance Method Details
#erase_log ⇒ Object
59
60
61
|
# File 'lib/crispy/crispy_internal/class_spy.rb', line 59
def erase_log
@received_messages_with_receiver.clear
end
|
#received_messages ⇒ Object
26
27
28
|
# File 'lib/crispy/crispy_internal/class_spy.rb', line 26
def received_messages
@received_messages_with_receiver.map {|m| m.received_message }
end
|
#received_messages_with_receiver ⇒ Object
30
31
32
33
34
|
# File 'lib/crispy/crispy_internal/class_spy.rb', line 30
def received_messages_with_receiver
self.stop
@received_messages_with_receiver
end
|
#target_to_class(target_class) ⇒ Object
22
23
24
|
# File 'lib/crispy/crispy_internal/class_spy.rb', line 22
def target_to_class target_class
target_class
end
|