mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
Remove some repetitive bits from play_spec.rb
Signed-off-by: Kyrylo Silin <kyrylosilin@gmail.com>
This commit is contained in:
parent
de50544759
commit
9b85398d29
1 changed files with 70 additions and 86 deletions
|
@ -3,13 +3,10 @@ require 'helper'
|
||||||
describe "play" do
|
describe "play" do
|
||||||
before do
|
before do
|
||||||
@t = pry_tester
|
@t = pry_tester
|
||||||
|
@eval_str = ''
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "with an argument" do
|
describe "with an argument" do
|
||||||
before do
|
|
||||||
@eval_str = ''
|
|
||||||
end
|
|
||||||
|
|
||||||
describe "string variable" do
|
describe "string variable" do
|
||||||
it "without --lines switch" do
|
it "without --lines switch" do
|
||||||
@t.eval 'x = "\"hello\""'
|
@t.eval 'x = "\"hello\""'
|
||||||
|
@ -67,91 +64,78 @@ describe "play" do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should play documentation with the -d switch' do
|
describe "without argument (switches only)" do
|
||||||
eval_str = ''
|
before do
|
||||||
o = Object.new
|
@o = Object.new
|
||||||
|
def @o.test_method
|
||||||
# @v = 10
|
|
||||||
# @y = 20
|
|
||||||
def o.test_method
|
|
||||||
:test_method_content
|
|
||||||
end
|
|
||||||
|
|
||||||
pry_tester(o).process_command 'play -d test_method', eval_str
|
|
||||||
|
|
||||||
eval_str.should == unindent(<<-STR)
|
|
||||||
@v = 10
|
|
||||||
@y = 20
|
|
||||||
STR
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should restrict -d switch with --lines' do
|
|
||||||
eval_str = ''
|
|
||||||
o = Object.new
|
|
||||||
|
|
||||||
# @x = 0
|
|
||||||
# @v = 10
|
|
||||||
# @y = 20
|
|
||||||
# @z = 30
|
|
||||||
def o.test_method
|
|
||||||
:test_method_content
|
|
||||||
end
|
|
||||||
|
|
||||||
pry_tester(o).process_command 'play -d test_method --lines 2..3', eval_str
|
|
||||||
|
|
||||||
eval_str.should == unindent(<<-STR)
|
|
||||||
@v = 10
|
|
||||||
@y = 20
|
|
||||||
STR
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should play a method with the -m switch (a single line)' do
|
|
||||||
eval_str = ''
|
|
||||||
o = Object.new
|
|
||||||
|
|
||||||
def o.test_method
|
|
||||||
:test_method_content
|
|
||||||
end
|
|
||||||
|
|
||||||
pry_tester(o).process_command 'play -m test_method --lines 2', eval_str
|
|
||||||
|
|
||||||
eval_str.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
|
|
||||||
|
|
||||||
o = Object.new
|
|
||||||
def o.test_method
|
|
||||||
:test_method_content
|
|
||||||
end
|
|
||||||
|
|
||||||
pry_tester(o).process_command 'play -m test_method --lines 2', eval_str
|
|
||||||
|
|
||||||
eval_str.should == unindent(<<-STR)
|
|
||||||
def another_test_method
|
|
||||||
:test_method_content
|
:test_method_content
|
||||||
STR
|
end
|
||||||
end
|
|
||||||
|
|
||||||
it 'should play a method with the -m switch (multiple line)' do
|
|
||||||
eval_str = ''
|
|
||||||
o = Object.new
|
|
||||||
|
|
||||||
def o.test_method
|
|
||||||
@var0 = 10
|
|
||||||
@var1 = 20
|
|
||||||
@var2 = 30
|
|
||||||
@var3 = 40
|
|
||||||
end
|
end
|
||||||
|
|
||||||
pry_tester(o).process_command 'play -m test_method --lines 3..4', eval_str
|
it 'should play documentation with the -d switch' do
|
||||||
|
# @v = 10
|
||||||
|
# @y = 20
|
||||||
|
def @o.test_method
|
||||||
|
:test_method_content
|
||||||
|
end
|
||||||
|
|
||||||
eval_str.should == unindent(<<-STR, 2)
|
pry_tester(@o).process_command 'play -d test_method', @eval_str
|
||||||
@var1 = 20
|
|
||||||
@var2 = 30
|
@eval_str.should == unindent(<<-STR)
|
||||||
STR
|
@v = 10
|
||||||
|
@y = 20
|
||||||
|
STR
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should restrict -d switch with --lines' do
|
||||||
|
# @x = 0
|
||||||
|
# @v = 10
|
||||||
|
# @y = 20
|
||||||
|
# @z = 30
|
||||||
|
def @o.test_method
|
||||||
|
:test_method_content
|
||||||
|
end
|
||||||
|
|
||||||
|
pry_tester(@o).process_command 'play -d test_method --lines 2..3', @eval_str
|
||||||
|
|
||||||
|
@eval_str.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"
|
||||||
|
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)
|
||||||
|
def another_test_method
|
||||||
|
:test_method_content
|
||||||
|
STR
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should play a method with the -m switch (multiple line)' do
|
||||||
|
def @o.test_method
|
||||||
|
@var0 = 10
|
||||||
|
@var1 = 20
|
||||||
|
@var2 = 30
|
||||||
|
@var3 = 40
|
||||||
|
end
|
||||||
|
|
||||||
|
pry_tester(@o).process_command 'play -m test_method --lines 3..4', @eval_str
|
||||||
|
|
||||||
|
@eval_str.should == unindent(<<-STR, 2)
|
||||||
|
@var1 = 20
|
||||||
|
@var2 = 30
|
||||||
|
STR
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue