1
0
Fork 0
mirror of https://github.com/pry/pry.git synced 2022-11-09 12:35:05 -05:00
pry--pry/test/helper.rb

98 lines
1.5 KiB
Ruby
Raw Normal View History

unless Object.const_defined? 'Pry'
$:.unshift File.expand_path '../../lib', __FILE__
require 'pry'
end
require 'bacon'
# Ensure we do not execute any rc files
Pry::RC_FILES.clear
Pry.color = false
Pry.should_load_rc = false
# sample doc
def sample_method
:sample
end
def redirect_global_pry_input_output(new_in, new_out)
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
def redirect_global_pry_input(new_io)
old_io = Pry.input
Pry.input = new_io
begin
yield
ensure
Pry.input = old_io
end
end
def redirect_global_pry_output(new_io)
old_io = Pry.output
Pry.output = new_io
begin
yield
ensure
Pry.output = old_io
end
end
class Module
public :remove_const
end
class << Pry
alias_method :orig_reset_defaults, :reset_defaults
def reset_defaults
orig_reset_defaults
Pry.color = false
end
end
class InputTester
def initialize(*actions)
@orig_actions = actions.dup
@actions = actions
end
2011-01-09 06:51:45 -05:00
def readline(*)
@actions.shift
end
def rewind
@actions = @orig_actions.dup
end
end
2011-01-19 03:50:45 -05:00
class Pry
# null output class - doesn't write anywwhere.
class NullOutput
def self.puts(*) end
def self.string(*) end
2011-01-19 03:50:45 -05:00
end
end
2011-05-07 01:32:05 -04:00
CommandTester = Pry::CommandSet.new do
command "command1", "command 1 test" do
output.puts "command1"
end
command "command2", "command 2 test" do |arg|
output.puts arg
end
end