Sha256: dc16ae295e79069ade8ef42f0058bd73d845800180d6f1e393739526415ebad7
Contents?: true
Size: 1.57 KB
Versions: 3
Compression:
Stored size: 1.57 KB
Contents
require_relative '../../lib/jsonerino' require_relative '../../lib/jsonerino/parse_error' describe Jsonerino do describe '#parse (exceptions)' do it 'Should throw parse error when invoked on empty strings' do expect { Jsonerino.parse(' ') }.to raise_error(Jsonerino::JsonParseError) end it 'Should print out the line (row) and character index (column) to indicate where the parse error occurred' do expect { Jsonerino.parse('{"foo" }') }.to raise_error(Jsonerino::JsonParseError, /line 1 column 8/) end it 'Should print out the unexpected token that caused the error' do expect { Jsonerino.parse('{"foo" }') }.to raise_error(Jsonerino::JsonParseError, /Unexpected token '\}'/) expect { Jsonerino.parse('{"foo": : }') }.to raise_error(Jsonerino::JsonParseError, /Unexpected token ':'/) expect { Jsonerino.parse('{"foo": ] }') }.to raise_error(Jsonerino::JsonParseError, /Unexpected token '\]'/) end it 'Should throw end of input error when end of input is reached'\ '(happens with unclosed curly brackets/double qutoes/etc.)' do expect { Jsonerino.parse('{"foo }') } .to raise_error(Jsonerino::JsonParseError, /End of data while reading object contents of the JSON data/) expect { Jsonerino.parse('{"foo" ') } .to raise_error(Jsonerino::JsonParseError, /End of data while reading object contents of the JSON data/) end it 'Should throw runtime error for unsupported characters' do expect { Jsonerino.parse('{"foo": % }') }.to raise_error(RuntimeError, /Unexpected character '%'/) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
jsonerino-0.2.4 | spec/jsonerino/parse_error_spec.rb |
jsonerino-0.2.3 | spec/jsonerino/parse_error_spec.rb |
jsonerino-0.2.2 | spec/jsonerino/parse_error_spec.rb |