Add clarifying comments to unit test for malformed json test

Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
This commit is contained in:
Clinton Wolfe 2019-01-17 11:07:13 -05:00
parent 7d1fd5a085
commit 06399fbc0f

View file

@ -64,9 +64,12 @@ describe 'Inspec::Config' do
let(:fixture_name) { 'malformed_json' }
it 'should throw an exception' do
ex = proc { cfg }.must_raise(Inspec::ConfigError::MalformedJson)
ex.message.must_include 'Failed to load JSON config'
ex.message.must_include 'unexpected token'
ex.message.must_include 'version'
# Failed to load JSON configuration: 765: unexpected token at '{ "hot_garbage": "a", "version": "1.1",
# '
# Config was: "{ \"hot_garbage\": \"a\", \"version\": \"1.1\", \n"
ex.message.must_include 'Failed to load JSON config' # The message
ex.message.must_include 'unexpected token' # The specific parser error
ex.message.must_include 'hot_garbage' # A sample of the unacceptable contents
end
end
@ -457,7 +460,7 @@ module ConfigTestHelper
when :bad_top_level
'{ "version": "1.1", "unsupported_field": "some_value" }'
when :malformed_json
'{ "version": "1.1", '
'{ "hot_garbage": "a", "version": "1.1", '
when :with_compliance
# TODO - this is dubious, need to verify
<<~EOJ5