test/lib/vedeu/repository/interface_repository_test.rb in vedeu-0.0.30 vs test/lib/vedeu/repository/interface_repository_test.rb in vedeu-0.0.31
- old
+ new
@@ -1,115 +1,77 @@
require_relative '../../../test_helper'
require_relative '../../../../lib/vedeu/repository/interface_repository'
module Vedeu
describe InterfaceRepository do
- let(:described_class) { InterfaceRepository }
-
- before do
- InterfaceRepository.create({
- name: 'dummy',
- width: 15,
- height: 2
- })
- end
- after { InterfaceRepository.reset }
-
describe '.create' do
- let(:subject) { described_class.create(attributes) }
- let(:attributes) {
- {
+ it 'returns an Interface' do
+ InterfaceRepository.create({
name: 'dummy',
width: 15,
height: 2
- }
- }
-
- it 'returns an Interface' do
- subject.must_be_instance_of(Interface)
+ }).must_be_instance_of(Interface)
end
end
describe '.find' do
- let(:subject) { described_class.find(value) }
- let(:value) { 'dummy' }
-
- context 'when the interface exists' do
- it 'returns an Interface' do
- subject.must_be_instance_of(Interface)
- end
+ it 'returns an Interface when the interface exists' do
+ InterfaceRepository.create({
+ name: 'dummy',
+ width: 15,
+ height: 2
+ })
+ InterfaceRepository.find('dummy').must_be_instance_of(Interface)
end
- context 'when the interface does not exist' do
- before { InterfaceRepository.reset }
-
- it 'raises an exception' do
- proc { subject }.must_raise(UndefinedInterface)
- end
+ it 'raises an exception when the interface does not exist' do
+ InterfaceRepository.reset
+ proc { InterfaceRepository.find('dummy') }
+ .must_raise(UndefinedInterface)
end
end
describe '.update' do
- let(:subject) { described_class.update(value, attributes) }
- let(:value) { 'dummy' }
- let(:attributes) { { name: 'dumber' } }
-
it 'returns an Interface' do
- subject.must_be_instance_of(Interface)
+ InterfaceRepository.update('dummy', { name: 'dumber' })
+ .must_be_instance_of(Interface)
end
- context 'when the interface exists' do
- it 'updates and returns the existing interface' do
- subject.name.must_equal('dumber')
- end
+ it 'updates and returns the existing interface when the interface exists' do
+ InterfaceRepository.update('dummy', { name: 'dumber' }).name
+ .must_equal('dumber')
end
- context 'when the interface does not exist' do
- before { InterfaceRepository.reset }
-
- it 'returns the created interface' do
- subject.name.must_equal('dumber')
- end
+ it 'returns a new interface when the interface does not exist' do
+ InterfaceRepository.reset
+ InterfaceRepository.update('dummy', { name: 'dumber' }).name
+ .must_equal('dumber')
end
end
describe '.refresh' do
- let(:subject) { described_class.refresh }
-
it 'returns an Array' do
- subject.must_be_instance_of(Array)
+ InterfaceRepository.refresh.must_be_instance_of(Array)
end
- end
- describe '.by_layer' do
- let(:subject) { described_class.by_layer }
-
- before do
+ it 'returns the collection in order they should be drawn' do
InterfaceRepository.reset
- @case_a = InterfaceRepository.create({ name: 'a', width: 15, height: 2, z: 2 })
- @case_b = InterfaceRepository.create({ name: 'b', width: 15, height: 2, z: 1 })
- @case_c = InterfaceRepository.create({ name: 'c', width: 15, height: 2, z: 3 })
+ InterfaceRepository.create({
+ name: 'a', width: 15, height: 2, z: 2
+ }).enqueue("a")
+ InterfaceRepository.create({
+ name: 'b', width: 15, height: 2, z: 1
+ }).enqueue("b")
+ InterfaceRepository.create({
+ name: 'c', width: 15, height: 2, z: 3
+ }).enqueue("c")
+ InterfaceRepository.refresh.must_equal(['b', 'a', 'c'])
end
- after { InterfaceRepository.reset }
-
- it 'returns an Array' do
- subject.must_be_instance_of(Array)
- end
-
- it 'returns the collection in order they should be drawn' do
- subject.must_equal([@case_b, @case_a, @case_c])
- 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 Interface' do
- subject.must_equal(Interface)
+ InterfaceRepository.entity.must_equal(Interface)
end
end
end
end