2014-09-01 04:24:45 -04:00
|
|
|
require 'helper'
|
2012-09-15 17:50:15 -04:00
|
|
|
|
2014-09-01 04:24:45 -04: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 17:50:15 -04:00
|
|
|
end
|
|
|
|
|
2014-09-01 04:24:45 -04:00
|
|
|
it 'prints an error when trying to jump to the same binding index' do
|
2018-10-12 12:54:00 -04:00
|
|
|
expect(pry_eval obj, "cd 1", "cd 2", "jump-to 2").to match(/Already/)
|
2012-09-15 17:50:15 -04:00
|
|
|
end
|
|
|
|
|
2014-09-01 04:24:45 -04:00
|
|
|
it 'prints error when trying to jump to a non-existent binding index' do
|
2015-01-23 04:30:41 -05:00
|
|
|
expect(pry_eval obj, "cd 1", "cd 2", "jump-to 3").to match(/Invalid nest level/)
|
2012-09-15 17:50:15 -04:00
|
|
|
end
|
|
|
|
end
|