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

Test command mutating eval_string instead of Ruby doing it

It probably isn't actually important to support Ruby mutating
eval_string.
This commit is contained in:
Ryan Fitzgerald 2012-12-23 15:21:58 -08:00
parent 4edafaee0f
commit 00c2fc935d
2 changed files with 21 additions and 8 deletions

View file

@ -9,9 +9,9 @@ class ReplTester
end end
end end
def self.start(&block) def self.start(options = {}, &block)
redirect_pry_io Input.new, StringIO.new do redirect_pry_io Input.new, StringIO.new do
instance = new instance = new(options)
instance.instance_eval(&block) instance.instance_eval(&block)
instance.ensure_exit instance.ensure_exit
end end
@ -19,8 +19,8 @@ class ReplTester
attr_accessor :pry, :repl, :fiber attr_accessor :pry, :repl, :fiber
def initialize def initialize(options = {})
@pry = Pry.new @pry = Pry.new(options)
@repl = Pry::REPL.new(@pry) @repl = Pry::REPL.new(@pry)
@fiber = Fiber.new do @fiber = Fiber.new do

View file

@ -47,10 +47,23 @@ describe "The REPL" do
end end
end end
it "should immediately evaluate if eval_string is complete" do it "should immediately evaluate eval_string after cmd if complete" do
ReplTester.start do set = Pry::CommandSet.new do
input '_pry_.eval_string = "10"' import Pry::Commands
output '=> 10'
command 'hello!' do
eval_string.replace('"hello"')
end
end
ReplTester.start(:commands => set) do
input 'def x'
output ''
prompt /\* $/
input 'hello!'
output '=> "hello"'
prompt /> $/
end end
end end
end end