Sha256: faabf29f4ee1c9f108f12eb668a43461cbf6893f41f740cb9698c69bd215aae3

Contents?: true

Size: 1.92 KB

Versions: 8

Compression:

Stored size: 1.92 KB

Contents

# frozen_string_literal: true

require 'test_helper'

module Vedeu

  module Cursors

    describe Move do

      let(:described) { Vedeu::Cursors::Move }
      let(:instance)  { described.new(_name, direction, offset) }
      let(:_name)     {}
      let(:direction) {}
      let(:offset)    { 1 }
      let(:visible)   { true }

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

      describe '.move' do
        let(:cursor) {
          Vedeu::Cursors::Cursor.new(name: _name, visible: visible)
        }

        before do
          Vedeu.stubs(:trigger).with(:_refresh_cursor_, _name)
        end

        subject { described.move(_name, direction, offset) }

        context 'when a name is given' do
          let(:_name) { :vedeu_cursors_move }

          before do
            Vedeu.cursors.stubs(:by_name).returns(cursor)
          end

          context 'when the cursor is visible' do
            context 'when a valid direction is given' do
              let(:direction) { :move_left }

              it { subject.must_be_instance_of(Vedeu::Cursors::Cursor) }
            end

            context 'when an invalid direction is given' do
              let(:direction) { :invalid }

              it { subject.must_equal(nil) }
            end
          end

          context 'when the cursor is not visible' do
            let(:visible) { false }

            it { subject.must_equal(nil) }
          end
        end

        context 'when a name is not given' do
          it { subject.must_equal(nil) }
        end
      end

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

    end # Move

  end # Cursors

end # Vedeu

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
vedeu-0.8.16 test/lib/vedeu/cursors/move_test.rb
vedeu-0.8.15 test/lib/vedeu/cursors/move_test.rb
vedeu-0.8.14 test/lib/vedeu/cursors/move_test.rb
vedeu-0.8.13 test/lib/vedeu/cursors/move_test.rb
vedeu-0.8.12 test/lib/vedeu/cursors/move_test.rb
vedeu-0.8.10 test/lib/vedeu/cursors/move_test.rb
vedeu-0.8.9 test/lib/vedeu/cursors/move_test.rb
vedeu-0.8.8 test/lib/vedeu/cursors/move_test.rb