chef-config 12.6.0 → 12.7.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +5 -6
- data/chef-config.gemspec +5 -5
- data/lib/chef-config.rb +1 -1
- data/lib/chef-config/config.rb +136 -71
- data/lib/chef-config/exceptions.rb +3 -3
- data/lib/chef-config/logger.rb +1 -4
- data/lib/chef-config/package_task.rb +27 -28
- data/lib/chef-config/path_helper.rb +28 -28
- data/lib/chef-config/version.rb +2 -2
- data/lib/chef-config/windows.rb +1 -2
- data/lib/chef-config/workstation_config_loader.rb +22 -23
- data/spec/spec_helper.rb +2 -2
- data/spec/unit/config_spec.rb +140 -37
- data/spec/unit/path_helper_spec.rb +17 -18
- data/spec/unit/workstation_config_loader_spec.rb +9 -11
- metadata +3 -3
data/spec/spec_helper.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "chef-config/windows"
|
2
2
|
|
3
3
|
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
4
4
|
RSpec.configure do |config|
|
@@ -53,7 +53,7 @@ RSpec.configure do |config|
|
|
53
53
|
# Use the documentation formatter for detailed output,
|
54
54
|
# unless a formatter has already been configured
|
55
55
|
# (e.g. via a command-line flag).
|
56
|
-
config.default_formatter =
|
56
|
+
config.default_formatter = "doc"
|
57
57
|
end
|
58
58
|
|
59
59
|
# Print the 10 slowest examples and example groups at the
|
data/spec/unit/config_spec.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#
|
2
|
-
# Author:: Adam Jacob (<adam@
|
2
|
+
# Author:: Adam Jacob (<adam@chef.io>)
|
3
3
|
# Author:: Kyle Goodwin (<kgoodwin@primerevenue.com>)
|
4
|
-
# Copyright:: Copyright
|
4
|
+
# Copyright:: Copyright 2008-2016, Chef Software Inc.
|
5
5
|
# License:: Apache License, Version 2.0
|
6
6
|
#
|
7
7
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -17,8 +17,8 @@
|
|
17
17
|
# limitations under the License.
|
18
18
|
#
|
19
19
|
|
20
|
-
require
|
21
|
-
require
|
20
|
+
require "spec_helper"
|
21
|
+
require "chef-config/config"
|
22
22
|
|
23
23
|
RSpec.describe ChefConfig::Config do
|
24
24
|
before(:each) do
|
@@ -28,7 +28,7 @@ RSpec.describe ChefConfig::Config do
|
|
28
28
|
ChefConfig::Config.treat_deprecation_warnings_as_errors(true)
|
29
29
|
|
30
30
|
# Set environment variable so the setting persists in child processes
|
31
|
-
ENV[
|
31
|
+
ENV["CHEF_TREAT_DEPRECATION_WARNINGS_AS_ERRORS"] = "1"
|
32
32
|
end
|
33
33
|
|
34
34
|
describe "config attribute writer: chef_server_url" do
|
@@ -123,7 +123,7 @@ RSpec.describe ChefConfig::Config do
|
|
123
123
|
if is_windows
|
124
124
|
it "should return a windows path on windows systems" do
|
125
125
|
path = "/etc/chef/cookbooks"
|
126
|
-
allow(ChefConfig::Config).to receive(:env).and_return({
|
126
|
+
allow(ChefConfig::Config).to receive(:env).and_return({ "SYSTEMDRIVE" => "C:" })
|
127
127
|
# match on a regex that looks for the base path with an optional
|
128
128
|
# system drive at the beginning (c:)
|
129
129
|
# system drive is not hardcoded b/c it can change and b/c it is not present on linux systems
|
@@ -156,10 +156,10 @@ RSpec.describe ChefConfig::Config do
|
|
156
156
|
|
157
157
|
before do
|
158
158
|
if is_windows
|
159
|
-
allow(ChefConfig::Config).to receive(:env).and_return({
|
159
|
+
allow(ChefConfig::Config).to receive(:env).and_return({ "SYSTEMDRIVE" => "C:" })
|
160
160
|
ChefConfig::Config[:user_home] = 'C:\Users\charlie'
|
161
161
|
else
|
162
|
-
ChefConfig::Config[:user_home] =
|
162
|
+
ChefConfig::Config[:user_home] = "/Users/charlie"
|
163
163
|
end
|
164
164
|
|
165
165
|
allow(ChefConfig::Config).to receive(:path_accessible?).and_return(false)
|
@@ -250,21 +250,21 @@ RSpec.describe ChefConfig::Config do
|
|
250
250
|
|
251
251
|
context "and config_dir is /a/b/c" do
|
252
252
|
before do
|
253
|
-
ChefConfig::Config.config_dir to_platform(
|
253
|
+
ChefConfig::Config.config_dir to_platform("/a/b/c")
|
254
254
|
end
|
255
255
|
|
256
256
|
it "cache_path is /a/b/c/local-mode-cache" do
|
257
|
-
expect(ChefConfig::Config.cache_path).to eq(to_platform(
|
257
|
+
expect(ChefConfig::Config.cache_path).to eq(to_platform("/a/b/c/local-mode-cache"))
|
258
258
|
end
|
259
259
|
end
|
260
260
|
|
261
261
|
context "and config_dir is /a/b/c/" do
|
262
262
|
before do
|
263
|
-
ChefConfig::Config.config_dir to_platform(
|
263
|
+
ChefConfig::Config.config_dir to_platform("/a/b/c/")
|
264
264
|
end
|
265
265
|
|
266
266
|
it "cache_path is /a/b/c/local-mode-cache" do
|
267
|
-
expect(ChefConfig::Config.cache_path).to eq(to_platform(
|
267
|
+
expect(ChefConfig::Config.cache_path).to eq(to_platform("/a/b/c/local-mode-cache"))
|
268
268
|
end
|
269
269
|
end
|
270
270
|
end
|
@@ -288,6 +288,104 @@ RSpec.describe ChefConfig::Config do
|
|
288
288
|
expect(ChefConfig::Config[:ssl_ca_path]).to be_nil
|
289
289
|
end
|
290
290
|
|
291
|
+
describe "ChefConfig::Config[:repo_mode]" do
|
292
|
+
|
293
|
+
context "when local mode is enabled" do
|
294
|
+
|
295
|
+
before { ChefConfig::Config[:local_mode] = true }
|
296
|
+
|
297
|
+
it "defaults to 'hosted_everything'" do
|
298
|
+
expect(ChefConfig::Config[:repo_mode]).to eq("hosted_everything")
|
299
|
+
end
|
300
|
+
|
301
|
+
context "and osc_compat is enabled" do
|
302
|
+
|
303
|
+
before { ChefConfig::Config.chef_zero.osc_compat = true }
|
304
|
+
|
305
|
+
it "defaults to 'everything'" do
|
306
|
+
expect(ChefConfig::Config[:repo_mode]).to eq("everything")
|
307
|
+
end
|
308
|
+
end
|
309
|
+
end
|
310
|
+
|
311
|
+
context "when local mode is not enabled" do
|
312
|
+
|
313
|
+
context "and the chef_server_url is multi-tenant" do
|
314
|
+
|
315
|
+
before { ChefConfig::Config[:chef_server_url] = "https://chef.example/organizations/example" }
|
316
|
+
|
317
|
+
it "defaults to 'hosted_everything'" do
|
318
|
+
expect(ChefConfig::Config[:repo_mode]).to eq("hosted_everything")
|
319
|
+
end
|
320
|
+
|
321
|
+
end
|
322
|
+
|
323
|
+
context "and the chef_server_url is not multi-tenant" do
|
324
|
+
|
325
|
+
before { ChefConfig::Config[:chef_server_url] = "https://chef.example/" }
|
326
|
+
|
327
|
+
it "defaults to 'everything'" do
|
328
|
+
expect(ChefConfig::Config[:repo_mode]).to eq("everything")
|
329
|
+
end
|
330
|
+
end
|
331
|
+
end
|
332
|
+
end
|
333
|
+
|
334
|
+
describe "ChefConfig::Config[:chef_repo_path]" do
|
335
|
+
|
336
|
+
context "when cookbook_path is set to a single path" do
|
337
|
+
|
338
|
+
before { ChefConfig::Config[:cookbook_path] = "/home/anne/repo/cookbooks" }
|
339
|
+
|
340
|
+
it "is set to a path one directory up from the cookbook_path" do
|
341
|
+
expected = File.expand_path("/home/anne/repo")
|
342
|
+
expect(ChefConfig::Config[:chef_repo_path]).to eq(expected)
|
343
|
+
end
|
344
|
+
|
345
|
+
end
|
346
|
+
|
347
|
+
context "when cookbook_path is set to multiple paths" do
|
348
|
+
|
349
|
+
before do
|
350
|
+
ChefConfig::Config[:cookbook_path] = [
|
351
|
+
"/home/anne/repo/cookbooks",
|
352
|
+
"/home/anne/other_repo/cookbooks",
|
353
|
+
]
|
354
|
+
end
|
355
|
+
|
356
|
+
it "is set to an Array of paths one directory up from the cookbook_paths" do
|
357
|
+
expected = [ "/home/anne/repo", "/home/anne/other_repo"].map { |p| File.expand_path(p) }
|
358
|
+
expect(ChefConfig::Config[:chef_repo_path]).to eq(expected)
|
359
|
+
end
|
360
|
+
|
361
|
+
end
|
362
|
+
|
363
|
+
context "when cookbook_path is not set but cookbook_artifact_path is set" do
|
364
|
+
|
365
|
+
before do
|
366
|
+
ChefConfig::Config[:cookbook_path] = nil
|
367
|
+
ChefConfig::Config[:cookbook_artifact_path] = "/home/roxie/repo/cookbook_artifacts"
|
368
|
+
end
|
369
|
+
|
370
|
+
it "is set to a path one directory up from the cookbook_artifact_path" do
|
371
|
+
expected = File.expand_path("/home/roxie/repo")
|
372
|
+
expect(ChefConfig::Config[:chef_repo_path]).to eq(expected)
|
373
|
+
end
|
374
|
+
|
375
|
+
end
|
376
|
+
|
377
|
+
context "when cookbook_path is not set" do
|
378
|
+
|
379
|
+
before { ChefConfig::Config[:cookbook_path] = nil }
|
380
|
+
|
381
|
+
it "is set to the cache_path" do
|
382
|
+
expect(ChefConfig::Config[:chef_repo_path]).to eq(ChefConfig::Config[:cache_path])
|
383
|
+
end
|
384
|
+
|
385
|
+
end
|
386
|
+
|
387
|
+
end
|
388
|
+
|
291
389
|
# On Windows, we'll detect an omnibus build and set this to the
|
292
390
|
# cacert.pem included in the package, but it's nil if you're on Windows
|
293
391
|
# w/o omnibus (e.g., doing development on Windows, custom build, etc.)
|
@@ -309,6 +407,12 @@ RSpec.describe ChefConfig::Config do
|
|
309
407
|
expect(ChefConfig::Config[:environment_path]).to eq(environment_path)
|
310
408
|
end
|
311
409
|
|
410
|
+
it "ChefConfig::Config[:cookbook_artifact_path] defaults to /var/chef/cookbook_artifacts" do
|
411
|
+
allow(ChefConfig::Config).to receive(:cache_path).and_return(primary_cache_path)
|
412
|
+
environment_path = is_windows ? "#{primary_cache_path}\\cookbook_artifacts" : "#{primary_cache_path}/cookbook_artifacts"
|
413
|
+
expect(ChefConfig::Config[:cookbook_artifact_path]).to eq(environment_path)
|
414
|
+
end
|
415
|
+
|
312
416
|
describe "setting the config dir" do
|
313
417
|
|
314
418
|
context "when the config file is given with a relative path" do
|
@@ -326,7 +430,7 @@ RSpec.describe ChefConfig::Config do
|
|
326
430
|
|
327
431
|
it "does not set derived paths at FS root" do
|
328
432
|
ChefConfig::Config.local_mode = true
|
329
|
-
expect(ChefConfig::Config.cache_path.downcase).to eq(to_platform(File.join(Dir.pwd,
|
433
|
+
expect(ChefConfig::Config.cache_path.downcase).to eq(to_platform(File.join(Dir.pwd, "local-mode-cache")).downcase)
|
330
434
|
end
|
331
435
|
|
332
436
|
end
|
@@ -371,7 +475,7 @@ RSpec.describe ChefConfig::Config do
|
|
371
475
|
end
|
372
476
|
|
373
477
|
it "config_dir is /home/charlie/.chef/" do
|
374
|
-
expect(ChefConfig::Config.config_dir).to eq(ChefConfig::PathHelper.join(to_platform("/home/charlie/.chef"),
|
478
|
+
expect(ChefConfig::Config.config_dir).to eq(ChefConfig::PathHelper.join(to_platform("/home/charlie/.chef"), ""))
|
375
479
|
end
|
376
480
|
|
377
481
|
context "and chef is running in local mode" do
|
@@ -380,7 +484,7 @@ RSpec.describe ChefConfig::Config do
|
|
380
484
|
end
|
381
485
|
|
382
486
|
it "config_dir is /home/charlie/.chef/" do
|
383
|
-
expect(ChefConfig::Config.config_dir).to eq(ChefConfig::PathHelper.join(to_platform("/home/charlie/.chef"),
|
487
|
+
expect(ChefConfig::Config.config_dir).to eq(ChefConfig::PathHelper.join(to_platform("/home/charlie/.chef"), ""))
|
384
488
|
end
|
385
489
|
end
|
386
490
|
end
|
@@ -433,7 +537,7 @@ RSpec.describe ChefConfig::Config do
|
|
433
537
|
end
|
434
538
|
|
435
539
|
describe "ChefConfig::Config[:encrypted_data_bag_secret]" do
|
436
|
-
let(:db_secret_default_path){ to_platform("/etc/chef/encrypted_data_bag_secret") }
|
540
|
+
let(:db_secret_default_path) { to_platform("/etc/chef/encrypted_data_bag_secret") }
|
437
541
|
|
438
542
|
before do
|
439
543
|
allow(File).to receive(:exist?).with(db_secret_default_path).and_return(secret_exists)
|
@@ -468,7 +572,7 @@ RSpec.describe ChefConfig::Config do
|
|
468
572
|
describe "ChefConfig::Config[:user_valid_regex]" do
|
469
573
|
context "on a platform that is not Windows" do
|
470
574
|
it "allows one letter usernames" do
|
471
|
-
any_match = ChefConfig::Config[:user_valid_regex].any? { |regex| regex.match(
|
575
|
+
any_match = ChefConfig::Config[:user_valid_regex].any? { |regex| regex.match("a") }
|
472
576
|
expect(any_match).to be_truthy
|
473
577
|
end
|
474
578
|
end
|
@@ -543,7 +647,7 @@ RSpec.describe ChefConfig::Config do
|
|
543
647
|
|
544
648
|
it "should fall back to C locale" do
|
545
649
|
expect(ChefConfig.logger).to receive(:warn).with("Please install an English UTF-8 locale for Chef to use, falling back to C locale and disabling UTF-8 support.")
|
546
|
-
expect(ChefConfig::Config.guess_internal_locale).to eq
|
650
|
+
expect(ChefConfig::Config.guess_internal_locale).to eq "C"
|
547
651
|
end
|
548
652
|
end
|
549
653
|
|
@@ -585,8 +689,8 @@ RSpec.describe ChefConfig::Config do
|
|
585
689
|
ChefConfig::Config.http_proxy_pass = proxy_pass
|
586
690
|
end
|
587
691
|
it "exports ENV['http_proxy']" do
|
588
|
-
expect(ENV).to receive(:[]=).with(
|
589
|
-
expect(ENV).to receive(:[]=).with(
|
692
|
+
expect(ENV).to receive(:[]=).with("http_proxy", "http://http_user:http_pass@localhost:7979")
|
693
|
+
expect(ENV).to receive(:[]=).with("HTTP_PROXY", "http://http_user:http_pass@localhost:7979")
|
590
694
|
ChefConfig::Config.export_proxies
|
591
695
|
end
|
592
696
|
end
|
@@ -598,8 +702,8 @@ RSpec.describe ChefConfig::Config do
|
|
598
702
|
ChefConfig::Config.https_proxy_pass = proxy_pass
|
599
703
|
end
|
600
704
|
it "exports ENV['https_proxy']" do
|
601
|
-
expect(ENV).to receive(:[]=).with(
|
602
|
-
expect(ENV).to receive(:[]=).with(
|
705
|
+
expect(ENV).to receive(:[]=).with("https_proxy", "https://http_user:http_pass@localhost:7979")
|
706
|
+
expect(ENV).to receive(:[]=).with("HTTPS_PROXY", "https://http_user:http_pass@localhost:7979")
|
603
707
|
ChefConfig::Config.export_proxies
|
604
708
|
end
|
605
709
|
end
|
@@ -611,16 +715,16 @@ RSpec.describe ChefConfig::Config do
|
|
611
715
|
ChefConfig::Config.ftp_proxy_pass = proxy_pass
|
612
716
|
end
|
613
717
|
it "exports ENV['ftp_proxy']" do
|
614
|
-
expect(ENV).to receive(:[]=).with(
|
615
|
-
expect(ENV).to receive(:[]=).with(
|
718
|
+
expect(ENV).to receive(:[]=).with("ftp_proxy", "ftp://http_user:http_pass@localhost:7979")
|
719
|
+
expect(ENV).to receive(:[]=).with("FTP_PROXY", "ftp://http_user:http_pass@localhost:7979")
|
616
720
|
ChefConfig::Config.export_proxies
|
617
721
|
end
|
618
722
|
end
|
619
723
|
|
620
724
|
shared_examples "no user pass" do
|
621
725
|
it "does not populate the user or password" do
|
622
|
-
expect(ENV).to receive(:[]=).with(
|
623
|
-
expect(ENV).to receive(:[]=).with(
|
726
|
+
expect(ENV).to receive(:[]=).with("http_proxy", "http://localhost:7979")
|
727
|
+
expect(ENV).to receive(:[]=).with("HTTP_PROXY", "http://localhost:7979")
|
624
728
|
ChefConfig::Config.export_proxies
|
625
729
|
end
|
626
730
|
end
|
@@ -646,8 +750,8 @@ RSpec.describe ChefConfig::Config do
|
|
646
750
|
ChefConfig::Config.http_proxy = "localhost:1111"
|
647
751
|
end
|
648
752
|
it "automatically adds the scheme to the proxy url" do
|
649
|
-
expect(ENV).to receive(:[]=).with(
|
650
|
-
expect(ENV).to receive(:[]=).with(
|
753
|
+
expect(ENV).to receive(:[]=).with("http_proxy", "http://localhost:1111")
|
754
|
+
expect(ENV).to receive(:[]=).with("HTTP_PROXY", "http://localhost:1111")
|
651
755
|
ChefConfig::Config.export_proxies
|
652
756
|
end
|
653
757
|
end
|
@@ -655,10 +759,10 @@ RSpec.describe ChefConfig::Config do
|
|
655
759
|
shared_examples "no export" do
|
656
760
|
it "does not export any proxy settings" do
|
657
761
|
ChefConfig::Config.export_proxies
|
658
|
-
expect(ENV[
|
659
|
-
expect(ENV[
|
660
|
-
expect(ENV[
|
661
|
-
expect(ENV[
|
762
|
+
expect(ENV["http_proxy"]).to eq(nil)
|
763
|
+
expect(ENV["https_proxy"]).to eq(nil)
|
764
|
+
expect(ENV["ftp_proxy"]).to eq(nil)
|
765
|
+
expect(ENV["no_proxy"]).to eq(nil)
|
662
766
|
end
|
663
767
|
end
|
664
768
|
|
@@ -683,8 +787,8 @@ RSpec.describe ChefConfig::Config do
|
|
683
787
|
ChefConfig::Config.no_proxy = "localhost"
|
684
788
|
end
|
685
789
|
it "exports ENV['no_proxy']" do
|
686
|
-
expect(ENV).to receive(:[]=).with(
|
687
|
-
expect(ENV).to receive(:[]=).with(
|
790
|
+
expect(ENV).to receive(:[]=).with("no_proxy", "localhost")
|
791
|
+
expect(ENV).to receive(:[]=).with("NO_PROXY", "localhost")
|
688
792
|
ChefConfig::Config.export_proxies
|
689
793
|
end
|
690
794
|
end
|
@@ -707,7 +811,7 @@ RSpec.describe ChefConfig::Config do
|
|
707
811
|
end
|
708
812
|
|
709
813
|
it "sets CHEF_TREAT_DEPRECATION_WARNINGS_AS_ERRORS environment variable" do
|
710
|
-
expect(ENV[
|
814
|
+
expect(ENV["CHEF_TREAT_DEPRECATION_WARNINGS_AS_ERRORS"]).to eq("1")
|
711
815
|
end
|
712
816
|
|
713
817
|
it "treats deprecation warnings as errors in child processes when testing" do
|
@@ -725,7 +829,7 @@ RSpec.describe ChefConfig::Config do
|
|
725
829
|
context "outside of our test environment" do
|
726
830
|
|
727
831
|
before do
|
728
|
-
ENV.delete(
|
832
|
+
ENV.delete("CHEF_TREAT_DEPRECATION_WARNINGS_AS_ERRORS")
|
729
833
|
ChefConfig::Config.reset
|
730
834
|
end
|
731
835
|
|
@@ -734,7 +838,6 @@ RSpec.describe ChefConfig::Config do
|
|
734
838
|
end
|
735
839
|
end
|
736
840
|
|
737
|
-
|
738
841
|
end
|
739
842
|
|
740
843
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Bryan McLellan <btm@loftninjas.org>
|
3
|
-
# Copyright:: Copyright
|
3
|
+
# Copyright:: Copyright 2014-2016, Chef Software, Inc.
|
4
4
|
# License:: Apache License, Version 2.0
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -16,8 +16,8 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
|
19
|
-
require
|
20
|
-
require
|
19
|
+
require "chef-config/path_helper"
|
20
|
+
require "spec_helper"
|
21
21
|
|
22
22
|
RSpec.describe ChefConfig::PathHelper do
|
23
23
|
|
@@ -27,30 +27,30 @@ RSpec.describe ChefConfig::PathHelper do
|
|
27
27
|
describe "join" do
|
28
28
|
|
29
29
|
it "joins starting with '' resolve to absolute paths" do
|
30
|
-
expect(path_helper.join(
|
30
|
+
expect(path_helper.join("", "a", "b")).to eq("#{path_helper.path_separator}a#{path_helper.path_separator}b")
|
31
31
|
end
|
32
32
|
|
33
33
|
it "joins ending with '' add a / to the end" do
|
34
|
-
expect(path_helper.join(
|
34
|
+
expect(path_helper.join("a", "b", "")).to eq("a#{path_helper.path_separator}b#{path_helper.path_separator}")
|
35
35
|
end
|
36
36
|
|
37
37
|
end
|
38
38
|
|
39
39
|
describe "dirname" do
|
40
40
|
it "dirname('abc') is '.'" do
|
41
|
-
expect(path_helper.dirname(
|
41
|
+
expect(path_helper.dirname("abc")).to eq(".")
|
42
42
|
end
|
43
43
|
it "dirname('/') is '/'" do
|
44
44
|
expect(path_helper.dirname(path_helper.path_separator)).to eq(path_helper.path_separator)
|
45
45
|
end
|
46
46
|
it "dirname('a/b/c') is 'a/b'" do
|
47
|
-
expect(path_helper.dirname(path_helper.join(
|
47
|
+
expect(path_helper.dirname(path_helper.join("a", "b", "c"))).to eq(path_helper.join("a", "b"))
|
48
48
|
end
|
49
49
|
it "dirname('a/b/c/') is 'a/b'" do
|
50
|
-
expect(path_helper.dirname(path_helper.join(
|
50
|
+
expect(path_helper.dirname(path_helper.join("a", "b", "c", ""))).to eq(path_helper.join("a", "b"))
|
51
51
|
end
|
52
52
|
it "dirname('/a/b/c') is '/a/b'" do
|
53
|
-
expect(path_helper.dirname(path_helper.join(
|
53
|
+
expect(path_helper.dirname(path_helper.join("", "a", "b", "c"))).to eq(path_helper.join("", "a", "b"))
|
54
54
|
end
|
55
55
|
end
|
56
56
|
end
|
@@ -93,7 +93,6 @@ RSpec.describe ChefConfig::PathHelper do
|
|
93
93
|
|
94
94
|
end
|
95
95
|
|
96
|
-
|
97
96
|
it "cleanpath changes slashes into backslashes and leaves backslashes alone" do
|
98
97
|
expect(path_helper.cleanpath('/a/b\\c/d/')).to eq('\\a\\b\\c\\d')
|
99
98
|
end
|
@@ -113,11 +112,11 @@ RSpec.describe ChefConfig::PathHelper do
|
|
113
112
|
include_examples("common_functionality")
|
114
113
|
|
115
114
|
it "path_separator is /" do
|
116
|
-
expect(path_helper.path_separator).to eq(
|
115
|
+
expect(path_helper.path_separator).to eq("/")
|
117
116
|
end
|
118
117
|
|
119
118
|
it "cleanpath removes extra slashes alone" do
|
120
|
-
expect(path_helper.cleanpath(
|
119
|
+
expect(path_helper.cleanpath("/a///b/c/d/")).to eq("/a/b/c/d")
|
121
120
|
end
|
122
121
|
|
123
122
|
describe "platform-specific #join behavior" do
|
@@ -224,7 +223,7 @@ RSpec.describe ChefConfig::PathHelper do
|
|
224
223
|
end
|
225
224
|
end
|
226
225
|
|
227
|
-
context "not on windows", :unix_only
|
226
|
+
context "not on windows", :unix_only do
|
228
227
|
it "returns a canonical path" do
|
229
228
|
expect(path_helper.canonical_path("/etc//apache.d/sites-enabled/../sites-available/default")).to eq("/etc/apache.d/sites-available/default")
|
230
229
|
end
|
@@ -256,10 +255,10 @@ RSpec.describe ChefConfig::PathHelper do
|
|
256
255
|
it "joins, cleanpaths, and escapes characters reserved by glob" do
|
257
256
|
args = ["this/*path", "[needs]", "escaping?"]
|
258
257
|
escaped_path = if ChefConfig.windows?
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
258
|
+
"this\\\\\\*path\\\\\\[needs\\]\\\\escaping\\?"
|
259
|
+
else
|
260
|
+
"this/\\*path/\\[needs\\]/escaping\\?"
|
261
|
+
end
|
263
262
|
expect(path_helper).to receive(:join).with(*args).and_call_original
|
264
263
|
expect(path_helper).to receive(:cleanpath).and_call_original
|
265
264
|
expect(path_helper.escape_glob(*args)).to eq(escaped_path)
|
@@ -269,7 +268,7 @@ RSpec.describe ChefConfig::PathHelper do
|
|
269
268
|
|
270
269
|
describe "all_homes" do
|
271
270
|
before do
|
272
|
-
stub_const(
|
271
|
+
stub_const("ENV", env)
|
273
272
|
allow(ChefConfig).to receive(:windows?).and_return(is_windows)
|
274
273
|
end
|
275
274
|
|