module Crispy

Constants

VERSION

Public Instance Methods

double(name_or_stubs_map = nil, stubs_map = {}) click to toggle source
# 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) click to toggle source
# File lib/crispy.rb, line 42
def spied? object
  defined? object.__CRISPY_SPY__
end
spied_instances?(klass) click to toggle source
# File lib/crispy.rb, line 46
def spied_instances? klass
  !!::Crispy::CrispyInternal::ClassSpy.of_target(klass)
end
spy(object) click to toggle source
# File lib/crispy.rb, line 25
def spy object
  object.__CRISPY_SPY__
rescue ::NoMethodError
  object_string = object.inspect rescue 'object' # BasicObject can't inspect!
  raise ::Crispy::CrispyError, "#{object_string} is not spied!"
end
spy_into(object, except: []) click to toggle source

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

# File lib/crispy.rb, line 12
def spy_into object, except: []
  ::Crispy::CrispyInternal::Spy.new object, except: except
end
spy_into_instances(klass, except: []) click to toggle source

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

# File lib/crispy.rb, line 21
def spy_into_instances klass, except: []
  ::Crispy::CrispyInternal::ClassSpy.new klass, except: except
end
spy_of_instances(klass) click to toggle source
# File lib/crispy.rb, line 32
def spy_of_instances klass
  ::Crispy::CrispyInternal::ClassSpy.of_target(klass) \
    || raise(::Crispy::CrispyError, "#{klass} does not have its instances spied!")
end
stub_const(full_const_name, value) click to toggle source
# File lib/crispy.rb, line 37
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