mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
removed some unnecessary global vars from tests
This commit is contained in:
parent
f79dda0f84
commit
7c8aa38015
2 changed files with 22 additions and 31 deletions
|
@ -3,8 +3,7 @@ require 'helper'
|
||||||
describe "Pry::DefaultCommands::Documentation" do
|
describe "Pry::DefaultCommands::Documentation" do
|
||||||
describe "show-doc" do
|
describe "show-doc" do
|
||||||
it 'should output a method\'s documentation' do
|
it 'should output a method\'s documentation' do
|
||||||
str_output = StringIO.new
|
redirect_pry_io(InputTester.new("show-doc sample_method", "exit-all"), str_output=StringIO.new) do
|
||||||
redirect_pry_io(InputTester.new("show-doc sample_method", "exit-all"), str_output) do
|
|
||||||
pry
|
pry
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -12,20 +11,17 @@ describe "Pry::DefaultCommands::Documentation" do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should output a method\'s documentation if inside method without needing to use method name' do
|
it 'should output a method\'s documentation if inside method without needing to use method name' do
|
||||||
$str_output = StringIO.new
|
|
||||||
|
|
||||||
o = Object.new
|
o = Object.new
|
||||||
|
|
||||||
# sample comment
|
# sample comment
|
||||||
def o.sample
|
def o.sample
|
||||||
redirect_pry_io(InputTester.new("show-doc", "exit-all"), $str_output) do
|
redirect_pry_io(InputTester.new("show-doc", "exit-all"), $out=StringIO.new) do
|
||||||
binding.pry
|
binding.pry
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
o.sample
|
o.sample
|
||||||
|
$out.string.should =~ /sample comment/
|
||||||
$str_output.string.should =~ /sample comment/
|
$out = nil
|
||||||
$str_output = nil
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should be able to find super methods" do
|
it "should be able to find super methods" do
|
||||||
|
|
|
@ -171,58 +171,53 @@ describe "Pry::DefaultCommands::Input" do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should play a method with the -m switch (a single line)' do
|
it 'should play a method with the -m switch (a single line)' do
|
||||||
$o = Object.new
|
o = Object.new
|
||||||
def $o.test_method
|
def o.test_method
|
||||||
:test_method_content
|
:test_method_content
|
||||||
end
|
end
|
||||||
|
|
||||||
redirect_pry_io(InputTester.new('play -m $o.test_method --lines 2', "exit-all"), str_output = StringIO.new) do
|
redirect_pry_io(InputTester.new('play -m test_method --lines 2', "exit-all"), str_output = StringIO.new) do
|
||||||
pry
|
o.pry
|
||||||
end
|
end
|
||||||
|
|
||||||
str_output.string.should =~ /:test_method_content/
|
str_output.string.should =~ /:test_method_content/
|
||||||
$o = nil
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should APPEND to the input buffer when playing a line with play -m, not replace it' do
|
it 'should APPEND to the input buffer when playing a line with play -m, not replace it' do
|
||||||
$o = Object.new
|
o = Object.new
|
||||||
def $o.test_method
|
def o.test_method
|
||||||
:test_method_content
|
:test_method_content
|
||||||
end
|
end
|
||||||
|
|
||||||
redirect_pry_io(InputTester.new('def another_test_method', 'play -m $o.test_method --lines 2', 'show-input', 'exit-all'), str_output = StringIO.new) do
|
redirect_pry_io(InputTester.new('def another_test_method', 'play -m test_method --lines 2', 'show-input', 'exit-all'), str_output = StringIO.new) do
|
||||||
pry
|
o.pry
|
||||||
end
|
end
|
||||||
str_output.string.should =~ /def another_test_method/
|
str_output.string.should =~ /def another_test_method/
|
||||||
str_output.string.should =~ /:test_method_content/
|
str_output.string.should =~ /:test_method_content/
|
||||||
$o = nil
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
it 'should play a method with the -m switch (multiple line)' do
|
it 'should play a method with the -m switch (multiple line)' do
|
||||||
$o = Object.new
|
o = Object.new
|
||||||
class << $o
|
|
||||||
attr_accessor :var1, :var2
|
|
||||||
end
|
|
||||||
|
|
||||||
def $o.test_method
|
def o.test_method
|
||||||
|
@var0 = 10
|
||||||
@var1 = 20
|
@var1 = 20
|
||||||
@var2 = 30
|
@var2 = 30
|
||||||
|
@var3 = 40
|
||||||
end
|
end
|
||||||
|
|
||||||
obj = Object.new
|
redirect_pry_io(InputTester.new('play -m test_method --lines 3..4', "exit-all"), str_output = StringIO.new) do
|
||||||
b = Pry.binding_for(obj)
|
o.pry
|
||||||
|
|
||||||
redirect_pry_io(InputTester.new('play -m $o.test_method --lines 2..3', "exit-all"), str_output = StringIO.new) do
|
|
||||||
b.pry
|
|
||||||
end
|
end
|
||||||
|
|
||||||
obj.instance_variable_get(:@var1).should == 20
|
o.instance_variable_get(:@var0).should == nil
|
||||||
obj.instance_variable_get(:@var2).should == 30
|
o.instance_variable_get(:@var1).should == 20
|
||||||
|
o.instance_variable_get(:@var2).should == 30
|
||||||
|
o.instance_variable_get(:@var3).should == nil
|
||||||
str_output.string.should =~ /30/
|
str_output.string.should =~ /30/
|
||||||
str_output.string.should.not =~ /20/
|
str_output.string.should.not =~ /20/
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "hist" do
|
describe "hist" do
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue