-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathset_feature_spec.rb
More file actions
45 lines (37 loc) · 1.4 KB
/
set_feature_spec.rb
File metadata and controls
45 lines (37 loc) · 1.4 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# frozen_string_literal: true
require 'spec_helper'
require 'bolt/executor'
require 'bolt/inventory'
describe 'set_feature' do
let(:executor) { Bolt::Executor.new }
let(:inventory) { Bolt::Inventory.empty }
let(:target) { inventory.get_target('example') }
let(:tasks_enabled) { true }
let(:feature) { 'feature' }
around(:each) do |example|
Puppet[:tasks] = tasks_enabled
Puppet.override(bolt_executor: executor, bolt_inventory: inventory) do
example.run
end
end
it 'should set a variable on a target' do
is_expected.to run.with_params(target, feature, true).and_return(target)
expect(target.features).to include(feature)
end
it 'errors when passed invalid data types' do
is_expected.to run.with_params(target, 1, 'one')
.and_raise_error(ArgumentError,
"'set_feature' parameter 'feature' expects a String value, got Integer")
end
it 'reports the call to analytics' do
executor.expects(:report_function_call).with('set_feature')
is_expected.to run.with_params(target, feature, true).and_return(target)
end
context 'without tasks enabled' do
let(:tasks_enabled) { false }
it 'fails and reports that set_feature is not available' do
is_expected.to run
.with_params(target, feature, true).and_raise_error(/Plan language function 'set_feature' cannot be used/)
end
end
end