8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/rspec/debugging/debug_it.rb', line 8
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 elsif user_metadata[:debug] && user_metadata[:skip] == RSpec::Core::Pending::NOT_YET_IMPLEMENTED
user_metadata.delete(:skip)
location = RSpec::Core::Metadata.relative_path(caller[2].split(":in").first)
example_block = Proc.new do
$stderr.puts <<~MSG
debugging: #{location}
MSG
debugger
end.tap do |block|
block.define_singleton_method(:source_location) { location.split(":") }
end
end
super
end
|