File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed
Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change 7070 }
7171 end
7272
73+ let ( :errors_json ) do
74+ {
75+ 'errors' => [
76+ {
77+ 'code' => 'unprocessable_entity' ,
78+ 'status' => '422' ,
79+ 'title' => 'Validation Error' ,
80+ 'detail' => 'Patron must exist' ,
81+ 'source' => {
82+ 'pointer' => '/data/relationships/patron'
83+ } ,
84+ 'meta' => {
85+ 'attribute' => 'patron' ,
86+ 'message' => 'must exist' ,
87+ 'code' => 'blank'
88+ }
89+ }
90+ ]
91+ }
92+ end
93+
7394 describe '#json_item' do
7495 let ( :json ) { show_json }
7596
166187 } )
167188 end
168189 end
190+
191+ describe '#validation_errors' do
192+ let ( :json ) { errors_json }
193+
194+ it 'creates a hash of the errors' do
195+ expect ( validation_errors ) . to eq ( { :patron => 'must exist' } )
196+ end
197+
198+ describe 'when there are no errors' do
199+ let ( :json ) { show_json }
200+ it 'does not raise an error of its own' do
201+ expect { validation_errors } . not_to raise_error
202+ end
203+ end
204+ end
205+
169206end
You can’t perform that action at this time.
0 commit comments