Sha256: 5a63b546b4a02a510f661bfeafa085c3ad4763a0079862663dac82b6acfa0a28

Contents?: true

Size: 1.77 KB

Versions: 11

Compression:

Stored size: 1.77 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::Keymap.new(name: '_test_') }

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

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

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

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

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

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

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

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

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

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

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

        context 'when the key is valid (not already defined)' do
          before { model.stubs(:add).returns(Vedeu::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 'defines the name of the keymap' do
          subject
          model.name.must_equal(_value)
        end
      end

    end # Keymap

  end # DSL

end # Vedeu

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
vedeu-0.6.1 test/lib/vedeu/dsl/keymap_test.rb
vedeu-0.6.0 test/lib/vedeu/dsl/keymap_test.rb
vedeu-0.5.13 test/lib/vedeu/dsl/keymap_test.rb
vedeu-0.5.12 test/lib/vedeu/dsl/keymap_test.rb
vedeu-0.5.11 test/lib/vedeu/dsl/keymap_test.rb
vedeu-0.5.10 test/lib/vedeu/dsl/keymap_test.rb
vedeu-0.5.9 test/lib/vedeu/dsl/keymap_test.rb
vedeu-0.5.8 test/lib/vedeu/dsl/keymap_test.rb
vedeu-0.5.7 test/lib/vedeu/dsl/keymap_test.rb
vedeu-0.5.6 test/lib/vedeu/dsl/keymap_test.rb
vedeu-0.5.5 test/lib/vedeu/dsl/keymap_test.rb