class Crispy::CrispyInternal::ClassSpy
Public Class Methods
new(klass, except: [])
click to toggle source
Calls superclass method
# File lib/crispy/crispy_internal/class_spy.rb, line 10 def initialize klass, except: [] @received_messages_with_receiver = [] super self.class.register spy: self, of_class: klass end
of_target(klass)
click to toggle source
# File lib/crispy/crispy_internal/class_spy.rb, line 18 def self.of_target klass @registry[klass] end
register(spy: nil, of_class: nil)
click to toggle source
# 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()
click to toggle source
# File lib/crispy/crispy_internal/class_spy.rb, line 73 def self.reset_all @registry.each_value {|spy| spy.reinitialize } end
Public Instance Methods
erase_log()
click to toggle source
# File lib/crispy/crispy_internal/class_spy.rb, line 59 def erase_log @received_messages_with_receiver.clear end
received_messages()
click to toggle source
# 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()
click to toggle source
# File lib/crispy/crispy_internal/class_spy.rb, line 30 def received_messages_with_receiver # stop spying in advance to prevent from unexpectedly spying receiver's methods in test code. self.stop @received_messages_with_receiver end
target_to_class(target_class)
click to toggle source
# File lib/crispy/crispy_internal/class_spy.rb, line 22 def target_to_class target_class target_class end
Private Instance Methods
append_received_message(receiver, method_name, *arguments, &attached_block)
click to toggle source
# File lib/crispy/crispy_internal/class_spy.rb, line 63 def append_received_message receiver, method_name, *arguments, &attached_block @received_messages_with_receiver << ::Crispy::CrispyReceivedMessageWithReceiver.new(receiver, method_name, *arguments, &attached_block) end