diff --git a/lib/power_assert/context.rb b/lib/power_assert/context.rb index 25b0a66..fd4fead 100644 --- a/lib/power_assert/context.rb +++ b/lib/power_assert/context.rb @@ -26,9 +26,11 @@ def initialize(base_caller_length) if (tp.event == :c_return && diff == 1 || tp.event == :return && diff <= 2) and Thread.current == @target_thread idx = -(base_caller_length + 1) if @parser.path == locs[idx].path and @parser.lineno == locs[idx].lineno + ret = tp.return_value + ret = tp.self if method_id == :initialize val = PowerAssert.configuration.lazy_inspection ? - tp.return_value : - InspectedValue.new(SafeInspectable.new(tp.return_value).inspect) + ret : + InspectedValue.new(SafeInspectable.new(ret).inspect) @return_values << Value[method_id.to_s, val, locs[idx].lineno, nil] end end diff --git a/lib/power_assert/parser.rb b/lib/power_assert/parser.rb index ff67200..0fcbb7b 100644 --- a/lib/power_assert/parser.rb +++ b/lib/power_assert/parser.rb @@ -175,7 +175,11 @@ def extract_idents(sexp) end when :@ident, :@const, :@op _, method_name, (_, column) = sexp - [Ident[:method, method_name, column]] + m = [Ident[:method, method_name, column]] + if method_name == "new" + m << Ident[:method, "initialize", column] + end + m else [] end