test/lib/vedeu/repositories/store_test.rb in vedeu-0.6.10 vs test/lib/vedeu/repositories/store_test.rb in vedeu-0.6.11
- old
+ new
@@ -1,164 +1,168 @@
require 'test_helper'
module Vedeu
- class StoreTestClass
- include Vedeu::Store
+ module Repositories
- attr_reader :model
+ class StoreTestClass
+ include Vedeu::Repositories::Store
- def initialize(model = nil, storage = {})
- @model = model
- @storage = storage
- end
+ attr_reader :model
- private
+ def initialize(model = nil, storage = {})
+ @model = model
+ @storage = storage
+ end
- def in_memory
- {}
+ private
+
+ def in_memory
+ {}
+ end
end
- end
- describe Store do
+ describe Store do
- let(:described) { Vedeu::Store }
- let(:instance) { Vedeu::StoreTestClass.new(model, storage) }
- let(:model) {}
- let(:storage) {}
+ let(:described) { Vedeu::Repositories::Store }
+ let(:instance) { Vedeu::Repositories::StoreTestClass.new(model, storage) }
+ let(:model) {}
+ let(:storage) {}
- describe '#each' do
- subject { instance.each }
+ describe '#each' do
+ subject { instance.each }
- it { subject.must_be_instance_of(Enumerator) }
- end
+ it { subject.must_be_instance_of(Enumerator) }
+ end
- describe '#empty?' do
- subject { instance.empty? }
+ describe '#empty?' do
+ subject { instance.empty? }
- context 'when empty' do
- it { subject.must_equal(true) }
- end
+ context 'when empty' do
+ it { subject.must_equal(true) }
+ end
- context 'when not empty' do
- let(:storage) { [:item] }
+ context 'when not empty' do
+ let(:storage) { [:item] }
- it { subject.must_equal(false) }
+ it { subject.must_equal(false) }
+ end
end
- end
- describe '#exists?' do
- let(:_name) {}
+ describe '#exists?' do
+ let(:_name) {}
- subject { instance.exists?(_name) }
+ subject { instance.exists?(_name) }
- context 'when empty' do
- let(:_name) { 'terbium' }
+ context 'when empty' do
+ let(:_name) { 'terbium' }
- it { subject.must_equal(false) }
- end
+ it { subject.must_equal(false) }
+ end
- context 'with no name' do
- it { subject.must_equal(false) }
- end
+ context 'with no name' do
+ it { subject.must_equal(false) }
+ end
- context 'with empty name' do
- let(:_name) { '' }
+ context 'with empty name' do
+ let(:_name) { '' }
- it { subject.must_equal(false) }
- end
+ it { subject.must_equal(false) }
+ end
- context 'when the model does not exist' do
- let(:storage) { { 'samarium' => [:some_model_data] } }
- let(:_name) { 'terbium' }
+ context 'when the model does not exist' do
+ let(:storage) { { 'samarium' => [:some_model_data] } }
+ let(:_name) { 'terbium' }
- it { subject.must_equal(false) }
- end
+ it { subject.must_equal(false) }
+ end
- context 'when the model exists' do
- let(:storage) { { 'samarium' => [:some_model_data] } }
- let(:_name) { 'samarium' }
+ context 'when the model exists' do
+ let(:storage) { { 'samarium' => [:some_model_data] } }
+ let(:_name) { 'samarium' }
- it { subject.must_equal(true) }
+ it { subject.must_equal(true) }
+ end
+
+ it { instance.must_respond_to(:registered?) }
end
- it { instance.must_respond_to(:registered?) }
- end
+ describe '#registered' do
+ subject { instance.registered }
- describe '#registered' do
- subject { instance.registered }
+ it { subject.must_be_instance_of(Array) }
- it { subject.must_be_instance_of(Array) }
-
- context 'when the storage is a Hash' do
- let(:storage) {
- {
- 'rutherfordium' => { name: 'rutherfordium' }
+ context 'when the storage is a Hash' do
+ let(:storage) {
+ {
+ 'rutherfordium' => { name: 'rutherfordium' }
+ }
}
- }
- it 'returns a collection of the names of all the registered entities' do
- subject.must_equal(['rutherfordium'])
+ it 'returns a collection of the names of all the registered entities' do
+ subject.must_equal(['rutherfordium'])
+ end
end
- end
- context 'when the storage is an Array' do
- let(:storage) { ['rutherfordium'] }
+ context 'when the storage is an Array' do
+ let(:storage) { ['rutherfordium'] }
- it 'returns the registered entities' do
- subject.must_equal(['rutherfordium'])
+ it 'returns the registered entities' do
+ subject.must_equal(['rutherfordium'])
+ end
end
- end
- context 'when the storage is a Set' do
- let(:storage) { Set['rutherfordium'] }
+ context 'when the storage is a Set' do
+ let(:storage) { Set['rutherfordium'] }
- it 'returns the registered entities' do
- subject.must_equal(['rutherfordium'])
+ it 'returns the registered entities' do
+ subject.must_equal(['rutherfordium'])
+ end
end
- end
- context 'when the storage is empty' do
- it 'returns an empty collection' do
- subject.must_equal([])
+ context 'when the storage is empty' do
+ it 'returns an empty collection' do
+ subject.must_equal([])
+ end
end
end
- end
- describe '#reset' do
- it 'returns a Hash' do
- instance.reset.must_be_instance_of(Hash)
- end
+ describe '#reset' do
+ it 'returns a Hash' do
+ instance.reset.must_be_instance_of(Hash)
+ end
- it 'resets the repository' do
- instance.reset.must_equal({})
+ it 'resets the repository' do
+ instance.reset.must_equal({})
+ end
+
+ it { instance.must_respond_to(:reset!) }
+ it { instance.must_respond_to(:clear) }
end
- it { instance.must_respond_to(:reset!) }
- it { instance.must_respond_to(:clear) }
- end
+ describe '#size' do
+ subject { instance.size }
- describe '#size' do
- subject { instance.size }
+ context 'when empty' do
+ it { subject.must_equal(0) }
+ end
- context 'when empty' do
- it { subject.must_equal(0) }
- end
+ context 'when not empty' do
+ let(:storage) { [:item] }
- context 'when not empty' do
- let(:storage) { [:item] }
-
- it { subject.must_equal(1) }
+ it { subject.must_equal(1) }
+ end
end
- end
- describe '#storage' do
- subject { instance.storage }
+ describe '#storage' do
+ subject { instance.storage }
- it { subject.must_equal({}) }
+ it { subject.must_equal({}) }
- it { instance.must_respond_to(:all) }
- end
+ it { instance.must_respond_to(:all) }
+ end
- end # Store
+ end # Store
+
+ end # Repositories
end # Vedeu