Sha256: 17c9b75e5f9f33b10eb841b48a24f351d3132a6f032bcb61c903be603340482e

Contents?: true

Size: 1.74 KB

Versions: 54

Compression:

Stored size: 1.74 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(InvalidSyntax) }
        end

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

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

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

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

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

          it { proc { subject }.must_raise(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

54 entries across 54 versions & 1 rubygems

Version Path
vedeu-0.5.4 test/lib/vedeu/dsl/keymap_test.rb
vedeu-0.5.3 test/lib/vedeu/dsl/keymap_test.rb
vedeu-0.5.2 test/lib/vedeu/dsl/keymap_test.rb
vedeu-0.5.1 test/lib/vedeu/dsl/keymap_test.rb
vedeu-0.5.0 test/lib/vedeu/dsl/keymap_test.rb
vedeu-0.4.65 test/lib/vedeu/dsl/keymap_test.rb
vedeu-0.4.64 test/lib/vedeu/dsl/keymap_test.rb
vedeu-0.4.63 test/lib/vedeu/dsl/keymap_test.rb
vedeu-0.4.62 test/lib/vedeu/dsl/keymap_test.rb
vedeu-0.4.61 test/lib/vedeu/dsl/keymap_test.rb
vedeu-0.4.60 test/lib/vedeu/dsl/keymap_test.rb
vedeu-0.4.59 test/lib/vedeu/dsl/keymap_test.rb
vedeu-0.4.58 test/lib/vedeu/dsl/keymap_test.rb
vedeu-0.4.57 test/lib/vedeu/dsl/keymap_test.rb
vedeu-0.4.56 test/lib/vedeu/dsl/keymap_test.rb
vedeu-0.4.55 test/lib/vedeu/dsl/keymap_test.rb
vedeu-0.4.54 test/lib/vedeu/dsl/keymap_test.rb
vedeu-0.4.53 test/lib/vedeu/dsl/keymap_test.rb
vedeu-0.4.52 test/lib/vedeu/dsl/keymap_test.rb
vedeu-0.4.51 test/lib/vedeu/dsl/keymap_test.rb