chef-utils 18.0.172 → 18.0.185
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +201 -201
- data/Rakefile +15 -15
- data/chef-utils.gemspec +50 -50
- data/lib/chef-utils/dist.rb +154 -154
- data/lib/chef-utils/dsl/architecture.rb +150 -150
- data/lib/chef-utils/dsl/cloud.rb +155 -155
- data/lib/chef-utils/dsl/default_paths.rb +60 -60
- data/lib/chef-utils/dsl/introspection.rb +134 -134
- data/lib/chef-utils/dsl/os.rb +58 -58
- data/lib/chef-utils/dsl/path_sanity.rb +39 -39
- data/lib/chef-utils/dsl/platform.rb +387 -387
- data/lib/chef-utils/dsl/platform_family.rb +360 -360
- data/lib/chef-utils/dsl/platform_version.rb +41 -41
- data/lib/chef-utils/dsl/service.rb +112 -112
- data/lib/chef-utils/dsl/train_helpers.rb +87 -87
- data/lib/chef-utils/dsl/virtualization.rb +272 -272
- data/lib/chef-utils/dsl/which.rb +123 -123
- data/lib/chef-utils/dsl/windows.rb +86 -86
- data/lib/chef-utils/internal.rb +114 -114
- data/lib/chef-utils/mash.rb +263 -263
- data/lib/chef-utils/parallel_map.rb +131 -131
- data/lib/chef-utils/version.rb +20 -20
- data/lib/chef-utils/version_string.rb +160 -160
- data/lib/chef-utils.rb +53 -53
- data/spec/spec_helper.rb +100 -100
- data/spec/unit/dsl/architecture_spec.rb +151 -151
- data/spec/unit/dsl/cloud_spec.rb +93 -93
- data/spec/unit/dsl/dsl_spec.rb +34 -34
- data/spec/unit/dsl/introspection_spec.rb +201 -201
- data/spec/unit/dsl/os_spec.rb +175 -175
- data/spec/unit/dsl/path_sanity_spec.rb +86 -86
- data/spec/unit/dsl/platform_family_spec.rb +235 -235
- data/spec/unit/dsl/platform_spec.rb +252 -252
- data/spec/unit/dsl/service_spec.rb +117 -117
- data/spec/unit/dsl/virtualization_spec.rb +75 -75
- data/spec/unit/dsl/which_spec.rb +171 -171
- data/spec/unit/dsl/windows_spec.rb +84 -84
- data/spec/unit/mash_spec.rb +51 -51
- data/spec/unit/parallel_map_spec.rb +156 -156
- metadata +7 -7
data/spec/unit/dsl/os_spec.rb
CHANGED
@@ -1,175 +1,175 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
#
|
3
|
-
# Copyright:: Copyright (c) Chef Software Inc.
|
4
|
-
# License:: Apache License, Version 2.0
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
#
|
18
|
-
|
19
|
-
require "spec_helper"
|
20
|
-
require "fauxhai"
|
21
|
-
|
22
|
-
def os_reports_true_for(*args)
|
23
|
-
args.each do |method|
|
24
|
-
it "reports true for #{method}" do
|
25
|
-
expect(described_class.send(method, node)).to be true
|
26
|
-
end
|
27
|
-
end
|
28
|
-
(OS_HELPERS - args).each do |method|
|
29
|
-
it "reports false for #{method}" do
|
30
|
-
expect(described_class.send(method, node)).to be false
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
RSpec.describe ChefUtils::DSL::OS do
|
36
|
-
let(:node) { Fauxhai.mock(options).data }
|
37
|
-
|
38
|
-
( HELPER_MODULES - [ described_class ] ).each do |klass|
|
39
|
-
it "does not have methods that collide with #{klass}" do
|
40
|
-
expect((klass.methods - Module.methods) & OS_HELPERS).to be_empty
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
OS_HELPERS.each do |helper|
|
45
|
-
it "has the #{helper} in the ChefUtils module" do
|
46
|
-
expect(ChefUtils).to respond_to(helper)
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
context "on ubuntu" do
|
51
|
-
let(:options) { { platform: "ubuntu" } }
|
52
|
-
|
53
|
-
os_reports_true_for(:linux?)
|
54
|
-
end
|
55
|
-
|
56
|
-
context "on raspbian" do
|
57
|
-
let(:options) { { platform: "raspbian" } }
|
58
|
-
|
59
|
-
os_reports_true_for(:linux?)
|
60
|
-
end
|
61
|
-
|
62
|
-
context "on linuxmint" do
|
63
|
-
let(:options) { { platform: "linuxmint" } }
|
64
|
-
|
65
|
-
os_reports_true_for(:linux?)
|
66
|
-
end
|
67
|
-
|
68
|
-
context "on debian" do
|
69
|
-
let(:options) { { platform: "debian" } }
|
70
|
-
|
71
|
-
os_reports_true_for(:linux?)
|
72
|
-
end
|
73
|
-
|
74
|
-
context "on amazon" do
|
75
|
-
let(:options) { { platform: "amazon" } }
|
76
|
-
|
77
|
-
os_reports_true_for(:linux?)
|
78
|
-
end
|
79
|
-
|
80
|
-
context "on arch" do
|
81
|
-
let(:options) { { platform: "arch" } }
|
82
|
-
|
83
|
-
os_reports_true_for(:linux?)
|
84
|
-
end
|
85
|
-
|
86
|
-
context "on centos" do
|
87
|
-
let(:options) { { platform: "centos" } }
|
88
|
-
|
89
|
-
os_reports_true_for(:linux?)
|
90
|
-
end
|
91
|
-
|
92
|
-
context "on clearos" do
|
93
|
-
let(:options) { { platform: "clearos" } }
|
94
|
-
|
95
|
-
os_reports_true_for(:linux?)
|
96
|
-
end
|
97
|
-
|
98
|
-
context "on dragonfly4" do
|
99
|
-
let(:options) { { platform: "dragonfly4" } }
|
100
|
-
|
101
|
-
os_reports_true_for
|
102
|
-
end
|
103
|
-
|
104
|
-
context "on fedora" do
|
105
|
-
let(:options) { { platform: "fedora" } }
|
106
|
-
|
107
|
-
os_reports_true_for(:linux?)
|
108
|
-
end
|
109
|
-
|
110
|
-
context "on freebsd" do
|
111
|
-
let(:options) { { platform: "freebsd" } }
|
112
|
-
|
113
|
-
os_reports_true_for
|
114
|
-
end
|
115
|
-
|
116
|
-
context "on gentoo" do
|
117
|
-
let(:options) { { platform: "gentoo" } }
|
118
|
-
|
119
|
-
os_reports_true_for(:linux?)
|
120
|
-
end
|
121
|
-
|
122
|
-
context "on mac_os_x" do
|
123
|
-
let(:options) { { platform: "mac_os_x" } }
|
124
|
-
|
125
|
-
os_reports_true_for(:darwin?)
|
126
|
-
end
|
127
|
-
|
128
|
-
context "on openbsd" do
|
129
|
-
let(:options) { { platform: "openbsd" } }
|
130
|
-
|
131
|
-
os_reports_true_for
|
132
|
-
end
|
133
|
-
|
134
|
-
context "on opensuse" do
|
135
|
-
let(:options) { { platform: "opensuse" } }
|
136
|
-
|
137
|
-
os_reports_true_for(:linux?)
|
138
|
-
end
|
139
|
-
|
140
|
-
context "on oracle" do
|
141
|
-
let(:options) { { platform: "oracle" } }
|
142
|
-
|
143
|
-
os_reports_true_for(:linux?)
|
144
|
-
end
|
145
|
-
|
146
|
-
context "on redhat" do
|
147
|
-
let(:options) { { platform: "redhat" } }
|
148
|
-
|
149
|
-
os_reports_true_for(:linux?)
|
150
|
-
end
|
151
|
-
|
152
|
-
context "on smartos" do
|
153
|
-
let(:options) { { platform: "smartos" } }
|
154
|
-
|
155
|
-
os_reports_true_for
|
156
|
-
end
|
157
|
-
|
158
|
-
context "on solaris2" do
|
159
|
-
let(:options) { { platform: "solaris2" } }
|
160
|
-
|
161
|
-
os_reports_true_for
|
162
|
-
end
|
163
|
-
|
164
|
-
context "on suse" do
|
165
|
-
let(:options) { { platform: "suse" } }
|
166
|
-
|
167
|
-
os_reports_true_for(:linux?)
|
168
|
-
end
|
169
|
-
|
170
|
-
context "on windows" do
|
171
|
-
let(:options) { { platform: "windows" } }
|
172
|
-
|
173
|
-
os_reports_true_for
|
174
|
-
end
|
175
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
#
|
3
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
require "spec_helper"
|
20
|
+
require "fauxhai"
|
21
|
+
|
22
|
+
def os_reports_true_for(*args)
|
23
|
+
args.each do |method|
|
24
|
+
it "reports true for #{method}" do
|
25
|
+
expect(described_class.send(method, node)).to be true
|
26
|
+
end
|
27
|
+
end
|
28
|
+
(OS_HELPERS - args).each do |method|
|
29
|
+
it "reports false for #{method}" do
|
30
|
+
expect(described_class.send(method, node)).to be false
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
RSpec.describe ChefUtils::DSL::OS do
|
36
|
+
let(:node) { Fauxhai.mock(options).data }
|
37
|
+
|
38
|
+
( HELPER_MODULES - [ described_class ] ).each do |klass|
|
39
|
+
it "does not have methods that collide with #{klass}" do
|
40
|
+
expect((klass.methods - Module.methods) & OS_HELPERS).to be_empty
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
OS_HELPERS.each do |helper|
|
45
|
+
it "has the #{helper} in the ChefUtils module" do
|
46
|
+
expect(ChefUtils).to respond_to(helper)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
context "on ubuntu" do
|
51
|
+
let(:options) { { platform: "ubuntu" } }
|
52
|
+
|
53
|
+
os_reports_true_for(:linux?)
|
54
|
+
end
|
55
|
+
|
56
|
+
context "on raspbian" do
|
57
|
+
let(:options) { { platform: "raspbian" } }
|
58
|
+
|
59
|
+
os_reports_true_for(:linux?)
|
60
|
+
end
|
61
|
+
|
62
|
+
context "on linuxmint" do
|
63
|
+
let(:options) { { platform: "linuxmint" } }
|
64
|
+
|
65
|
+
os_reports_true_for(:linux?)
|
66
|
+
end
|
67
|
+
|
68
|
+
context "on debian" do
|
69
|
+
let(:options) { { platform: "debian" } }
|
70
|
+
|
71
|
+
os_reports_true_for(:linux?)
|
72
|
+
end
|
73
|
+
|
74
|
+
context "on amazon" do
|
75
|
+
let(:options) { { platform: "amazon" } }
|
76
|
+
|
77
|
+
os_reports_true_for(:linux?)
|
78
|
+
end
|
79
|
+
|
80
|
+
context "on arch" do
|
81
|
+
let(:options) { { platform: "arch" } }
|
82
|
+
|
83
|
+
os_reports_true_for(:linux?)
|
84
|
+
end
|
85
|
+
|
86
|
+
context "on centos" do
|
87
|
+
let(:options) { { platform: "centos" } }
|
88
|
+
|
89
|
+
os_reports_true_for(:linux?)
|
90
|
+
end
|
91
|
+
|
92
|
+
context "on clearos" do
|
93
|
+
let(:options) { { platform: "clearos" } }
|
94
|
+
|
95
|
+
os_reports_true_for(:linux?)
|
96
|
+
end
|
97
|
+
|
98
|
+
context "on dragonfly4" do
|
99
|
+
let(:options) { { platform: "dragonfly4" } }
|
100
|
+
|
101
|
+
os_reports_true_for
|
102
|
+
end
|
103
|
+
|
104
|
+
context "on fedora" do
|
105
|
+
let(:options) { { platform: "fedora" } }
|
106
|
+
|
107
|
+
os_reports_true_for(:linux?)
|
108
|
+
end
|
109
|
+
|
110
|
+
context "on freebsd" do
|
111
|
+
let(:options) { { platform: "freebsd" } }
|
112
|
+
|
113
|
+
os_reports_true_for
|
114
|
+
end
|
115
|
+
|
116
|
+
context "on gentoo" do
|
117
|
+
let(:options) { { platform: "gentoo" } }
|
118
|
+
|
119
|
+
os_reports_true_for(:linux?)
|
120
|
+
end
|
121
|
+
|
122
|
+
context "on mac_os_x" do
|
123
|
+
let(:options) { { platform: "mac_os_x" } }
|
124
|
+
|
125
|
+
os_reports_true_for(:darwin?)
|
126
|
+
end
|
127
|
+
|
128
|
+
context "on openbsd" do
|
129
|
+
let(:options) { { platform: "openbsd" } }
|
130
|
+
|
131
|
+
os_reports_true_for
|
132
|
+
end
|
133
|
+
|
134
|
+
context "on opensuse" do
|
135
|
+
let(:options) { { platform: "opensuse" } }
|
136
|
+
|
137
|
+
os_reports_true_for(:linux?)
|
138
|
+
end
|
139
|
+
|
140
|
+
context "on oracle" do
|
141
|
+
let(:options) { { platform: "oracle" } }
|
142
|
+
|
143
|
+
os_reports_true_for(:linux?)
|
144
|
+
end
|
145
|
+
|
146
|
+
context "on redhat" do
|
147
|
+
let(:options) { { platform: "redhat" } }
|
148
|
+
|
149
|
+
os_reports_true_for(:linux?)
|
150
|
+
end
|
151
|
+
|
152
|
+
context "on smartos" do
|
153
|
+
let(:options) { { platform: "smartos" } }
|
154
|
+
|
155
|
+
os_reports_true_for
|
156
|
+
end
|
157
|
+
|
158
|
+
context "on solaris2" do
|
159
|
+
let(:options) { { platform: "solaris2" } }
|
160
|
+
|
161
|
+
os_reports_true_for
|
162
|
+
end
|
163
|
+
|
164
|
+
context "on suse" do
|
165
|
+
let(:options) { { platform: "suse" } }
|
166
|
+
|
167
|
+
os_reports_true_for(:linux?)
|
168
|
+
end
|
169
|
+
|
170
|
+
context "on windows" do
|
171
|
+
let(:options) { { platform: "windows" } }
|
172
|
+
|
173
|
+
os_reports_true_for
|
174
|
+
end
|
175
|
+
end
|
@@ -1,86 +1,86 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
#
|
3
|
-
# Copyright:: Copyright (c) Chef Software Inc.
|
4
|
-
# License:: Apache License, Version 2.0
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
#
|
18
|
-
|
19
|
-
require "spec_helper"
|
20
|
-
|
21
|
-
RSpec.describe ChefUtils::DSL::DefaultPaths do
|
22
|
-
class DefaultPathsTestClass
|
23
|
-
include ChefUtils::DSL::DefaultPaths
|
24
|
-
end
|
25
|
-
|
26
|
-
before do
|
27
|
-
allow(Gem).to receive(:bindir).and_return("/opt/ruby/bin/bundle")
|
28
|
-
allow(RbConfig::CONFIG).to receive(:[]).with("bindir").and_return("/opt/ruby/bin")
|
29
|
-
end
|
30
|
-
|
31
|
-
context "on unix" do
|
32
|
-
before do
|
33
|
-
allow(ChefUtils).to receive(:windows?).and_return(false)
|
34
|
-
end
|
35
|
-
|
36
|
-
let(:test_instance) { DefaultPathsTestClass.new }
|
37
|
-
|
38
|
-
it "works with no path" do
|
39
|
-
env = {}
|
40
|
-
expect(test_instance.default_paths(env)).to eql("#{Gem.bindir}:#{RbConfig::CONFIG["bindir"]}:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin")
|
41
|
-
end
|
42
|
-
|
43
|
-
it "works with nil path" do
|
44
|
-
env = { "PATH" => nil }
|
45
|
-
expect(test_instance.default_paths(env)).to eql("#{Gem.bindir}:#{RbConfig::CONFIG["bindir"]}:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin")
|
46
|
-
end
|
47
|
-
|
48
|
-
it "works with empty path" do
|
49
|
-
env = { "PATH" => "" }
|
50
|
-
expect(test_instance.default_paths(env)).to eql("#{Gem.bindir}:#{RbConfig::CONFIG["bindir"]}:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin")
|
51
|
-
end
|
52
|
-
|
53
|
-
it "appends the default_paths to the end of the path, preserving any that already exist, in the same order" do
|
54
|
-
env = { "PATH" => "/bin:/opt/app/bin:/sbin" }
|
55
|
-
expect(test_instance.default_paths(env)).to eql("#{Gem.bindir}:#{RbConfig::CONFIG["bindir"]}:/bin:/opt/app/bin:/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin")
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
context "on windows" do
|
60
|
-
before do
|
61
|
-
allow(ChefUtils).to receive(:windows?).and_return(true)
|
62
|
-
end
|
63
|
-
|
64
|
-
let(:test_instance) { DefaultPathsTestClass.new }
|
65
|
-
|
66
|
-
it "works with no path" do
|
67
|
-
env = {}
|
68
|
-
expect(test_instance.default_paths(env)).to eql("#{Gem.bindir};#{RbConfig::CONFIG["bindir"]}")
|
69
|
-
end
|
70
|
-
|
71
|
-
it "works with nil path" do
|
72
|
-
env = { "PATH" => nil }
|
73
|
-
expect(test_instance.default_paths(env)).to eql("#{Gem.bindir};#{RbConfig::CONFIG["bindir"]}")
|
74
|
-
end
|
75
|
-
|
76
|
-
it "works with empty path" do
|
77
|
-
env = { "PATH" => "" }
|
78
|
-
expect(test_instance.default_paths(env)).to eql("#{Gem.bindir};#{RbConfig::CONFIG["bindir"]}")
|
79
|
-
end
|
80
|
-
|
81
|
-
it "prepends to an existing path" do
|
82
|
-
env = { "PATH" => "%SystemRoot%\\system32;%SystemRoot%;%SystemRoot%\\System32\\Wbem;%SYSTEMROOT%\\System32\\WindowsPowerShell\\v1.0\\" }
|
83
|
-
expect(test_instance.default_paths(env)).to eql("#{Gem.bindir};#{RbConfig::CONFIG["bindir"]};%SystemRoot%\\system32;%SystemRoot%;%SystemRoot%\\System32\\Wbem;%SYSTEMROOT%\\System32\\WindowsPowerShell\\v1.0\\")
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
#
|
3
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
require "spec_helper"
|
20
|
+
|
21
|
+
RSpec.describe ChefUtils::DSL::DefaultPaths do
|
22
|
+
class DefaultPathsTestClass
|
23
|
+
include ChefUtils::DSL::DefaultPaths
|
24
|
+
end
|
25
|
+
|
26
|
+
before do
|
27
|
+
allow(Gem).to receive(:bindir).and_return("/opt/ruby/bin/bundle")
|
28
|
+
allow(RbConfig::CONFIG).to receive(:[]).with("bindir").and_return("/opt/ruby/bin")
|
29
|
+
end
|
30
|
+
|
31
|
+
context "on unix" do
|
32
|
+
before do
|
33
|
+
allow(ChefUtils).to receive(:windows?).and_return(false)
|
34
|
+
end
|
35
|
+
|
36
|
+
let(:test_instance) { DefaultPathsTestClass.new }
|
37
|
+
|
38
|
+
it "works with no path" do
|
39
|
+
env = {}
|
40
|
+
expect(test_instance.default_paths(env)).to eql("#{Gem.bindir}:#{RbConfig::CONFIG["bindir"]}:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin")
|
41
|
+
end
|
42
|
+
|
43
|
+
it "works with nil path" do
|
44
|
+
env = { "PATH" => nil }
|
45
|
+
expect(test_instance.default_paths(env)).to eql("#{Gem.bindir}:#{RbConfig::CONFIG["bindir"]}:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin")
|
46
|
+
end
|
47
|
+
|
48
|
+
it "works with empty path" do
|
49
|
+
env = { "PATH" => "" }
|
50
|
+
expect(test_instance.default_paths(env)).to eql("#{Gem.bindir}:#{RbConfig::CONFIG["bindir"]}:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin")
|
51
|
+
end
|
52
|
+
|
53
|
+
it "appends the default_paths to the end of the path, preserving any that already exist, in the same order" do
|
54
|
+
env = { "PATH" => "/bin:/opt/app/bin:/sbin" }
|
55
|
+
expect(test_instance.default_paths(env)).to eql("#{Gem.bindir}:#{RbConfig::CONFIG["bindir"]}:/bin:/opt/app/bin:/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin")
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
context "on windows" do
|
60
|
+
before do
|
61
|
+
allow(ChefUtils).to receive(:windows?).and_return(true)
|
62
|
+
end
|
63
|
+
|
64
|
+
let(:test_instance) { DefaultPathsTestClass.new }
|
65
|
+
|
66
|
+
it "works with no path" do
|
67
|
+
env = {}
|
68
|
+
expect(test_instance.default_paths(env)).to eql("#{Gem.bindir};#{RbConfig::CONFIG["bindir"]}")
|
69
|
+
end
|
70
|
+
|
71
|
+
it "works with nil path" do
|
72
|
+
env = { "PATH" => nil }
|
73
|
+
expect(test_instance.default_paths(env)).to eql("#{Gem.bindir};#{RbConfig::CONFIG["bindir"]}")
|
74
|
+
end
|
75
|
+
|
76
|
+
it "works with empty path" do
|
77
|
+
env = { "PATH" => "" }
|
78
|
+
expect(test_instance.default_paths(env)).to eql("#{Gem.bindir};#{RbConfig::CONFIG["bindir"]}")
|
79
|
+
end
|
80
|
+
|
81
|
+
it "prepends to an existing path" do
|
82
|
+
env = { "PATH" => "%SystemRoot%\\system32;%SystemRoot%;%SystemRoot%\\System32\\Wbem;%SYSTEMROOT%\\System32\\WindowsPowerShell\\v1.0\\" }
|
83
|
+
expect(test_instance.default_paths(env)).to eql("#{Gem.bindir};#{RbConfig::CONFIG["bindir"]};%SystemRoot%\\system32;%SystemRoot%;%SystemRoot%\\System32\\Wbem;%SYSTEMROOT%\\System32\\WindowsPowerShell\\v1.0\\")
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|