test/lib/vedeu/repository/command_repository_test.rb in vedeu-0.0.30 vs test/lib/vedeu/repository/command_repository_test.rb in vedeu-0.0.31

- old
+ new

@@ -2,13 +2,10 @@ require_relative '../../../support/dummy_command' require_relative '../../../../lib/vedeu/repository/command_repository' module Vedeu describe CommandRepository do - let(:described_class) { CommandRepository } - let(:input) {} - before do CommandRepository.create({ name: 'apple', entity: DummyCommand, keypress: 'a', @@ -19,69 +16,43 @@ entity: DummyCommand, keypress: 'b', keyword: 'banana' }) end - after { CommandRepository.reset } describe '.by_input' do - let(:subject) { described_class.by_input(input) } - let(:input) { 'b' } + 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 Command instance' do - subject.must_be_instance_of(Command) + 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 - context 'when the command was found by keypress' do - it 'returns the correct command' do - subject.name.must_equal('banana') - end - - it 'returns the correct command' do - subject.name.wont_equal('apple') - end - - it 'returns the correct command' do - subject.keypress.must_equal('b') - end + it 'returns FalseClass when no command was found' do + CommandRepository.by_input('not_found').must_be_instance_of(FalseClass) end - context 'when the command was found by keyword' do - let(:input) { 'apple' } - - it 'returns the correct command' do - subject.keypress.must_equal('a') - end - - it 'returns the correct command' do - subject.keypress.wont_equal('b') - end - - it 'returns the correct command' do - subject.name.wont_equal('banana') - end + it 'returns FalseClass when there is no input' do + CommandRepository.by_input('').must_be_instance_of(FalseClass) end end describe '.create' do - let(:subject) { described_class.create(attributes) } - let(:attributes) { {} } - it 'returns a Command' do - subject.must_be_instance_of(Command) + skip + CommandRepository.create({}).must_be_instance_of(Command) end end describe '.entity' do - let(:subject) { described_class.entity } - - it 'returns a Class instance' do - subject.must_be_instance_of(Class) - end - it 'returns Command' do - subject.must_equal(Command) + CommandRepository.entity.must_equal(Command) end end end end