Sha256: 26a1a4906fd1012702a227726f201eac4024723cee88cbfbbb84f6fb0b0f6527
Contents?: true
Size: 1.52 KB
Versions: 1
Compression:
Stored size: 1.52 KB
Contents
require 'debug/session' module RSpec module Debugging module DebugIt ENABLED = ['1', 'true'].include?(ENV['RSPEC_DEBUGGING']) def initialize(example_group_class, description, user_metadata, example_block=nil) return super unless user_metadata[:debug] || ENABLED if example_block orig_example_block = example_block example_block = Proc.new do e = DEBUGGER__::SESSION.capture_exception_frames /(exe|bin|lib)\/rspec/ do instance_exec(&orig_example_block) end if e STDERR.puts <<~MSG Error: #{e.message} MSG DEBUGGER__::SESSION.enter_postmortem_session e raise e end end # Proc.new elsif user_metadata[:debug] && user_metadata[:skip] == RSpec::Core::Pending::NOT_YET_IMPLEMENTED # called with no block user_metadata.delete(:skip) file, line = caller[2].split(":") example_block = Proc.new do STDERR.puts <<~MSG debugging: #{file}:#{line} MSG debugger end end super end end end end RSpec::Core::Example.prepend RSpec::Debugging::DebugIt RSpec::Core::ExampleGroup.define_example_method(:dit, debug: true, focus: true) RSpec::Core::ExampleGroup.define_example_group_method(:ddescribe, debug: true, focus: true) RSpec::Core::ExampleGroup.define_example_group_method(:dcontext, debug: true, focus: true)
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rspec-debugging-0.0.2 | lib/rspec/debugging/debug_it.rb |