Sha256: 39047845c8b528db21bcdcbd06c5fde3cea8ed3c552adff2b7b5160f26bb703a

Contents?: true

Size: 1.93 KB

Versions: 40

Compression:

Stored size: 1.93 KB

Contents

require 'helper'

Pry.config.output = StringIO.new

describe PryStackExplorer::FrameManager do

  before do
    @pry_instance = Pry.new
    @bindings = [binding, binding, binding, binding]
    @bindings.each_with_index { |v, i| v.eval("x = #{i}") }
    @pry_instance.binding_stack.push @bindings.last
    @frame_manager = PE::FrameManager.new(@bindings, @pry_instance)
  end

  describe "creation" do
    it "should make bindings accessible via 'bindings' method" do
      @frame_manager.bindings.should == @bindings
    end

    it "should set binding_index to 0" do
      @frame_manager.binding_index.should == 0
    end

    it "should set current_frame to first frame" do
      @frame_manager.current_frame.should == @bindings.first
    end
  end

  describe "FrameManager#change_frame_to" do
    it 'should change the frame to the given one' do
      @frame_manager.change_frame_to(1)

      @frame_manager.binding_index.should == 1
      @frame_manager.current_frame.should == @bindings[1]
      @pry_instance.binding_stack.last.should == @frame_manager.current_frame
    end

    it 'should accept negative indices when specifying frame' do
      @frame_manager.change_frame_to(-1)

      # negative index is converted to a positive one inside change_frame_to
      @frame_manager.binding_index.should == @bindings.size - 1

      @frame_manager.current_frame.should == @bindings[-1]
      @pry_instance.binding_stack.last.should == @frame_manager.current_frame
    end
  end

  describe "FrameManager#refresh_frame" do
    it 'should change the Pry frame to the active one in the FrameManager' do
      @frame_manager.binding_index = 2
      @frame_manager.refresh_frame

      @pry_instance.binding_stack.last.should == @frame_manager.current_frame
    end
  end

  describe "FrameManager is Enumerable" do
    it 'should perform an Enumerable#map on the frames' do
      @frame_manager.map { |v| v.eval("x") }.should == (0..(@bindings.size - 1)).to_a
    end
  end

end

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
pry-stack_explorer-0.4.13 test/test_frame_manager.rb
pry-stack_explorer-0.4.12 test/test_frame_manager.rb
pry-stack_explorer-0.4.11 test/test_frame_manager.rb
pry-stack_explorer-0.5.0 test/test_frame_manager.rb
pry-stack_explorer-0.4.9.3 test/test_frame_manager.rb
pry-stack_explorer-0.4.9.2 test/test_frame_manager.rb
pry-stack_explorer-0.4.9.1 test/test_frame_manager.rb
pry-stack_explorer-0.4.9 test/test_frame_manager.rb
pry-stack_explorer-0.4.8 test/test_frame_manager.rb
pry-stack_explorer-0.4.8pre1 test/test_frame_manager.rb
pry-stack_explorer-0.4.7 test/test_frame_manager.rb
pry-stack_explorer-0.4.6 test/test_frame_manager.rb
pry-stack_explorer-0.4.5 test/test_frame_manager.rb
pry-stack_explorer-0.4.4 test/test_frame_manager.rb
pry-stack_explorer-0.4.3 test/test_frame_manager.rb
pry-stack_explorer-0.4.2 test/test_frame_manager.rb
pry-stack_explorer-0.4.1 test/test_frame_manager.rb
pry-stack_explorer-0.4.0 test/test_frame_manager.rb
pry-stack_explorer-0.3.9 test/test_frame_manager.rb
pry-stack_explorer-0.3.8 test/test_frame_manager.rb