module PowerAssert

Constants

IGNORED_LIB_DIRS
POWER_ASSERT_LIB_DIR
SUPPORT_ALIAS_METHOD
VERSION

Public Class Methods

app_caller_locations() click to toggle source
# File lib/power_assert.rb, line 48
def app_caller_locations
  caller_locations.drop_while {|i| ignored_file?(i.path) }.take_while {|i| ! ignored_file?(i.path) }
end
app_context?() click to toggle source
# File lib/power_assert.rb, line 52
def app_context?
  top_frame = caller_locations.drop_while {|i| i.path.start_with?(POWER_ASSERT_LIB_DIR) }.first
  top_frame && ! ignored_file?(top_frame.path)
end
configuration() click to toggle source
# File lib/power_assert/configuration.rb, line 3
def configuration
  @configuration ||= Configuration[false, false, true, false, false]
end
configure() { |configuration| ... } click to toggle source
# File lib/power_assert/configuration.rb, line 7
def configure
  yield configuration
end
start(assertion_proc_or_source, assertion_method: nil, source_binding: TOPLEVEL_BINDING) { |block_context| ... } click to toggle source
# File lib/power_assert.rb, line 30
def start(assertion_proc_or_source, assertion_method: nil, source_binding: TOPLEVEL_BINDING)
  if respond_to?(:clear_global_method_cache, true)
    clear_global_method_cache
  end
  yield BlockContext.new(assertion_proc_or_source, assertion_method, source_binding)
end
trace(frame) click to toggle source
# File lib/power_assert.rb, line 37
def trace(frame)
  begin
    raise 'Byebug is not started yet' unless Byebug.started?
  rescue NameError
    raise "PowerAssert.#{__method__} requires Byebug"
  end
  ctx = TraceContext.new(frame._binding)
  ctx.enable
  ctx
end

Private Class Methods

clear_global_method_cache() click to toggle source
# File lib/power_assert.rb, line 72
def clear_global_method_cache
  eval('using PowerAssert.const_get(:Empty)', TOPLEVEL_BINDING)
end
ignored_file?(file) click to toggle source
# File lib/power_assert.rb, line 59
def ignored_file?(file)
  IGNORED_LIB_DIRS[Byebug]    = lib_dir(Byebug, :attach, 2)             if defined?(Byebug) and ! IGNORED_LIB_DIRS[Byebug]
  IGNORED_LIB_DIRS[PryByebug] = lib_dir(Pry, :start_with_pry_byebug, 2) if defined?(PryByebug) and ! IGNORED_LIB_DIRS[PryByebug]
  IGNORED_LIB_DIRS.find do |_, dir|
    file.start_with?(dir)
  end
end
lib_dir(obj, mid, depth) click to toggle source
# File lib/power_assert.rb, line 67
def lib_dir(obj, mid, depth)
  File.expand_path('../' * depth, obj.method(mid).source_location[0])
end

Public Instance Methods

!() click to toggle source
# File lib/power_assert/enable_tracepoint_events.rb, line 70
def !
end
==() click to toggle source
# File lib/power_assert/enable_tracepoint_events.rb, line 63
def ==
end
fixed?() click to toggle source
# File lib/power_assert/enable_tracepoint_events.rb, line 32
def fixed?
end