Skip to content

Commit af234cc

Browse files
b4ldrekohl
andcommitted
Update spec/functions/stdlib_ensure_spec.rb
Co-authored-by: Ewoud Kohl van Wijngaarden <ewoud@kohlvanwijngaarden.nl>
1 parent ade72a1 commit af234cc

2 files changed

Lines changed: 3 additions & 4 deletions

File tree

functions/ensure.pp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# @return [String]
44
function stdlib::ensure(
55
Variant[Boolean, Enum['present', 'absent']] $ensure,
6-
Enum['present', 'directory', 'link', 'mounted', 'service', 'file', 'package'] $resource = 'present',
6+
Optional[Enum['directory', 'link', 'mounted', 'service', 'file', 'package']] $resource = undef,
77
) >> String {
88
$_ensure = $ensure ? {
99
Boolean => $ensure.bool2str('present', 'absent'),
@@ -22,6 +22,7 @@ function stdlib::ensure(
2222
default => 'stopped',
2323
}
2424
}
25+
undef: { $_ensure }
2526
default: {
2627
$_ensure ? {
2728
'present' => $resource,

spec/functions/stdlib_ensure_spec.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@
33
require 'spec_helper'
44

55
describe 'stdlib::ensure' do
6-
context 'work with generi resource' do
6+
context 'work with generic resource' do
77
it { is_expected.to run.with_params(true).and_return('present') }
88
it { is_expected.to run.with_params(false).and_return('absent') }
9-
it { is_expected.to run.with_params(true, 'present').and_return('present') }
10-
it { is_expected.to run.with_params(false, 'present').and_return('absent') }
119
end
1210
context 'work with service resource' do
1311
it { is_expected.to run.with_params('present', 'service').and_return('running') }

0 commit comments

Comments
 (0)