From 00c2fc935d6b713cb6df706973fcecc2d05c00dc Mon Sep 17 00:00:00 2001 From: Ryan Fitzgerald Date: Sun, 23 Dec 2012 15:21:58 -0800 Subject: [PATCH] Test command mutating eval_string instead of Ruby doing it It probably isn't actually important to support Ruby mutating eval_string. --- spec/helpers/repl_tester.rb | 8 ++++---- spec/pry_repl_spec.rb | 21 +++++++++++++++++---- 2 files changed, 21 insertions(+), 8 deletions(-) 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