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

View file

@ -47,10 +47,23 @@ describe "The REPL" do
end
end
it "should immediately evaluate if eval_string is complete" do
ReplTester.start do
input '_pry_.eval_string = "10"'
output '=> 10'
it "should immediately evaluate eval_string after cmd if complete" do
set = Pry::CommandSet.new do
import Pry::Commands
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