Last active
December 10, 2020 07:41
-
-
Save a2ikm/b21b023690ff8ef99e738497f59725c7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
line_tracer = TracePoint.new(:line) do |tp| | |
p [tp.path, tp.lineno] | |
end | |
RSpec.configure do |config| | |
# enable for each test case | |
config.around do |example| | |
line_tracer.enable do | |
example.run | |
end | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
current_id = nil | |
data = Hash.new { |h, example_id| h[example_id] = [] } | |
line_tracer = TracePoint.new(:line) do |tp| | |
if record?(tp.path) # tell if we should record this event or not | |
data[example_id] << [tp.path, tp.lineno] | |
end | |
end | |
RSpec.configure do |config| | |
config.around do |example| | |
current_id = example.id | |
line_tracer.enable do | |
example.run | |
end | |
flush(data) # write and clear huge data on each test case | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment