Created
November 9, 2014 06:40
-
-
Save y-yagi/cec784b99b56a226e60d to your computer and use it in GitHub Desktop.
TracePoint study
This file contains 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
require 'minitest' | |
require "minitest/autorun" | |
require 'power_p' | |
require 'ripper' | |
trace = TracePoint.new(:raise) do |tp| | |
if tp.raised_exception.class == Minitest::Assertion | |
file, lineno = tp.raised_exception.location.split(':') | |
line = open(file).each_line.drop(lineno.to_i - 1).first | |
idents = Ripper.sexp(line) | |
p "line: #{line}".strip | |
# p tp.binding.eval('caller_locations') | |
# p tp.binding.eval('local_variables') | |
end | |
end | |
trace.enable | |
class TestMeme < Minitest::Test | |
def test_that_kitty_can_eat | |
assert_equal 3.times.to_a, 0 | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment