···120120 end
121121 end
122122123123- context 'when service entries are partially valid' do
123123+ context 'when some service entries are not valid' do
124124 let(:services) {
125125 [
126126 { 'id' => '#atproto_pds', 'type' => 'AtprotoPersonalDataServer', 'serviceEndpoint' => 'https://pds.dholms.xyz' },
···133133134134 let(:json) { base_json.merge('service' => services) }
135135136136- it 'should only keep the valid records' do
137137- doc = subject.new(did, json)
138138-139139- doc.services.length.should == 2
140140- doc.services.map(&:key).should == ['atproto_pds', 'lycan']
141141- doc.services.map(&:type).should == ['AtprotoPersonalDataServer', 'LycanService']
142142- doc.services.map(&:endpoint).should == ['https://pds.dholms.xyz', 'https://lycan.feeds.blue']
136136+ it 'should raise a format error' do
137137+ expect {
138138+ subject.new(did, json)
139139+ }.to raise_error(DIDKit::FormatError)
143140 end
144141 end
145142 end
+8
spec/plc_operation_spec.rb
···111111 end
112112 end
113113114114+ context 'when operation type is not a string' do
115115+ let(:json) { base_json.tap { |h| h['operation']['type'] = 5 }}
116116+117117+ it 'should raise a format error' do
118118+ expect { subject.new(json) }.to raise_error(DIDKit::FormatError)
119119+ end
120120+ end
121121+114122 context 'when operation type is not plc_operation' do
115123 let(:json) { base_json.tap { |h| h['operation']['type'] = 'other' }}
116124