2018-03-04 10:09:32 -05:00
|
|
|
require_relative '../../spec_helper'
|
2020-05-31 12:22:49 -04:00
|
|
|
require_relative 'fixtures/classes'
|
2017-12-01 10:41:50 -05:00
|
|
|
|
|
|
|
describe 'TracePoint#path' do
|
|
|
|
it 'returns the path of the file being run' do
|
|
|
|
path = nil
|
2020-05-31 12:22:49 -04:00
|
|
|
TracePoint.new(:line) { |tp|
|
|
|
|
next unless TracePointSpec.target_thread?
|
|
|
|
path = tp.path
|
|
|
|
}.enable do
|
|
|
|
line_event = true
|
2017-12-01 10:41:50 -05:00
|
|
|
end
|
2020-05-31 12:22:49 -04:00
|
|
|
path.should == "#{__FILE__}"
|
2017-12-01 10:41:50 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'equals (eval) inside an eval for :end event' do
|
|
|
|
path = nil
|
2020-05-31 12:22:49 -04:00
|
|
|
TracePoint.new(:end) { |tp|
|
|
|
|
next unless TracePointSpec.target_thread?
|
|
|
|
path = tp.path
|
|
|
|
}.enable do
|
2019-02-21 10:38:59 -05:00
|
|
|
eval("module TracePointSpec; end")
|
2017-12-01 10:41:50 -05:00
|
|
|
end
|
2020-05-31 12:22:49 -04:00
|
|
|
path.should == '(eval)'
|
2017-12-01 10:41:50 -05:00
|
|
|
end
|
|
|
|
end
|