mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
added tests for hist command, fixed tests for cd command, changed some method names in helpers.rb
This commit is contained in:
parent
8b065971c3
commit
7f96d03e9a
1 changed files with 18 additions and 5 deletions
|
@ -2,6 +2,10 @@ require 'helper'
|
|||
|
||||
describe "Pry::Commands" do
|
||||
|
||||
after do
|
||||
$obj = nil
|
||||
end
|
||||
|
||||
describe "hist" do
|
||||
before do
|
||||
Readline::HISTORY.clear
|
||||
|
@ -122,35 +126,43 @@ describe "Pry::Commands" do
|
|||
b = Pry.binding_for(Object.new)
|
||||
b.eval("x = :mon_ouie")
|
||||
|
||||
redirect_pry_io(InputTester.new("cd x", "self.should == :mon_ouie;", "exit-all"), StringIO.new) do
|
||||
redirect_pry_io(InputTester.new("cd x", "$obj = self", "exit-all"), StringIO.new) do
|
||||
Pry.new.repl(b)
|
||||
end
|
||||
|
||||
$obj.should == :mon_ouie
|
||||
end
|
||||
|
||||
it 'should break out of session with cd ..' do
|
||||
b = Pry.binding_for(:outer)
|
||||
b.eval("x = :inner")
|
||||
|
||||
redirect_pry_io(InputTester.new("cd x", "self.should == :inner;", "cd ..", "self.should == :outer", "exit-all"), StringIO.new) do
|
||||
redirect_pry_io(InputTester.new("cd x", "$inner = self;", "cd ..", "$outer = self", "exit-all"), StringIO.new) do
|
||||
Pry.new.repl(b)
|
||||
end
|
||||
$inner.should == :inner
|
||||
$outer.should == :outer
|
||||
end
|
||||
|
||||
it 'should break out to outer-most session with cd /' do
|
||||
b = Pry.binding_for(:outer)
|
||||
b.eval("x = :inner")
|
||||
|
||||
redirect_pry_io(InputTester.new("cd x", "self.should == :inner;", "cd 5", "self.should == 5", "cd /", "self.should == :outer", "exit-all"), StringIO.new) do
|
||||
redirect_pry_io(InputTester.new("cd x", "$inner = self;", "cd 5", "$five = self", "cd /", "$outer = self", "exit-all"), StringIO.new) do
|
||||
Pry.new.repl(b)
|
||||
end
|
||||
$inner.should == :inner
|
||||
$five.should == 5
|
||||
$outer.should == :outer
|
||||
end
|
||||
|
||||
it 'should start a session on TOPLEVEL_BINDING with cd ::' do
|
||||
b = Pry.binding_for(:outer)
|
||||
|
||||
redirect_pry_io(InputTester.new("cd ::", "self.should == TOPLEVEL_BINDING.eval('self')", "exit-all"), StringIO.new) do
|
||||
redirect_pry_io(InputTester.new("cd ::", "$obj = self", "exit-all"), StringIO.new) do
|
||||
Pry.new.repl(5)
|
||||
end
|
||||
$obj.should == TOPLEVEL_BINDING.eval('self')
|
||||
end
|
||||
|
||||
it 'should cd into complex input (with spaces)' do
|
||||
|
@ -159,9 +171,10 @@ describe "Pry::Commands" do
|
|||
:mon_ouie
|
||||
end
|
||||
|
||||
redirect_pry_io(InputTester.new("cd hello 1, 2, 3", "self.should == :mon_ouie", "exit-all"), StringIO.new) do
|
||||
redirect_pry_io(InputTester.new("cd hello 1, 2, 3", "$obj = self", "exit-all"), StringIO.new) do
|
||||
Pry.new.repl(o)
|
||||
end
|
||||
$obj.should == :mon_ouie
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue