Sha256: d2fbbe055a157bc960ee488c912d62910b8719d85bc2749bdd88905fc088c721

Contents?: true

Size: 1.72 KB

Versions: 6

Compression:

Stored size: 1.72 KB

Contents

require_relative '../../../test_helper'
require_relative '../../../support/dummy_command'
require_relative '../../../../lib/vedeu/repository/command_repository'

module Vedeu
  describe CommandRepository do
    before do
      CommandRepository.create({
        name:     'apple',
        entity:   DummyCommand,
        keypress: 'a',
        keyword:  'apple'
      })
      CommandRepository.create({
        name:     'banana',
        entity:   DummyCommand,
        keypress: 'b',
        keyword:  'banana'
      })
    end
    after { CommandRepository.reset }

    describe '.by_input' do
      it 'returns the correct command when the command was found by keypress' do
        command = CommandRepository.by_input('b')

        command.name.must_equal('banana')
        command.name.wont_equal('apple')
        command.keypress.must_equal('b')
      end

      it 'returns the correct command when the command was found by keyword' do
        command = CommandRepository.by_input('apple')

        command.keypress.must_equal('a')
        command.keypress.wont_equal('b')
        command.name.wont_equal('banana')
      end

      it 'returns FalseClass when no command was found' do
        command = CommandRepository.by_input('not_found')
        command.must_be_instance_of(FalseClass)
      end

      it 'returns FalseClass when there is no input' do
        CommandRepository.by_input('').must_be_instance_of(FalseClass)
      end
    end

    describe '.create' do
      it 'returns a Command' do
        command = CommandRepository.create({})
        command.must_be_instance_of(Command)
      end
    end

    describe '.entity' do
      it 'returns Command' do
        CommandRepository.entity.must_equal(Command)
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
vedeu-0.0.38 test/lib/vedeu/repository/command_repository_test.rb
vedeu-0.0.37 test/lib/vedeu/repository/command_repository_test.rb
vedeu-0.0.36 test/lib/vedeu/repository/command_repository_test.rb
vedeu-0.0.35 test/lib/vedeu/repository/command_repository_test.rb
vedeu-0.0.34 test/lib/vedeu/repository/command_repository_test.rb
vedeu-0.0.33 test/lib/vedeu/repository/command_repository_test.rb