Module: Crispy

Defined in:
lib/crispy.rb,
lib/crispy/version.rb,
lib/crispy/crispy_world.rb,
lib/crispy/crispy_internal/spy.rb,
lib/crispy/crispy_internal/double.rb,
lib/crispy/crispy_received_message.rb,
lib/crispy/crispy_internal/spy_base.rb,
lib/crispy/crispy_internal/class_spy.rb,
lib/crispy/crispy_internal/const_changer.rb,
lib/crispy/crispy_received_message_with_receiver.rb

Defined Under Namespace

Modules: CrispyInternal, CrispyWorld Classes: CrispyReceivedMessage, CrispyReceivedMessageWithReceiver

Constant Summary collapse

VERSION =
"0.3.2"

Class Method Summary collapse

Class Method Details

.double(name_or_stubs_map = nil, stubs_map = {}) ⇒ Object



16
17
18
# File 'lib/crispy.rb', line 16

def double name_or_stubs_map = nil, stubs_map = {}
  ::Crispy::CrispyInternal::Double.new name_or_stubs_map, stubs_map
end

.spied?(object) ⇒ Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/crispy.rb', line 38

def spied? object
  defined? object.__CRISPY_SPY__
end

.spied_instances?(klass) ⇒ Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/crispy.rb', line 42

def spied_instances? klass
  !!::Crispy::CrispyInternal::ClassSpy.of_target(klass)
end

.spy(object) ⇒ Object



25
26
27
# File 'lib/crispy.rb', line 25

def spy object
  object.__CRISPY_SPY__
end

.spy_into(object, stubs_map = {}) ⇒ Object

Returns a Spy object to wrap all methods of the object.



12
13
14
# File 'lib/crispy.rb', line 12

def spy_into object, stubs_map = {}
  ::Crispy::CrispyInternal::Spy.new object, stubs_map
end

.spy_into_instances(klass, stubs_map = {}) ⇒ Object

Make and returns a Crispy::ClassSpy’s instance to spy all instances of a class.



21
22
23
# File 'lib/crispy.rb', line 21

def spy_into_instances klass, stubs_map = {}
  ::Crispy::CrispyInternal::ClassSpy.new klass, stubs_map
end

.spy_of_instances(klass) ⇒ Object



29
30
31
# File 'lib/crispy.rb', line 29

def spy_of_instances klass
  ::Crispy::CrispyInternal::ClassSpy.of_target(klass)
end

.stub_const(full_const_name, value) ⇒ Object



33
34
35
36
# File 'lib/crispy.rb', line 33

def stub_const full_const_name, value
  saved_value = ::Crispy::CrispyInternal::ConstChanger.change_by_full_name full_const_name, value
  ::Crispy::CrispyInternal::ConstChanger.save full_const_name, saved_value
end