chef 12.9.41-universal-mingw32 → 12.10.24-universal-mingw32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +52 -13
  3. data/README.md +145 -0
  4. data/Rakefile +4 -14
  5. data/VERSION +1 -1
  6. data/acceptance/.gitignore +0 -1
  7. data/acceptance/Gemfile +2 -2
  8. data/acceptance/Gemfile.lock +235 -0
  9. data/acceptance/fips/.kitchen.yml +5 -1
  10. data/acceptance/fips/test/integration/{fips → fips-integration}/serverspec/Gemfile +0 -0
  11. data/acceptance/fips/test/integration/fips-integration/serverspec/fips-integration_spec.rb +51 -0
  12. data/acceptance/fips/test/integration/fips-unit-functional/serverspec/Gemfile +3 -0
  13. data/acceptance/fips/test/integration/fips-unit-functional/serverspec/fips-unit-functional_spec.rb +56 -0
  14. data/{chef-windows.gemspec → chef-universal-mingw32.gemspec} +0 -0
  15. data/chef.gemspec +0 -6
  16. data/{lib → lib-backcompat}/chef/chef_fs/file_system/already_exists_error.rb +0 -0
  17. data/{lib → lib-backcompat}/chef/chef_fs/file_system/cookbook_frozen_error.rb +0 -0
  18. data/{lib → lib-backcompat}/chef/chef_fs/file_system/default_environment_cannot_be_modified_error.rb +0 -0
  19. data/{lib → lib-backcompat}/chef/chef_fs/file_system/file_system_error.rb +0 -0
  20. data/{lib → lib-backcompat}/chef/chef_fs/file_system/must_delete_recursively_error.rb +0 -0
  21. data/{lib → lib-backcompat}/chef/chef_fs/file_system/not_found_error.rb +0 -0
  22. data/{lib → lib-backcompat}/chef/chef_fs/file_system/operation_failed_error.rb +0 -0
  23. data/{lib → lib-backcompat}/chef/chef_fs/file_system/operation_not_allowed_error.rb +0 -0
  24. data/lib-backcompat/chef/chef_fs/file_system/repository/chef_repository_file_system_acls_dir.rb +5 -0
  25. data/lib-backcompat/chef/chef_fs/file_system/repository/chef_repository_file_system_client_keys_dir.rb +5 -0
  26. data/lib-backcompat/chef/chef_fs/file_system/repository/chef_repository_file_system_entry.rb +6 -0
  27. data/lib-backcompat/chef/chef_fs/file_system/repository/chef_repository_file_system_policies_dir.rb +5 -0
  28. data/{lib → lib-backcompat}/chef/chef_fs/file_system/repository/file_system_root_dir.rb +1 -0
  29. data/lib/chef/chef_fs/file_system/repository/acl.rb +38 -0
  30. data/lib/chef/chef_fs/file_system/repository/{chef_repository_file_system_acls_dir.rb → acls_dir.rb} +14 -5
  31. data/lib/chef/chef_fs/file_system/repository/acls_sub_dir.rb +42 -0
  32. data/lib/chef/chef_fs/file_system/repository/base_file.rb +120 -0
  33. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_entry.rb +1 -1
  34. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb +36 -32
  35. data/lib/chef/chef_fs/file_system/repository/client.rb +38 -0
  36. data/lib/chef/chef_fs/file_system/repository/client_key.rb +38 -0
  37. data/lib/chef/chef_fs/file_system/repository/{chef_repository_file_system_client_keys_dir.rb → client_keys_dir.rb} +9 -5
  38. data/lib/chef/chef_fs/file_system/repository/client_keys_sub_dir.rb +42 -0
  39. data/lib/chef/chef_fs/file_system/repository/clients_dir.rb +40 -0
  40. data/lib/chef/chef_fs/file_system/repository/container.rb +38 -0
  41. data/lib/chef/chef_fs/file_system/repository/containers_dir.rb +41 -0
  42. data/lib/chef/chef_fs/file_system/repository/cookbooks_dir.rb +0 -1
  43. data/lib/chef/chef_fs/file_system/repository/data_bag_item.rb +3 -79
  44. data/lib/chef/chef_fs/file_system/repository/directory.rb +15 -2
  45. data/lib/chef/chef_fs/file_system/repository/environment.rb +38 -0
  46. data/lib/chef/chef_fs/file_system/repository/environments_dir.rb +41 -0
  47. data/lib/chef/chef_fs/file_system/repository/file_system_entry.rb +66 -30
  48. data/lib/chef/chef_fs/file_system/repository/group.rb +38 -0
  49. data/lib/chef/chef_fs/file_system/repository/groups_dir.rb +41 -0
  50. data/lib/chef/chef_fs/file_system/repository/node.rb +38 -0
  51. data/lib/chef/chef_fs/file_system/repository/nodes_dir.rb +41 -0
  52. data/lib/chef/chef_fs/file_system/repository/{chef_repository_file_system_policies_dir.rb → policies_dir.rb} +9 -5
  53. data/lib/chef/chef_fs/file_system/repository/policy.rb +38 -0
  54. data/lib/chef/chef_fs/file_system/repository/policy_group.rb +38 -0
  55. data/lib/chef/chef_fs/file_system/repository/policy_groups_dir.rb +41 -0
  56. data/lib/chef/chef_fs/file_system/repository/role.rb +38 -0
  57. data/lib/chef/chef_fs/file_system/repository/roles_dir.rb +41 -0
  58. data/lib/chef/chef_fs/file_system/repository/user.rb +38 -0
  59. data/lib/chef/chef_fs/file_system/repository/users_dir.rb +41 -0
  60. data/lib/chef/dsl/declare_resource.rb +182 -7
  61. data/lib/chef/http/json_input.rb +2 -2
  62. data/lib/chef/knife.rb +1 -1
  63. data/lib/chef/mixin/shell_out.rb +10 -21
  64. data/lib/chef/property.rb +9 -2
  65. data/lib/chef/provider.rb +8 -7
  66. data/lib/chef/provider/apt_repository.rb +8 -6
  67. data/lib/chef/provider/directory.rb +15 -1
  68. data/lib/chef/provider/env/windows.rb +1 -1
  69. data/lib/chef/provider/mdadm.rb +1 -0
  70. data/lib/chef/provider/package/easy_install.rb +2 -0
  71. data/lib/chef/provider/package/rubygems.rb +4 -1
  72. data/lib/chef/provider/package/windows.rb +1 -1
  73. data/lib/chef/recipe.rb +1 -2
  74. data/lib/chef/resource/apt_repository.rb +6 -6
  75. data/lib/chef/resource/mdadm.rb +9 -0
  76. data/lib/chef/resource_collection.rb +5 -0
  77. data/lib/chef/resource_collection/resource_list.rb +10 -0
  78. data/lib/chef/resource_collection/resource_set.rb +14 -11
  79. data/lib/chef/version.rb +1 -1
  80. data/spec/functional/resource/git_spec.rb +1 -3
  81. data/spec/functional/resource/group_spec.rb +5 -5
  82. data/spec/functional/tiny_server_spec.rb +1 -1
  83. data/spec/functional/util/powershell/cmdlet_spec.rb +1 -1
  84. data/spec/functional/win32/registry_spec.rb +3 -3
  85. data/spec/integration/solo/solo_spec.rb +2 -2
  86. data/spec/support/shared/functional/securable_resource.rb +1 -1
  87. data/spec/support/shared/unit/provider/file.rb +3 -3
  88. data/spec/support/shared/unit/windows_script_resource.rb +1 -1
  89. data/spec/unit/application/apply_spec.rb +1 -0
  90. data/spec/unit/chef_fs/file_system/repository/base_file_spec.rb +128 -0
  91. data/spec/unit/chef_fs/file_system/repository/directory_spec.rb +174 -0
  92. data/spec/unit/cookbook/metadata_spec.rb +1 -1
  93. data/spec/unit/dsl/declare_resource_spec.rb +335 -0
  94. data/spec/unit/knife/bootstrap_spec.rb +2 -2
  95. data/spec/unit/mixin/shell_out_spec.rb +4 -0
  96. data/spec/unit/node/attribute_spec.rb +1 -1
  97. data/spec/unit/node/immutable_collections_spec.rb +2 -2
  98. data/spec/unit/node_map_spec.rb +1 -1
  99. data/spec/unit/property/validation_spec.rb +23 -7
  100. data/spec/unit/provider/apt_repository_spec.rb +5 -0
  101. data/spec/unit/provider/apt_update_spec.rb +1 -0
  102. data/spec/unit/provider/directory_spec.rb +0 -7
  103. data/spec/unit/provider/file/content_spec.rb +1 -1
  104. data/spec/unit/provider/mdadm_spec.rb +9 -0
  105. data/spec/unit/provider/package/easy_install_spec.rb +6 -0
  106. data/spec/unit/provider/package/rubygems_spec.rb +8 -4
  107. data/spec/unit/provider/package/yum_spec.rb +1 -1
  108. data/spec/unit/provider/powershell_script_spec.rb +1 -1
  109. data/spec/unit/provider/user/dscl_spec.rb +6 -6
  110. data/spec/unit/recipe_spec.rb +1 -0
  111. data/spec/unit/resource/apt_repository_spec.rb +4 -0
  112. data/spec/unit/resource/file/verification_spec.rb +1 -1
  113. data/spec/unit/resource/file_spec.rb +2 -2
  114. data/spec/unit/resource/mdadm_spec.rb +7 -2
  115. data/spec/unit/resource_collection_spec.rb +30 -0
  116. data/spec/unit/resource_spec.rb +1 -1
  117. data/tasks/bin/bundle-platform +15 -0
  118. data/tasks/bin/bundle-platform.bat +2 -0
  119. data/tasks/bin/create-override-gemfile +110 -0
  120. data/tasks/bin/run_chef_tests +17 -0
  121. data/tasks/bin/run_external_test +47 -0
  122. data/tasks/bundle.rb +97 -0
  123. data/tasks/bundle_util.rb +94 -0
  124. data/tasks/changelog.rb +12 -0
  125. data/tasks/dependencies.rb +147 -0
  126. data/tasks/gemfile_util.rb +390 -0
  127. data/tasks/maintainers.rb +2 -1
  128. data/tasks/rspec.rb +2 -1
  129. metadata +61 -83
  130. data/acceptance/fips/test/integration/fips/serverspec/fips_spec.rb +0 -39
  131. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_entry.rb +0 -83
  132. data/tasks/external_tests.rb +0 -64
@@ -85,7 +85,7 @@ describe Chef::Knife::Bootstrap do
85
85
  let(:bootstrap_template) { "/opt/blah/not/exists/template.erb" }
86
86
 
87
87
  it "raises an error" do
88
- expect { knife.find_template }.to raise_error
88
+ expect { knife.find_template }.to raise_error(Errno::ENOENT)
89
89
  end
90
90
  end
91
91
 
@@ -339,7 +339,7 @@ describe Chef::Knife::Bootstrap do
339
339
  let(:options) { ["--node-ssl-verify-mode", "all"] }
340
340
 
341
341
  it "raises error" do
342
- expect { rendered_template }.to raise_error
342
+ expect { rendered_template }.to raise_error(RuntimeError)
343
343
  end
344
344
  end
345
345
 
@@ -34,6 +34,10 @@ describe Chef::Mixin::ShellOut do
34
34
  let!(:capture_log_output) { Chef::Log.logger = Logger.new(output) }
35
35
  let(:assume_deprecation_log_level) { allow(Chef::Log).to receive(:level).and_return(:warn) }
36
36
 
37
+ before do
38
+ Chef::Config[:treat_deprecation_warnings_as_errors] = false
39
+ end
40
+
37
41
  context "without options" do
38
42
  let(:command_args) { [ cmd ] }
39
43
 
@@ -408,7 +408,7 @@ describe Chef::Node::Attribute do
408
408
  end
409
409
 
410
410
  it "should die if you try and do nested attributes that do not exist without read vivification" do
411
- expect { @attributes["foo"]["bar"] = :baz }.to raise_error
411
+ expect { @attributes["foo"]["bar"] = :baz }.to raise_error(NoMethodError)
412
412
  end
413
413
 
414
414
  it "should let you set attributes manually without vivification" do
@@ -97,7 +97,7 @@ describe Chef::Node::ImmutableMash do
97
97
  :shift,
98
98
  ].each do |mutator|
99
99
  it "doesn't allow mutation via `#{mutator}'" do
100
- expect { @immutable_mash.send(mutator) }.to raise_error
100
+ expect { @immutable_mash.send(mutator) }.to raise_error(Chef::Exceptions::ImmutableAttributeModification)
101
101
  end
102
102
  end
103
103
 
@@ -154,7 +154,7 @@ describe Chef::Node::ImmutableArray do
154
154
  :unshift,
155
155
  ].each do |mutator|
156
156
  it "does not allow mutation via `#{mutator}" do
157
- expect { @immutable_array.send(mutator) }.to raise_error
157
+ expect { @immutable_array.send(mutator) }.to raise_error(Chef::Exceptions::ImmutableAttributeModification)
158
158
  end
159
159
  end
160
160
 
@@ -27,7 +27,7 @@ describe Chef::NodeMap do
27
27
 
28
28
  describe "with a bad filter name" do
29
29
  it "should raise an error" do
30
- expect { node_map.set(node, :thing, on_platform_family: "rhel") }.to raise_error
30
+ expect { node_map.set(node, :thing, on_platform_family: "rhel") }.to raise_error(ArgumentError)
31
31
  end
32
32
  end
33
33
 
@@ -99,13 +99,15 @@ describe "Chef::Resource.property validation" do
99
99
  expect(resource.x nil).to be_nil
100
100
  expect(resource.x).to be_nil
101
101
  end
102
- it "changing x to nil warns that the get will change to a set in Chef 13 and does not change the value" do
103
- resource.instance_eval { @x = "default" }
104
- expect { resource.x nil }.to raise_error Chef::Exceptions::DeprecatedFeatureError,
105
- /An attempt was made to change x from "default" to nil by calling x\(nil\). In Chef 12, this does a get rather than a set. In Chef 13, this will change to set the value to nil./
106
- Chef::Config[:treat_deprecation_warnings_as_errors] = false
107
- expect(resource.x nil).to eq "default"
108
- expect(resource.x).to eq "default"
102
+ unless tags.include?(:nillable)
103
+ it "changing x to nil warns that the get will change to a set in Chef 13 and does not change the value" do
104
+ resource.instance_eval { @x = "default" }
105
+ expect { resource.x nil }.to raise_error Chef::Exceptions::DeprecatedFeatureError,
106
+ /An attempt was made to change x from "default" to nil by calling x\(nil\). In Chef 12, this does a get rather than a set. In Chef 13, this will change to set the value to nil./
107
+ Chef::Config[:treat_deprecation_warnings_as_errors] = false
108
+ expect(resource.x nil).to eq "default"
109
+ expect(resource.x).to eq "default"
110
+ end
109
111
  end
110
112
  end
111
113
  if tags.include?(:nil_is_valid)
@@ -123,6 +125,15 @@ describe "Chef::Resource.property validation" do
123
125
  expect(resource.x).to eq "default"
124
126
  end
125
127
  end
128
+ elsif tags.include?(:nillable)
129
+ with_property ":x, #{validation}, nillable: true" do
130
+ it "changing x to nil with nillable true overwrites defaults and just works" do
131
+ resource.instance_eval { @x = "default" }
132
+ expect { resource.x nil }.not_to raise_error
133
+ expect(resource.x nil).to eq nil
134
+ expect(resource.x).to eq nil
135
+ end
136
+ end
126
137
  else
127
138
  it "property :x, #{validation}, default: nil warns that the default is invalid" do
128
139
  expect { resource_class.class_eval("property :x, #{validation}, default: nil", __FILE__, __LINE__) }.to raise_error Chef::Exceptions::DeprecatedFeatureError,
@@ -268,6 +279,11 @@ describe "Chef::Resource.property validation" do
268
279
  validation_test "[]",
269
280
  [],
270
281
  [ :a ]
282
+
283
+ validation_test "[ String, nil ], nillable: true",
284
+ [ nil, "thing" ],
285
+ [ :nope, false ],
286
+ :nillable
271
287
  end
272
288
 
273
289
  # is
@@ -158,6 +158,11 @@ C5986B4F1257FFA86632CBA746181433FBB75451
158
158
  expect(provider.build_repo("http://test/uri", "unstable", "main", false, nil)).to eql(target)
159
159
  end
160
160
 
161
+ it "should create a repository string with no distribution" do
162
+ target = %Q{deb "http://test/uri" main\n}
163
+ expect(provider.build_repo("http://test/uri", nil, "main", false, nil)).to eql(target)
164
+ end
165
+
161
166
  it "should create a repository string with source" do
162
167
  target = %Q{deb "http://test/uri" unstable main\ndeb-src "http://test/uri" unstable main\n}
163
168
  expect(provider.build_repo("http://test/uri", "unstable", "main", false, nil, true)).to eql(target)
@@ -73,6 +73,7 @@ describe Chef::Provider::AptUpdate do
73
73
  describe "#action_periodic" do
74
74
  before do
75
75
  allow(File).to receive(:exist?)
76
+ allow(File).to receive(:exist?).with(Dir.tmpdir).and_return(true)
76
77
  expect(File).to receive(:exist?).with("#{stamp_dir}/update-success-stamp").and_return(true)
77
78
  end
78
79
 
@@ -185,13 +185,6 @@ describe Chef::Provider::Directory do
185
185
  end
186
186
 
187
187
  it "raises an exception when the parent directory is a file and recursive is true" do
188
- FileUtils.touch tmp_dir
189
- new_resource.recursive true
190
- expect { directory.run_action(:create) }.to raise_error
191
- end
192
-
193
- it "raises the right exception when the parent directory is a file and recursive is true" do
194
- pending "this seems to return the wrong error" # FIXME
195
188
  FileUtils.touch tmp_dir
196
189
  new_resource.recursive true
197
190
  expect { directory.run_action(:create) }.to raise_error(Chef::Exceptions::EnclosingDirectoryDoesNotExist)
@@ -89,7 +89,7 @@ describe Chef::Provider::File::Content do
89
89
 
90
90
  it "fails when :file_desployment_uses_destdir is set" do
91
91
  Chef::Config[:file_staging_uses_destdir] = true
92
- expect { content.tempfile }.to raise_error
92
+ expect { content.tempfile }.to raise_error(Chef::Exceptions::FileContentStagingError)
93
93
  end
94
94
 
95
95
  it "returns a tempfile in the tempdir when :file_desployment_uses_destdir is not set" do
@@ -76,6 +76,15 @@ describe Chef::Provider::Mdadm do
76
76
  expect(@new_resource).to be_updated_by_last_action
77
77
  end
78
78
 
79
+ it "should specify a layout only if set" do
80
+ @current_resource.exists(false)
81
+ @new_resource.layout("rs")
82
+ expected_command = "yes | mdadm --create /dev/md1 --level 5 --chunk=16 --metadata=0.90 --layout=rs --raid-devices 3 /dev/sdz1 /dev/sdz2 /dev/sdz3"
83
+ expect(@provider).to receive(:shell_out!).with(expected_command)
84
+ @provider.run_action(:create)
85
+ expect(@new_resource).to be_updated_by_last_action
86
+ end
87
+
79
88
  it "should not specify a chunksize if raid level 1" do
80
89
  @current_resource.exists(false)
81
90
  @new_resource.level 1
@@ -61,6 +61,7 @@ describe Chef::Provider::Package::EasyInstall do
61
61
 
62
62
  describe "actions_on_package" do
63
63
  it "should run easy_install with the package name and version" do
64
+ expect(Chef).to receive(:log_deprecation).with(/easy_install package provider is deprecated/)
64
65
  expect(@provider).to receive(:run_command).with({
65
66
  :command => "easy_install \"boto==1.8d\"",
66
67
  })
@@ -68,6 +69,7 @@ describe Chef::Provider::Package::EasyInstall do
68
69
  end
69
70
 
70
71
  it "should run easy_install with the package name and version and specified options" do
72
+ expect(Chef).to receive(:log_deprecation).with(/easy_install package provider is deprecated/)
71
73
  expect(@provider).to receive(:run_command).with({
72
74
  :command => "easy_install --always-unzip \"boto==1.8d\"",
73
75
  })
@@ -76,6 +78,7 @@ describe Chef::Provider::Package::EasyInstall do
76
78
  end
77
79
 
78
80
  it "should run easy_install with the package name and version" do
81
+ expect(Chef).to receive(:log_deprecation).with(/easy_install package provider is deprecated/)
79
82
  expect(@provider).to receive(:run_command).with({
80
83
  :command => "easy_install \"boto==1.8d\"",
81
84
  })
@@ -83,6 +86,7 @@ describe Chef::Provider::Package::EasyInstall do
83
86
  end
84
87
 
85
88
  it "should run easy_install -m with the package name and version" do
89
+ expect(Chef).to receive(:log_deprecation).with(/easy_install package provider is deprecated/)
86
90
  expect(@provider).to receive(:run_command).with({
87
91
  :command => "easy_install -m boto",
88
92
  })
@@ -90,6 +94,7 @@ describe Chef::Provider::Package::EasyInstall do
90
94
  end
91
95
 
92
96
  it "should run easy_install -m with the package name and version and specified options" do
97
+ expect(Chef).to receive(:log_deprecation).with(/easy_install package provider is deprecated/)
93
98
  expect(@provider).to receive(:run_command).with({
94
99
  :command => "easy_install -x -m boto",
95
100
  })
@@ -98,6 +103,7 @@ describe Chef::Provider::Package::EasyInstall do
98
103
  end
99
104
 
100
105
  it "should run easy_install -m with the package name and version" do
106
+ expect(Chef).to receive(:log_deprecation).with(/easy_install package provider is deprecated/)
101
107
  expect(@provider).to receive(:run_command).with({
102
108
  :command => "easy_install -m boto",
103
109
  })
@@ -562,9 +562,10 @@ describe Chef::Provider::Package::Rubygems do
562
562
 
563
563
  context "when source is a path" do
564
564
  let(:source) { CHEF_SPEC_DATA + "/gems/chef-integration-test-0.1.0.gem" }
565
+ let(:domain) { { domain: :local } }
565
566
 
566
567
  it "installs the gem from file via the gems api" do
567
- expect(provider.gem_env).to receive(:install).with(source)
568
+ expect(provider.gem_env).to receive(:install).with(source, domain)
568
569
  provider.run_action(:install)
569
570
  expect(new_resource).to be_updated_by_last_action
570
571
  end
@@ -572,10 +573,11 @@ describe Chef::Provider::Package::Rubygems do
572
573
 
573
574
  context "when the gem name is a file path and source is nil" do
574
575
  let(:gem_name) { CHEF_SPEC_DATA + "/gems/chef-integration-test-0.1.0.gem" }
576
+ let(:domain) { { domain: :local } }
575
577
 
576
578
  it "installs the gem from file via the gems api" do
577
579
  expect(new_resource.source).to eq(gem_name)
578
- expect(provider.gem_env).to receive(:install).with(gem_name)
580
+ expect(provider.gem_env).to receive(:install).with(gem_name, domain)
579
581
  provider.run_action(:install)
580
582
  expect(new_resource).to be_updated_by_last_action
581
583
  end
@@ -693,9 +695,10 @@ describe Chef::Provider::Package::Rubygems do
693
695
  context "when source is a path" do
694
696
  let(:source) { CHEF_SPEC_DATA + "/gems/chef-integration-test-0.1.0.gem" }
695
697
  let(:target_version) { ">= 0" }
698
+ let(:domain) { " --local" }
696
699
 
697
700
  it "installs the gem by shelling out to gem install" do
698
- expect(provider).to receive(:shell_out!).with("#{gem_binary} install #{source} -q --no-rdoc --no-ri -v \"#{target_version}\"", env: nil, timeout: 900)
701
+ expect(provider).to receive(:shell_out!).with("#{gem_binary} install #{source} -q --no-rdoc --no-ri -v \"#{target_version}\"#{domain}", env: nil, timeout: 900)
699
702
  provider.run_action(:install)
700
703
  expect(new_resource).to be_updated_by_last_action
701
704
  end
@@ -704,10 +707,11 @@ describe Chef::Provider::Package::Rubygems do
704
707
  context "when the package is a path and source is nil" do
705
708
  let(:gem_name) { CHEF_SPEC_DATA + "/gems/chef-integration-test-0.1.0.gem" }
706
709
  let(:target_version) { ">= 0" }
710
+ let(:domain) { " --local" }
707
711
 
708
712
  it "installs the gem from file by shelling out to gem install when the package is a path and the source is nil" do
709
713
  expect(new_resource.source).to eq(gem_name)
710
- expect(provider).to receive(:shell_out!).with("#{gem_binary} install #{gem_name} -q --no-rdoc --no-ri -v \"#{target_version}\"", env: nil, timeout: 900)
714
+ expect(provider).to receive(:shell_out!).with("#{gem_binary} install #{gem_name} -q --no-rdoc --no-ri -v \"#{target_version}\"#{domain}", env: nil, timeout: 900)
711
715
  provider.run_action(:install)
712
716
  expect(new_resource).to be_updated_by_last_action
713
717
  end
@@ -1578,7 +1578,7 @@ describe Chef::Provider::Package::Yum::RPMDb do
1578
1578
  end
1579
1579
 
1580
1580
  it "should only accept an RPMDbPackage object" do
1581
- expect { @rpmdb.push("string") }.to raise_error
1581
+ expect { @rpmdb.push("string") }.to raise_error(ArgumentError)
1582
1582
  end
1583
1583
 
1584
1584
  it "should add the package to the package db" do
@@ -74,7 +74,7 @@ describe Chef::Provider::PowershellScript, "action_run" do
74
74
 
75
75
  provider_flags.find do |value|
76
76
  execution_policy_index += 1
77
- execution_policy_specified = value.downcase == "-ExecutionPolicy".downcase
77
+ execution_policy_specified = value.casecmp("-ExecutionPolicy".downcase).zero?
78
78
  end
79
79
 
80
80
  execution_policy = execution_policy_specified ? provider_flags[execution_policy_index] : nil
@@ -294,7 +294,7 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30"
294
294
  let(:dscl_exists) { false }
295
295
 
296
296
  it "should raise an error" do
297
- expect { run_requirements }.to raise_error
297
+ expect { run_requirements }.to raise_error(Chef::Exceptions::User)
298
298
  end
299
299
  end
300
300
 
@@ -302,7 +302,7 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30"
302
302
  let(:plutil_exists) { false }
303
303
 
304
304
  it "should raise an error" do
305
- expect { run_requirements }.to raise_error
305
+ expect { run_requirements }.to raise_error(Chef::Exceptions::User)
306
306
  end
307
307
  end
308
308
 
@@ -312,7 +312,7 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30"
312
312
  }
313
313
 
314
314
  it "should raise an error" do
315
- expect { run_requirements }.to raise_error
315
+ expect { run_requirements }.to raise_error(Chef::Exceptions::User)
316
316
  end
317
317
  end
318
318
 
@@ -333,7 +333,7 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30"
333
333
  let(:password) { salted_sha512_pbkdf2_password }
334
334
 
335
335
  it "should raise an error" do
336
- expect { run_requirements }.to raise_error
336
+ expect { run_requirements }.to raise_error(Chef::Exceptions::User)
337
337
  end
338
338
  end
339
339
  end
@@ -348,7 +348,7 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30"
348
348
  let(:password) { salted_sha512_password }
349
349
 
350
350
  it "should raise an error" do
351
- expect { run_requirements }.to raise_error
351
+ expect { run_requirements }.to raise_error(Chef::Exceptions::User)
352
352
  end
353
353
  end
354
354
 
@@ -357,7 +357,7 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30"
357
357
 
358
358
  describe "when salt and iteration is not set" do
359
359
  it "should raise an error" do
360
- expect { run_requirements }.to raise_error
360
+ expect { run_requirements }.to raise_error(Chef::Exceptions::User)
361
361
  end
362
362
  end
363
363
 
@@ -306,6 +306,7 @@ describe Chef::Recipe do
306
306
 
307
307
  it "does not insert two resources if create_if_missing is used" do
308
308
  zm_resource
309
+ Chef::Config[:treat_deprecation_warnings_as_errors] = false
309
310
  recipe.declare_resource(:zen_master, "klopp", create_if_missing: true)
310
311
  expect(run_context.resource_collection.count).to eql(1)
311
312
  end
@@ -31,4 +31,8 @@ describe Chef::Resource::AptRepository do
31
31
  expect(resource.keyserver).to eql("keyserver.ubuntu.com")
32
32
  end
33
33
 
34
+ it "the default distribution should be nillable" do
35
+ expect(resource.distribution(nil)).to eql(nil)
36
+ expect(resource.distribution).to eql(nil)
37
+ end
34
38
  end
@@ -43,7 +43,7 @@ describe Chef::Resource::File::Verification do
43
43
  it "expects a string argument" do
44
44
  v = Chef::Resource::File::Verification.new(parent_resource, nil, {}) {}
45
45
  expect { v.verify("/foo/bar") }.to_not raise_error
46
- expect { v.verify }.to raise_error
46
+ expect { v.verify }.to raise_error(ArgumentError)
47
47
  end
48
48
 
49
49
  it "accepts an options hash" do
@@ -70,8 +70,8 @@ describe Chef::Resource::File do
70
70
  expect { @resource.verify {} }.not_to raise_error
71
71
  expect { @resource.verify "" }.not_to raise_error
72
72
  expect { @resource.verify :json }.not_to raise_error
73
- expect { @resource.verify true }.to raise_error
74
- expect { @resource.verify false }.to raise_error
73
+ expect { @resource.verify true }.to raise_error(ArgumentError)
74
+ expect { @resource.verify false }.to raise_error(ArgumentError)
75
75
  end
76
76
 
77
77
  it "should accept multiple verify statements" do
@@ -65,8 +65,13 @@ describe Chef::Resource::Mdadm do
65
65
  end
66
66
 
67
67
  it "should allow you to set the bitmap attribute" do
68
- @resource.metadata "internal"
69
- expect(@resource.metadata).to eql("internal")
68
+ @resource.bitmap "internal"
69
+ expect(@resource.bitmap).to eql("internal")
70
+ end
71
+
72
+ it "should allow you to set the layout attribute" do
73
+ @resource.layout "f2"
74
+ expect(@resource.layout).to eql("f2")
70
75
  end
71
76
 
72
77
  it "should allow you to set the devices attribute" do
@@ -162,6 +162,36 @@ describe Chef::ResourceCollection do
162
162
  end
163
163
  end
164
164
 
165
+ describe "delete" do
166
+ it "should allow you to delete resources by name via delete" do
167
+ zmr = Chef::Resource::ZenMaster.new("dog")
168
+ rc << zmr
169
+ expect(rc).not_to be_empty
170
+ expect(rc.delete(zmr.to_s)).to eql(zmr)
171
+ expect(rc).to be_empty
172
+
173
+ zmr = Chef::Resource::ZenMaster.new("cat")
174
+ rc[0] = zmr
175
+ expect(rc).not_to be_empty
176
+ expect(rc.delete(zmr)).to eql(zmr)
177
+ expect(rc).to be_empty
178
+
179
+ zmr = Chef::Resource::ZenMaster.new("monkey")
180
+ rc.push(zmr)
181
+ expect(rc).not_to be_empty
182
+ expect(rc.delete(zmr)).to eql(zmr)
183
+ expect(rc).to be_empty
184
+ end
185
+
186
+ it "should raise an exception if you send something strange to delete" do
187
+ expect { rc.delete(:symbol) }.to raise_error(ArgumentError)
188
+ end
189
+
190
+ it "should raise an exception if it cannot find a resource with delete" do
191
+ expect { rc.delete("zen_master[dog]") }.to raise_error(Chef::Exceptions::ResourceNotFound)
192
+ end
193
+ end
194
+
165
195
  describe "resources" do
166
196
 
167
197
  it "should find a resource by symbol and name (:zen_master => monkey)" do
@@ -542,7 +542,7 @@ describe Chef::Resource do
542
542
  allow(provider).to receive(:action_purr).and_raise
543
543
 
544
544
  expect(retriable_resource).to receive(:sleep).exactly(3).times
545
- expect { retriable_resource.run_action(:purr) }.to raise_error
545
+ expect { retriable_resource.run_action(:purr) }.to raise_error(RuntimeError)
546
546
  expect(retriable_resource.retries).to eq(3)
547
547
  end
548
548
  end