Sha256: 6b43d866e5710d8630be02cfb3341d4fd37da1033fea0350cd2deb2af2a65993

Contents?: true

Size: 1.74 KB

Versions: 1

Compression:

Stored size: 1.74 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
        CommandRepository.by_input('b').name.must_equal('banana')
        CommandRepository.by_input('b').name.wont_equal('apple')
        CommandRepository.by_input('b').keypress.must_equal('b')
      end

      it 'returns the correct command when the command was found by keyword' do
        CommandRepository.by_input('apple').keypress.must_equal('a')
        CommandRepository.by_input('apple').keypress.wont_equal('b')
        CommandRepository.by_input('apple').name.wont_equal('banana')
      end

      it 'returns FalseClass when no command was found' do
        CommandRepository.by_input('not_found')
          .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
        skip
        CommandRepository.create({}).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

1 entries across 1 versions & 1 rubygems

Version Path
vedeu-0.0.32 test/lib/vedeu/repository/command_repository_test.rb