123456789_123456789_123456789_123456789_123456789_

Module: PowerAssert

Constant Summary

Class Attribute Summary

Class Method Summary

Class Attribute Details

.app_context?Boolean (readonly)

[ GitHub ]

  
# File 'lib/power_assert.rb', line 39

def app_context?
  top_frame = caller_locations.drop_while {|i| i.path.start_with?(POWER_ASSERT_LIB_DIR) }.first
  top_frame and ! internal_file?(top_frame.path)
end

Class Method Details

.app_caller_locations

[ GitHub ]

  
# File 'lib/power_assert.rb', line 35

def app_caller_locations
  caller_locations.drop_while {|i| internal_file?(i.path) }.take_while {|i| ! internal_file?(i.path) }
end

.clear_global_method_cache (private)

[ GitHub ]

  
# File 'lib/power_assert.rb', line 55

def clear_global_method_cache
  CLEAR_CACHE_ISEQ.eval
end

.configuration

[ GitHub ]

  
# File 'lib/power_assert/configuration.rb', line 3

def configuration
  @configuration ||= Configuration[false, true, false, :p]
end

.configure {|configuration| ... }

Yields:

[ GitHub ]

  
# File 'lib/power_assert/configuration.rb', line 7

def configure
  yield configuration
end

.internal_file?(file) ⇒ Boolean (private)

[ GitHub ]

  
# File 'lib/power_assert.rb', line 46

def internal_file?(file)
  INTERNAL_LIB_DIRS.find do |_, dir|
    file.start_with?(dir)
  end
end

.start(assertion_proc_or_source, assertion_method: nil, source_binding: TOPLEVEL_BINDING) {|Context.new(assertion_proc_or_source, assertion_method, source_binding)| ... }

Yields:

  • (Context.new(assertion_proc_or_source, assertion_method, source_binding))
[ GitHub ]

  
# File 'lib/power_assert.rb', line 30

def start(assertion_proc_or_source, assertion_method: nil, source_binding: TOPLEVEL_BINDING)
  clear_global_method_cache
  yield Context.new(assertion_proc_or_source, assertion_method, source_binding)
end