Sha256: b1375c3dc18eba91554f4de8f5875f2abc6a9eb4f8c45fc04c2fd75edcd6e3f7
Contents?: true
Size: 1.01 KB
Versions: 7
Compression:
Stored size: 1.01 KB
Contents
require 'spec_helper' require 'rom/memory/storage' describe ROM::Memory::Storage do describe 'thread safe' do let(:threads) { 4 } let(:operations) { 5000 } describe 'data' do it 'create datasets properly' do storage = ROM::Memory::Storage.new threaded_operations do |thread, operation| key = "#{thread}:#{operation}" storage.create_dataset(key) end expect(storage.size).to eql(threads * operations) end end describe 'dataset' do it 'inserts data in proper order' do storage = ROM::Memory::Storage.new dataset = storage.create_dataset(:ary) threaded_operations do dataset << :data end expect(dataset.size).to eql(threads * operations) end end def threaded_operations threads.times.map do |thread| Thread.new do operations.times do |operation| yield thread, operation end end end.each(&:join) end end end
Version data entries
7 entries across 7 versions & 1 rubygems