mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
Fix calls to repl() in tests
This commit is contained in:
parent
6cd88512ec
commit
5da52a02ca
2 changed files with 31 additions and 25 deletions
|
@ -207,8 +207,7 @@ describe Pry do
|
||||||
it 'sets _ to the last result' do
|
it 'sets _ to the last result' do
|
||||||
res = []
|
res = []
|
||||||
input = InputTester.new *[":foo", "self << _", "42", "self << _"]
|
input = InputTester.new *[":foo", "self << _", "42", "self << _"]
|
||||||
pry = Pry.new(:input => input, :output => StringIO.new)
|
Pry.new(:input => input, :output => StringIO.new, :target => res).repl
|
||||||
pry.repl(res)
|
|
||||||
|
|
||||||
res.should == [:foo, 42]
|
res.should == [:foo, 42]
|
||||||
end
|
end
|
||||||
|
@ -216,8 +215,7 @@ describe Pry do
|
||||||
it 'sets out to an array with the result' do
|
it 'sets out to an array with the result' do
|
||||||
res = {}
|
res = {}
|
||||||
input = InputTester.new *[":foo", "42", "self[:res] = _out_"]
|
input = InputTester.new *[":foo", "42", "self[:res] = _out_"]
|
||||||
pry = Pry.new(:input => input, :output => StringIO.new)
|
Pry.new(:input => input, :output => StringIO.new, :target => res).repl
|
||||||
pry.repl(res)
|
|
||||||
|
|
||||||
res[:res].should.be.kind_of Pry::HistoryArray
|
res[:res].should.be.kind_of Pry::HistoryArray
|
||||||
res[:res][1..2].should == [:foo, 42]
|
res[:res][1..2].should == [:foo, 42]
|
||||||
|
@ -226,8 +224,7 @@ describe Pry do
|
||||||
it 'sets _in_ to an array with the entered lines' do
|
it 'sets _in_ to an array with the entered lines' do
|
||||||
res = {}
|
res = {}
|
||||||
input = InputTester.new *[":foo", "42", "self[:res] = _in_"]
|
input = InputTester.new *[":foo", "42", "self[:res] = _in_"]
|
||||||
pry = Pry.new(:input => input, :output => StringIO.new)
|
Pry.new(:input => input, :output => StringIO.new, :target => res).repl
|
||||||
pry.repl(res)
|
|
||||||
|
|
||||||
res[:res].should.be.kind_of Pry::HistoryArray
|
res[:res].should.be.kind_of Pry::HistoryArray
|
||||||
res[:res][1..2].should == [":foo\n", "42\n"]
|
res[:res][1..2].should == [":foo\n", "42\n"]
|
||||||
|
@ -236,8 +233,7 @@ describe Pry do
|
||||||
it 'uses 100 as the size of _in_ and _out_' do
|
it 'uses 100 as the size of _in_ and _out_' do
|
||||||
res = []
|
res = []
|
||||||
input = InputTester.new *["self << _out_.max_size << _in_.max_size"]
|
input = InputTester.new *["self << _out_.max_size << _in_.max_size"]
|
||||||
pry = Pry.new(:input => input, :output => StringIO.new)
|
Pry.new(:input => input, :output => StringIO.new, :target => res).repl
|
||||||
pry.repl(res)
|
|
||||||
|
|
||||||
res.should == [100, 100]
|
res.should == [100, 100]
|
||||||
end
|
end
|
||||||
|
@ -245,9 +241,12 @@ describe Pry do
|
||||||
it 'can change the size of the history arrays' do
|
it 'can change the size of the history arrays' do
|
||||||
res = []
|
res = []
|
||||||
input = InputTester.new *["self << _out_.max_size << _in_.max_size"]
|
input = InputTester.new *["self << _out_.max_size << _in_.max_size"]
|
||||||
pry = Pry.new(:input => input, :output => StringIO.new,
|
Pry.new(
|
||||||
:memory_size => 1000)
|
:input => input,
|
||||||
pry.repl(res)
|
:output => StringIO.new,
|
||||||
|
:memory_size => 1000,
|
||||||
|
:target => res
|
||||||
|
).repl
|
||||||
|
|
||||||
res.should == [1000, 1000]
|
res.should == [1000, 1000]
|
||||||
end
|
end
|
||||||
|
@ -255,9 +254,11 @@ describe Pry do
|
||||||
it 'store exceptions' do
|
it 'store exceptions' do
|
||||||
res = []
|
res = []
|
||||||
input = InputTester.new *["foo!","self << _in_[-1] << _out_[-1]"]
|
input = InputTester.new *["foo!","self << _in_[-1] << _out_[-1]"]
|
||||||
pry = Pry.new(:input => input, :output => StringIO.new,
|
Pry.new(
|
||||||
:memory_size => 1000)
|
:input => input,
|
||||||
pry.repl(res)
|
:output => StringIO.new,
|
||||||
|
:memory_size => 1000
|
||||||
|
).repl
|
||||||
|
|
||||||
res.first.should == "foo!\n"
|
res.first.should == "foo!\n"
|
||||||
res.last.should.be.kind_of NoMethodError
|
res.last.should.be.kind_of NoMethodError
|
||||||
|
@ -332,7 +333,12 @@ describe Pry do
|
||||||
|
|
||||||
it "should not load the rc file if #repl method invoked" do
|
it "should not load the rc file if #repl method invoked" do
|
||||||
Pry.config.should_load_rc = true
|
Pry.config.should_load_rc = true
|
||||||
Pry.new(:input => StringIO.new("exit-all\n"), :output => StringIO.new).repl(self)
|
|
||||||
|
Pry.new(
|
||||||
|
:input => StringIO.new("exit-all\n"),
|
||||||
|
:output => StringIO.new
|
||||||
|
).repl
|
||||||
|
|
||||||
Object.const_defined?(:TEST_RC).should == false
|
Object.const_defined?(:TEST_RC).should == false
|
||||||
Pry.config.should_load_rc = false
|
Pry.config.should_load_rc = false
|
||||||
end
|
end
|
||||||
|
|
|
@ -123,10 +123,11 @@ describe "Sticky locals (_file_ and friends)" do
|
||||||
|
|
||||||
it 'should create a new sticky local' do
|
it 'should create a new sticky local' do
|
||||||
o = Object.new
|
o = Object.new
|
||||||
pi = Pry.new
|
pry = Pry.new(:target => o)
|
||||||
pi.add_sticky_local(:test_local) { :test_value }
|
pry.add_sticky_local(:test_local) { :test_value }
|
||||||
pi.input, pi.output = InputTester.new("@value = test_local", "exit-all"), StringIO.new
|
pry.input = InputTester.new("@value = test_local", "exit-all")
|
||||||
pi.repl(o)
|
pry.output = StringIO.new
|
||||||
|
pry.repl
|
||||||
|
|
||||||
o.instance_variable_get(:@value).should == :test_value
|
o.instance_variable_get(:@value).should == :test_value
|
||||||
end
|
end
|
||||||
|
@ -135,12 +136,11 @@ describe "Sticky locals (_file_ and friends)" do
|
||||||
o = Object.new
|
o = Object.new
|
||||||
o2 = Object.new
|
o2 = Object.new
|
||||||
o.instance_variable_set(:@o2, o2)
|
o.instance_variable_set(:@o2, o2)
|
||||||
pi = Pry.new
|
pry = Pry.new(:target => o)
|
||||||
pi.add_sticky_local(:test_local) { :test_value }
|
pry.add_sticky_local(:test_local) { :test_value }
|
||||||
pi.input = InputTester.new("cd @o2\n",
|
pry.input = InputTester.new("cd @o2\n", "@value = test_local", "exit-all")
|
||||||
"@value = test_local", "exit-all")
|
pry.output = StringIO.new
|
||||||
pi.output = StringIO.new
|
pry.repl
|
||||||
pi.repl(o)
|
|
||||||
|
|
||||||
o2.instance_variable_get(:@value).should == :test_value
|
o2.instance_variable_get(:@value).should == :test_value
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue