1
0
Fork 0
mirror of https://github.com/pry/pry.git synced 2022-11-09 12:35:05 -05:00
pry--pry/spec/helper.rb
John Mair 31a9578228 cleaned up lib/pry/test/helper.rb
* removed most historicla junk from lib/pry/test/helper.rb
* relocated recalcitrant junk to the local spec/helper.rb (this isn't exposed to 3rd parties)
2012-12-07 21:41:05 +01:00

55 lines
1.1 KiB
Ruby

unless Object.const_defined? 'Pry'
$:.unshift File.expand_path '../../lib', __FILE__
require 'pry'
end
require File.join(File.expand_path(File.dirname(__FILE__)), '../lib/pry/test/helper')
class Module
public :remove_const
public :remove_method
end
# turn warnings off (esp for Pry::Hooks which will generate warnings
# in tests)
$VERBOSE = nil
# Set I/O streams.
#
# Out defaults to an anonymous StringIO.
def redirect_pry_io(new_in, new_out = StringIO.new)
old_in = Pry.input
old_out = Pry.output
Pry.input = new_in
Pry.output = new_out
begin
yield
ensure
Pry.input = old_in
Pry.output = old_out
end
end
class InputTester
def initialize(*actions)
@orig_actions = actions.dup
@actions = actions
end
def readline(*)
@actions.shift
end
def rewind
@actions = @orig_actions.dup
end
end
# to help with tracking down bugs that cause an infinite loop in the test suite
if ENV["SET_TRACE_FUNC"]
require 'set_trace' if Pry::Helpers::BaseHelpers.rbx?
set_trace_func proc { |event, file, line, id, binding, classname|
STDERR.printf "%8s %s:%-2d %10s %8s\n", event, file, line, id, classname
}
end