Sha256: 4f3432899736c42ad9b40d754b01950e1a1919a2dc4119d747d62339e619c31d

Contents?: true

Size: 1.73 KB

Versions: 8

Compression:

Stored size: 1.73 KB

Contents

require 'test_helper'

module Vedeu

  module DSL

    describe Keymap do

      let(:described) { Vedeu::DSL::Keymap }
      let(:instance)  { described.new(model) }
      let(:model)     { Vedeu::Input::Keymap.new(name: '_test_') }

      describe '#key' do
        let(:value_or_values) { ['j', :down] }

        subject { instance.key(*value_or_values) { :some_action } }

        it { instance.must_respond_to(:key=) }

        context 'when a block was not given' do
          subject { instance.key(value_or_values) }

          it { proc { subject }.must_raise(Vedeu::Error::InvalidSyntax) }
        end

        context 'when a key was not given' do
          let(:value_or_values) {}

          it { proc { subject }.must_raise(Vedeu::Error::InvalidSyntax) }
        end

        context 'when an invalid key was given (nil)' do
          let(:value_or_values) { ['v', nil] }

          it { proc { subject }.must_raise(Vedeu::Error::InvalidSyntax) }
        end

        context 'when an invalid key was given (empty)' do
          let(:value_or_values) { ['v', ''] }

          it { proc { subject }.must_raise(Vedeu::Error::InvalidSyntax) }
        end

        context 'when the key is valid (not already defined)' do
          before { model.stubs(:add).returns(Vedeu::Input::Keymap) }

          it { subject.must_equal(['j', :down]) }
        end

        context 'when the key is not valid (already defined)' do
        end
      end

      describe '#name' do
        let(:_value) { 'gold' }

        subject { instance.name(_value) }

        it { instance.must_respond_to(:name=) }

        it 'defines the name of the keymap' do
          subject
          model.name.must_equal(_value)
        end
      end

    end # Keymap

  end # DSL

end # Vedeu

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
vedeu-0.6.28 test/lib/vedeu/dsl/keymap_test.rb
vedeu-0.6.27 test/lib/vedeu/dsl/keymap_test.rb
vedeu-0.6.26 test/lib/vedeu/dsl/keymap_test.rb
vedeu-0.6.25 test/lib/vedeu/dsl/keymap_test.rb
vedeu-0.6.24 test/lib/vedeu/dsl/keymap_test.rb
vedeu-0.6.23 test/lib/vedeu/dsl/keymap_test.rb
vedeu-0.6.22 test/lib/vedeu/dsl/keymap_test.rb
vedeu-0.6.21 test/lib/vedeu/dsl/keymap_test.rb