From 731358109388307857d3cb5c4f45a9518a516b64 Mon Sep 17 00:00:00 2001 From: Ryan Fitzgerald Date: Tue, 18 Dec 2012 00:53:26 -0800 Subject: [PATCH] Fix play_spec and command_integration_spec --- spec/command_integration_spec.rb | 9 +++--- spec/commands/play_spec.rb | 52 ++++++++++++++------------------ 2 files changed, 27 insertions(+), 34 deletions(-) diff --git a/spec/command_integration_spec.rb b/spec/command_integration_spec.rb index 237fc555..452fad0c 100644 --- a/spec/command_integration_spec.rb +++ b/spec/command_integration_spec.rb @@ -217,11 +217,10 @@ describe "commands" do describe "Pry#run_command" do it 'should run a command that modifies the passed in eval_string' do p = Pry.new(:output => @str_output) - p.push_binding 7 - eval_string = "def hello\npeter pan\n" - p.run_command("amend-line !", eval_string) - eval_string.should =~ /def hello/ - eval_string.should.not =~ /peter pan/ + p.accept_line "def hello\npeter pan\n" + p.run_command "amend-line !" + p.eval_string.should =~ /def hello/ + p.eval_string.should.not =~ /peter pan/ end it 'should run a command in the context of a session' do diff --git a/spec/commands/play_spec.rb b/spec/commands/play_spec.rb index c2e967ce..03b3544f 100644 --- a/spec/commands/play_spec.rb +++ b/spec/commands/play_spec.rb @@ -3,21 +3,20 @@ require 'helper' describe "play" do before do @t = pry_tester - @eval_str = '' end describe "with an argument" do describe "string variable" do it "without --lines switch" do @t.eval 'x = "\"hello\""' - @t.process_command 'play x', @eval_str - @eval_str.should == '"hello"' + @t.process_command 'play x' + @t.eval_string.should == '"hello"' end it 'using --lines switch to select what to play' do @t.eval 'x = "\"hello\"\n\"goodbye\"\n\"love\""' - @t.process_command 'play x --lines 1', @eval_str - @eval_str.should == "\"hello\"\n" + @t.process_command 'play x --lines 1' + @t.eval_string.should == "\"hello\"\n" end end @@ -40,16 +39,16 @@ describe "play" do describe "integer" do it "should process one line from _pry_.last_file" do - @t.process_command 'play 1', @eval_str - @eval_str.should =~ /bing = :bing\n/ + @t.process_command 'play 1' + @t.eval_string.should =~ /bing = :bing\n/ end end describe "range" do it "should process multiple lines at once from _pry_.last_file" do - @t.process_command 'play 1..3', @eval_str + @t.process_command 'play 1..3' [/bing = :bing\n/, /bang = :bang\n/, /bong = :bong\n/].each { |str| - @eval_str.should =~ str + @t.eval_string.should =~ str } end end @@ -57,8 +56,8 @@ describe "play" do describe "malformed" do it "should return nothing" do - @t.process_command 'play 69', @eval_str - @eval_str.should == '' + @t.process_command 'play 69' + @t.eval_string.should == '' lambda { @t.process_command('play zZz') }.should.raise Pry::CommandError end end @@ -70,6 +69,8 @@ describe "play" do def @o.test_method :test_method_content end + + @t = pry_tester(@o) end it 'should play documentation with the -d switch' do @@ -79,9 +80,8 @@ describe "play" do :test_method_content end - pry_tester(@o).process_command 'play -d test_method', @eval_str - - @eval_str.should == unindent(<<-STR) + @t.process_command 'play -d test_method' + @t.eval_string.should == unindent(<<-STR) @v = 10 @y = 20 STR @@ -96,27 +96,22 @@ describe "play" do :test_method_content end - pry_tester(@o).process_command 'play -d test_method --lines 2..3', @eval_str - - @eval_str.should == unindent(<<-STR) + @t.process_command 'play -d test_method --lines 2..3' + @t.eval_string.should == unindent(<<-STR) @v = 10 @y = 20 STR end it 'should play a method with the -m switch (a single line)' do - pry_tester(@o).process_command 'play -m test_method --lines 2', @eval_str - @eval_str.should == " :test_method_content\n" + @t.process_command 'play -m test_method --lines 2' + @t.eval_string.should == " :test_method_content\n" end it 'should APPEND to the input buffer when playing a line with play -m, not replace it' do - @eval_str = unindent(<<-STR) - def another_test_method - STR - - pry_tester(@o).process_command 'play -m test_method --lines 2', @eval_str - - @eval_str.should == unindent(<<-STR) + @t.accept_line 'def another_test_method' + @t.process_command 'play -m test_method --lines 2' + @t.eval_string.should == unindent(<<-STR) def another_test_method :test_method_content STR @@ -130,9 +125,8 @@ describe "play" do @var3 = 40 end - pry_tester(@o).process_command 'play -m test_method --lines 3..4', @eval_str - - @eval_str.should == unindent(<<-STR, 2) + @t.process_command 'play -m test_method --lines 3..4' + @t.eval_string.should == unindent(<<-STR, 2) @var1 = 20 @var2 = 30 STR