introduce create_ini_settings
create_ini_settings is a function that allows you to create
ini_setting resources from a simple hash:
$settings = { section1 => {
setting1 => val1
},
section2 => {
setting2 => val2,
setting3 => {
ensure => absent
}
}
}
$defaults = {
path => '/tmp/foo.ini'
}
create_ini_settings($settings,$defaults)
Will create the following resources
ini_setting{'[section1] setting1':
ensure => present,
section => 'section1',
setting => 'setting1',
value => 'val1',
path => '/tmp/foo.ini',
}
ini_setting{'[section2] setting2':
ensure => present,
section => 'section2',
setting => 'setting2',
value => 'val2',
path => '/tmp/foo.ini',
}
ini_setting{'[section2] setting3':
ensure => absent,
section => 'section2',
setting => 'setting3',
path => '/tmp/foo.ini',
}
This allows one to create much easier classes
that should be able to manage an arbritary set of
ini-style settings without having to specify each
one of them.
2014-10-04 15:41:13 +02:00
|
|
|
require 'spec_helper'
|
|
|
|
# end-to-end test of the create_init_settings function
|
|
|
|
describe 'create_ini_settings_test' do
|
|
|
|
it { should have_ini_setting_resource_count(3) }
|
2016-02-04 15:09:10 +01:00
|
|
|
it { should contain_ini_setting('/tmp/foo.ini section1 setting1').with(
|
introduce create_ini_settings
create_ini_settings is a function that allows you to create
ini_setting resources from a simple hash:
$settings = { section1 => {
setting1 => val1
},
section2 => {
setting2 => val2,
setting3 => {
ensure => absent
}
}
}
$defaults = {
path => '/tmp/foo.ini'
}
create_ini_settings($settings,$defaults)
Will create the following resources
ini_setting{'[section1] setting1':
ensure => present,
section => 'section1',
setting => 'setting1',
value => 'val1',
path => '/tmp/foo.ini',
}
ini_setting{'[section2] setting2':
ensure => present,
section => 'section2',
setting => 'setting2',
value => 'val2',
path => '/tmp/foo.ini',
}
ini_setting{'[section2] setting3':
ensure => absent,
section => 'section2',
setting => 'setting3',
path => '/tmp/foo.ini',
}
This allows one to create much easier classes
that should be able to manage an arbritary set of
ini-style settings without having to specify each
one of them.
2014-10-04 15:41:13 +02:00
|
|
|
:ensure => 'present',
|
|
|
|
:section => 'section1',
|
|
|
|
:setting => 'setting1',
|
|
|
|
:value => 'val1',
|
|
|
|
:path => '/tmp/foo.ini'
|
|
|
|
)}
|
2016-02-04 15:09:10 +01:00
|
|
|
it { should contain_ini_setting('/tmp/foo.ini section2 setting2').with(
|
introduce create_ini_settings
create_ini_settings is a function that allows you to create
ini_setting resources from a simple hash:
$settings = { section1 => {
setting1 => val1
},
section2 => {
setting2 => val2,
setting3 => {
ensure => absent
}
}
}
$defaults = {
path => '/tmp/foo.ini'
}
create_ini_settings($settings,$defaults)
Will create the following resources
ini_setting{'[section1] setting1':
ensure => present,
section => 'section1',
setting => 'setting1',
value => 'val1',
path => '/tmp/foo.ini',
}
ini_setting{'[section2] setting2':
ensure => present,
section => 'section2',
setting => 'setting2',
value => 'val2',
path => '/tmp/foo.ini',
}
ini_setting{'[section2] setting3':
ensure => absent,
section => 'section2',
setting => 'setting3',
path => '/tmp/foo.ini',
}
This allows one to create much easier classes
that should be able to manage an arbritary set of
ini-style settings without having to specify each
one of them.
2014-10-04 15:41:13 +02:00
|
|
|
:ensure => 'present',
|
|
|
|
:section => 'section2',
|
|
|
|
:setting => 'setting2',
|
|
|
|
:value => 'val2',
|
|
|
|
:path => '/tmp/foo.ini'
|
|
|
|
)}
|
2016-02-04 15:09:10 +01:00
|
|
|
it { should contain_ini_setting('/tmp/foo.ini section2 setting3').with(
|
introduce create_ini_settings
create_ini_settings is a function that allows you to create
ini_setting resources from a simple hash:
$settings = { section1 => {
setting1 => val1
},
section2 => {
setting2 => val2,
setting3 => {
ensure => absent
}
}
}
$defaults = {
path => '/tmp/foo.ini'
}
create_ini_settings($settings,$defaults)
Will create the following resources
ini_setting{'[section1] setting1':
ensure => present,
section => 'section1',
setting => 'setting1',
value => 'val1',
path => '/tmp/foo.ini',
}
ini_setting{'[section2] setting2':
ensure => present,
section => 'section2',
setting => 'setting2',
value => 'val2',
path => '/tmp/foo.ini',
}
ini_setting{'[section2] setting3':
ensure => absent,
section => 'section2',
setting => 'setting3',
path => '/tmp/foo.ini',
}
This allows one to create much easier classes
that should be able to manage an arbritary set of
ini-style settings without having to specify each
one of them.
2014-10-04 15:41:13 +02:00
|
|
|
:ensure => 'absent',
|
|
|
|
:section => 'section2',
|
|
|
|
:setting => 'setting3',
|
|
|
|
:path => '/tmp/foo.ini'
|
|
|
|
)}
|
|
|
|
end
|