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

Fix play_spec and command_integration_spec

This commit is contained in:
Ryan Fitzgerald 2012-12-18 00:53:26 -08:00
parent b7758db7c5
commit 7313581093
2 changed files with 27 additions and 34 deletions

View file

@ -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

View file

@ -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