diff --git a/spec/helpers/repl_tester.rb b/spec/helpers/repl_tester.rb index 6ce704ce..c30254da 100644 --- a/spec/helpers/repl_tester.rb +++ b/spec/helpers/repl_tester.rb @@ -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 diff --git a/spec/pry_repl_spec.rb b/spec/pry_repl_spec.rb index f29ff222..bb8ce1c8 100644 --- a/spec/pry_repl_spec.rb +++ b/spec/pry_repl_spec.rb @@ -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