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

Fix old_stack behavior on error

This commit is contained in:
Ryan Fitzgerald 2012-08-16 23:31:03 -07:00
parent 6271b16aee
commit 46e1196e75
2 changed files with 18 additions and 18 deletions

View file

@ -20,9 +20,9 @@ class Pry
BANNER
def process
stack, old_stack = context_from_object_path(arg_string, _pry_, state.old_stack||[])
state.old_stack = old_stack
_pry_.binding_stack = stack unless stack.nil?
state.old_stack ||= []
stack, state.old_stack = context_from_object_path(arg_string, _pry_, state.old_stack)
_pry_.binding_stack = stack if stack
end
end
end

View file

@ -20,9 +20,9 @@ describe 'Pry::DefaultCommands::Cd' do
eval '_pry_.command_state["cd"]'
end
# def old_stack
# eval '_pry_.command_state["cd"].old_stack.dup'
# end
def old_stack
eval '_pry_.command_state["cd"].old_stack.dup'
end
end
end
@ -42,20 +42,20 @@ describe 'Pry::DefaultCommands::Cd' do
end
end
# describe 'when an error was raised' do
# it 'should not toggle and should keep correct stacks' do
# proc {
# @t.eval 'cd @'
# }.should.raise(Pry::CommandError)
describe 'when an error was raised' do
it 'should not toggle and should keep correct stacks' do
proc {
@t.eval 'cd @'
}.should.raise(Pry::CommandError)
# @t.old_stack.should == []
# @t.assert_binding_stack [@o]
@t.old_stack.should == []
@t.assert_binding_stack [@o]
# @t.eval 'cd -'
# @t.old_stack.should == []
# @t.assert_binding_stack [@o]
# end
# end
@t.eval 'cd -'
@t.old_stack.should == []
@t.assert_binding_stack [@o]
end
end
describe 'when using simple cd syntax' do
it 'should toggle' do