2014-09-01 02:24:45 -06:00
|
|
|
require 'helper'
|
2012-09-15 14:50:15 -07:00
|
|
|
|
2014-09-01 02:24:45 -06:00
|
|
|
RSpec.describe "jump-to" do
|
|
|
|
let(:obj) { Object.new }
|
|
|
|
|
|
|
|
it 'jumps to the proper binding index in the stack' do
|
|
|
|
expect(pry_eval obj, "cd 1", "cd 2", "jump-to 0", 'self').to eq obj
|
|
|
|
expect(pry_eval obj, 'cd 1', 'cd 2', 'jump-to 1', 'self').to eq 1
|
2012-09-15 14:50:15 -07:00
|
|
|
end
|
|
|
|
|
2014-09-01 02:24:45 -06:00
|
|
|
it 'prints an error when trying to jump to the same binding index' do
|
2015-01-23 10:30:41 +01:00
|
|
|
expect(pry_eval obj, "cd 1", "cd 2", "jump-to 2").to match(/Already/)
|
2012-09-15 14:50:15 -07:00
|
|
|
end
|
|
|
|
|
2014-09-01 02:24:45 -06:00
|
|
|
it 'prints error when trying to jump to a non-existent binding index' do
|
2015-01-23 10:30:41 +01:00
|
|
|
expect(pry_eval obj, "cd 1", "cd 2", "jump-to 3").to match(/Invalid nest level/)
|
2012-09-15 14:50:15 -07:00
|
|
|
end
|
|
|
|
end
|