···120 end
121 end
122123- context 'when service entries are partially valid' do
124 let(:services) {
125 [
126 { 'id' => '#atproto_pds', 'type' => 'AtprotoPersonalDataServer', 'serviceEndpoint' => 'https://pds.dholms.xyz' },
···133134 let(:json) { base_json.merge('service' => services) }
135136- it 'should only keep the valid records' do
137- doc = subject.new(did, json)
138-139- doc.services.length.should == 2
140- doc.services.map(&:key).should == ['atproto_pds', 'lycan']
141- doc.services.map(&:type).should == ['AtprotoPersonalDataServer', 'LycanService']
142- doc.services.map(&:endpoint).should == ['https://pds.dholms.xyz', 'https://lycan.feeds.blue']
143 end
144 end
145 end
···120 end
121 end
122123+ context 'when some service entries are not valid' do
124 let(:services) {
125 [
126 { 'id' => '#atproto_pds', 'type' => 'AtprotoPersonalDataServer', 'serviceEndpoint' => 'https://pds.dholms.xyz' },
···133134 let(:json) { base_json.merge('service' => services) }
135136+ it 'should raise a format error' do
137+ expect {
138+ subject.new(did, json)
139+ }.to raise_error(DIDKit::FormatError)
000140 end
141 end
142 end
+8
spec/plc_operation_spec.rb
···111 end
112 end
11300000000114 context 'when operation type is not plc_operation' do
115 let(:json) { base_json.tap { |h| h['operation']['type'] = 'other' }}
116
···111 end
112 end
113114+ context 'when operation type is not a string' do
115+ let(:json) { base_json.tap { |h| h['operation']['type'] = 5 }}
116+117+ it 'should raise a format error' do
118+ expect { subject.new(json) }.to raise_error(DIDKit::FormatError)
119+ end
120+ end
121+122 context 'when operation type is not plc_operation' do
123 let(:json) { base_json.tap { |h| h['operation']['type'] = 'other' }}
124