Commit 8d798f2
Changed files (4)
lib
lib/del/configuration.rb
@@ -24,7 +24,7 @@ module Del
@password = settings.fetch(:password)
@router = DefaultRouter.new
@socket_file = settings.fetch(:socket_file, SOCKET_FILE)
- @users = Repository.new
+ @users = Repository.new(mapper: User)
end
def load(file)
lib/del/user.rb
@@ -16,7 +16,7 @@ module Del
end
def self.map_from(attributes)
- new(attributes[:id], attributes)
+ new(attributes['jid'], attributes)
end
end
end
spec/repository_spec.rb
@@ -6,23 +6,23 @@ RSpec.describe Del::Repository do
let(:mapper) { double(:mapper, map_from: nil) }
describe "#[]" do
- let(:id) { SecureRandom.uuid }
- let(:attributes) { { id: id, name: 'Teren Delvon Jones' } }
+ let(:jid) { SecureRandom.uuid }
+ let(:attributes) { { 'jid' => jid, 'name' => 'Teren Delvon Jones' } }
let(:user) { instance_double(Del::User) }
before do
- subject.upsert(id, attributes)
+ subject.upsert(jid, attributes)
allow(mapper).to receive(:map_from).with(attributes).and_return(user)
end
- specify { expect(subject[id]).to eql(user) }
- specify { expect(subject.find(id)).to eql(user) }
+ specify { expect(subject[jid]).to eql(user) }
+ specify { expect(subject.find(jid)).to eql(user) }
specify { expect(subject.find(SecureRandom.uuid)).to be_nil }
end
describe "#all" do
- let(:del_attributes) { { name: 'Teren Delvon Jones' } }
- let(:ice_cube_attributes) { { name: "O'Shea Jackson Sr." } }
+ 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) }
spec/user_spec.rb
@@ -3,12 +3,12 @@ require 'spec_helper'
RSpec.describe Del::User do
describe ".map_from" do
subject { described_class }
- let(:attributes) { { id: SecureRandom.uuid } }
+ let(:attributes) { { 'jid' => SecureRandom.uuid } }
it 'returns a new user' do
result = subject.map_from(attributes)
expect(result).to be_instance_of(described_class)
- expect(result.jid).to eql(attributes[:id])
+ expect(result.jid).to eql(attributes['jid'])
expect(result.attributes).to eql(attributes)
end
end