File tree Expand file tree Collapse file tree 2 files changed +7
-0
lines changed Expand file tree Collapse file tree 2 files changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ module JSONAPI
23
23
# objects in the primary data must have an id.
24
24
# @return [JSONAPI::Parser::Document]
25
25
def parse ( document , options = { } )
26
+ raise Parser ::InvalidDocument , 'document cannot be nil' if document . nil?
26
27
hash = document . is_a? ( Hash ) ? document : JSON . parse ( document )
27
28
28
29
Parser ::Document . new ( hash , options )
Original file line number Diff line number Diff line change 94
94
expect ( document . data . first . relationships . author . data . to_hash ) . to eq @author_data_hash
95
95
expect ( document . data . first . relationships . comments . data . map ( &:to_hash ) ) . to eq @comments_data_hash
96
96
end
97
+
98
+ it 'raises InvalidDocument on nil input' do
99
+ expect {
100
+ JSONAPI . parse ( nil )
101
+ } . to raise_error JSONAPI ::Parser ::InvalidDocument
102
+ end
97
103
end
You can’t perform that action at this time.
0 commit comments