mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
Make pry_tester accept Pry ctor options
This commit is contained in:
parent
9b52d358ae
commit
1a1ea323ea
2 changed files with 12 additions and 11 deletions
|
@ -242,8 +242,10 @@ ensure
|
|||
File.unlink("#{file.path}c") if File.exists?("#{file.path}c") # rbx
|
||||
end
|
||||
|
||||
def pry_tester(context = TOPLEVEL_BINDING, &block)
|
||||
PryTester.new(context).tap do |t|
|
||||
def pry_tester(*args, &block)
|
||||
args << TOPLEVEL_BINDING if args.length == 0
|
||||
|
||||
PryTester.new(*args).tap do |t|
|
||||
(class << t; self; end).class_eval(&block) if block
|
||||
end
|
||||
end
|
||||
|
@ -261,8 +263,8 @@ end
|
|||
class PryTester
|
||||
attr_reader :pry, :out
|
||||
|
||||
def initialize(context = TOPLEVEL_BINDING)
|
||||
@pry = Pry.new
|
||||
def initialize(context = TOPLEVEL_BINDING, options = {})
|
||||
@pry = Pry.new(options)
|
||||
|
||||
if context
|
||||
@pry.binding_stack << Pry.binding_for(context)
|
||||
|
@ -277,7 +279,7 @@ class PryTester
|
|||
result = nil
|
||||
|
||||
strs.flatten.each do |str|
|
||||
str = "#{str}\n" unless str.end_with?("\n")
|
||||
str = "#{str.strip}\n"
|
||||
if @pry.process_command(str)
|
||||
result = last_command_result_or_output
|
||||
else
|
||||
|
|
|
@ -352,12 +352,11 @@ describe "Pry::Command" do
|
|||
end
|
||||
|
||||
it 'should accept multiline blocks' do
|
||||
redirect_pry_io(InputTester.new("walking-spanish | do",
|
||||
" :jesus",
|
||||
"end",
|
||||
"exit-all"), out = StringIO.new) do
|
||||
Pry.start @context, :commands => @set
|
||||
end
|
||||
pry_tester(@context, :commands => @set).eval <<-EOS
|
||||
walking-spanish | do
|
||||
:jesus
|
||||
end
|
||||
EOS
|
||||
@context.instance_variable_get(:@x).should == :jesus
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue