forked from puppetlabs/puppetlabs-stdlib
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstdlib_ensure_spec.rb
More file actions
30 lines (28 loc) · 1.46 KB
/
stdlib_ensure_spec.rb
File metadata and controls
30 lines (28 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# frozen_string_literal: true
require 'spec_helper'
describe 'stdlib::ensure' do
context 'work without resource' do
it { is_expected.to run.with_params(true).and_return('present') }
it { is_expected.to run.with_params(false).and_return('absent') }
end
context 'work with service resource' do
it { is_expected.to run.with_params('present', 'service').and_return('running') }
it { is_expected.to run.with_params(true, 'service').and_return('running') }
it { is_expected.to run.with_params('absent', 'service').and_return('stopped') }
it { is_expected.to run.with_params(false, 'service').and_return('stopped') }
end
['directory', 'link', 'mounted', 'file'].each do |resource|
context "work with #{resource} resource" do
it { is_expected.to run.with_params('present', resource).and_return(resource) }
it { is_expected.to run.with_params(true, resource).and_return(resource) }
it { is_expected.to run.with_params('absent', resource).and_return('absent') }
it { is_expected.to run.with_params(false, resource).and_return('absent') }
end
end
context 'work with package resource' do
it { is_expected.to run.with_params('present', 'package').and_return('installed') }
it { is_expected.to run.with_params(true, 'package').and_return('installed') }
it { is_expected.to run.with_params('absent', 'package').and_return('absent') }
it { is_expected.to run.with_params(false, 'package').and_return('absent') }
end
end