Commit 5d69583
Changed files (2)
lib
del
spec
lib/del/repository.rb
@@ -17,7 +17,11 @@ module Del
end
def find_all
- @lock.synchronize { @storage.keys }
+ @lock.synchronize do
+ @storage.map do |(_, value)|
+ @mapper.map_from(value)
+ end
+ end
end
def upsert(id, attributes = {})
spec/repository_spec.rb
@@ -17,5 +17,22 @@ RSpec.describe Del::Repository do
specify { expect(subject[id]).to eql(user) }
specify { expect(subject.find(id)).to eql(user) }
+ specify { expect(subject.find(SecureRandom.uuid)).to be_nil }
+ end
+
+ describe "#find_all" do
+ let(:del_attributes) { { name: 'Teren Delvon Jones' } }
+ let(:ice_cube_attributes) { { name: "O'Shea Jackson Sr." } }
+ let(:del) { instance_double(Del::User) }
+ let(:cube) { instance_double(Del::User) }
+
+ it 'returns each item' do
+ subject.upsert(SecureRandom.uuid, del_attributes)
+ subject.upsert(SecureRandom.uuid, ice_cube_attributes)
+ allow(mapper).to receive(:map_from).with(del_attributes).and_return(del)
+ allow(mapper).to receive(:map_from).with(ice_cube_attributes).and_return(cube)
+
+ expect(subject.find_all).to match_array([ del, cube ])
+ end
end
end