Sha256: b1748dab61a99e7a824b2b6d6c2373827293078af065e2dd4792d4b748e3cd78

Contents?: true

Size: 1.47 KB

Versions: 4

Compression:

Stored size: 1.47 KB

Contents

require 'test_helper'

module Vedeu

  describe RefreshCursor do

    let(:described) { Vedeu::RefreshCursor }
    let(:instance)  { described.new(_name) }
    let(:_name)     { 'refresh_cursor' }
    let(:expected)  {}
    let(:ox)        { 0 }
    let(:oy)        { 0 }

    describe '#initialize' do
      it { instance.must_be_instance_of(described) }
      it { instance.instance_variable_get('@name').must_equal(_name) }
    end

    describe '.render' do
      before {
        Vedeu.geometry 'refresh_cursor' do
          x  1
          xn 3
          y  1
          yn 3
        end
        Vedeu::Cursor.new({ name: 'refresh_cursor', ox: ox, oy: oy }).store

        Vedeu::Terminal.stubs(:output).returns(expected)
      }

      subject { described.render(_name) }

      it 'renders the cursor in the terminal' do
        Vedeu::Terminal.expects(:output).with("\e[1;1H\e[?25l")
        subject
      end

      context 'when the cursors offset position is outside the viewable area' do
        let(:ox) { 3 }
        let(:oy) { 3 }

        it 'refreshes the view' do
          Vedeu::Refresh.expects(:by_name)
          subject
        end
      end

      context 'when the cursors offset position is inside the viewable area' do
        it 'does not refresh the view' do
          Vedeu::Refresh.expects(:by_name).never
          subject
        end
      end
    end

    describe '#render' do
      it { instance.must_respond_to(:render) }
    end

  end # RefreshCursor

end # Vedeu

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
vedeu-0.5.4 test/lib/vedeu/cursor/refresh_cursor_test.rb
vedeu-0.5.3 test/lib/vedeu/cursor/refresh_cursor_test.rb
vedeu-0.5.2 test/lib/vedeu/cursor/refresh_cursor_test.rb
vedeu-0.5.1 test/lib/vedeu/cursor/refresh_cursor_test.rb