rewrite mock_backtrace to use define_singleton_method.

This commit is contained in:
Robert Gleeson 2014-03-10 01:22:09 +01:00
parent e6576546de
commit 90dacb8f25
1 changed files with 2 additions and 4 deletions

View File

@ -68,11 +68,9 @@ module PryTestHelpers
end
def mock_exception(*mock_backtrace)
e = StandardError.new("mock exception")
(class << e; self; end).class_eval do
define_method(:backtrace) { mock_backtrace }
StandardError.new.tap do |e|
e.define_singleton_method(:backtrace) { mock_backtrace }
end
e
end
end