mirror of
https://github.com/inspec/inspec
synced 2024-11-23 13:13:22 +00:00
extend json tests, remove dot-resolver
This commit is contained in:
parent
6ddc45446d
commit
a55e240a0f
2 changed files with 31 additions and 11 deletions
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "demo",
|
"name": "demo",
|
||||||
"run_list": [
|
"run_list": [
|
||||||
"apache2",
|
"a",
|
||||||
"omnibus"
|
"b"
|
||||||
],
|
],
|
||||||
"cookbook_locks": {
|
"x": {
|
||||||
"omnibus": {
|
"y": {
|
||||||
"version": "2.2.0"
|
"z": 123
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,11 +6,31 @@ require 'helper'
|
||||||
require 'inspec/resource'
|
require 'inspec/resource'
|
||||||
|
|
||||||
describe 'Inspec::Resources::JSON' do
|
describe 'Inspec::Resources::JSON' do
|
||||||
it 'verify json parsing' do
|
describe 'when loading a valid json' do
|
||||||
resource = load_resource('json', 'policyfile.lock.json')
|
let (:resource) { load_resource('json', 'policyfile.lock.json') }
|
||||||
_(resource.params).wont_equal nil
|
|
||||||
_(resource.send('name')).must_equal 'demo'
|
it 'gets params as a hashmap' do
|
||||||
_(resource.send('run_list')).must_equal %w{apache2 omnibus}
|
_(resource.params).must_be_kind_of Hash
|
||||||
_(resource.send('cookbook_locks.omnibus.version')).must_equal '2.2.0'
|
end
|
||||||
|
|
||||||
|
it 'retrieves nil if a param is missing' do
|
||||||
|
_(resource.params['missing']).must_be_nil
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'retrieves params by name' do
|
||||||
|
_(resource.send('name')).must_equal 'demo'
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'retrieves an array by name' do
|
||||||
|
_(resource.send('run_list')).must_equal %w{a b}
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'doesnt resolve dot-notation names' do
|
||||||
|
_(resource.send('x.y.z')).must_be_nil
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'doesnt resolve symbol-notation names' do
|
||||||
|
_(resource.send(:'x.y.z')).must_be_nil
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue