chefspec 4.2.0 → 4.7.0

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 (135) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.travis.yml +39 -16
  4. data/CHANGELOG.md +136 -72
  5. data/README.md +187 -13
  6. data/chefspec.gemspec +5 -5
  7. data/examples/batch/spec/run_spec.rb +5 -0
  8. data/examples/chef_gem/recipes/install.rb +8 -3
  9. data/examples/chef_gem/recipes/purge.rb +6 -3
  10. data/examples/chef_gem/recipes/reconfig.rb +6 -3
  11. data/examples/chef_gem/recipes/remove.rb +6 -3
  12. data/examples/chef_gem/recipes/upgrade.rb +6 -3
  13. data/examples/chocolatey_package/recipes/install.rb +6 -0
  14. data/examples/chocolatey_package/recipes/remove.rb +8 -0
  15. data/examples/chocolatey_package/recipes/upgrade.rb +8 -0
  16. data/examples/chocolatey_package/spec/install_spec.rb +21 -0
  17. data/examples/chocolatey_package/spec/remove_spec.rb +20 -0
  18. data/examples/chocolatey_package/spec/upgrade_spec.rb +20 -0
  19. data/examples/directory/recipes/create.rb +4 -0
  20. data/examples/directory/spec/create_spec.rb +4 -0
  21. data/examples/dpkg_package/spec/install_spec.rb +5 -0
  22. data/examples/dpkg_package/spec/purge_spec.rb +5 -0
  23. data/examples/dpkg_package/spec/remove_spec.rb +5 -0
  24. data/examples/dsc_resource/recipes/default.rb +20 -0
  25. data/examples/dsc_resource/spec/default_spec.rb +40 -0
  26. data/examples/env/spec/create_spec.rb +5 -0
  27. data/examples/env/spec/delete_spec.rb +5 -0
  28. data/examples/env/spec/modify_spec.rb +5 -0
  29. data/examples/ips_package/spec/install_spec.rb +5 -0
  30. data/examples/ips_package/spec/remove_spec.rb +5 -0
  31. data/examples/ips_package/spec/upgrade_spec.rb +5 -0
  32. data/examples/package/recipes/install.rb +4 -0
  33. data/examples/package/recipes/purge.rb +4 -0
  34. data/examples/package/recipes/reconfig.rb +4 -0
  35. data/examples/package/recipes/remove.rb +4 -0
  36. data/examples/package/recipes/upgrade.rb +4 -0
  37. data/examples/package/spec/install_spec.rb +4 -0
  38. data/examples/package/spec/purge_spec.rb +4 -0
  39. data/examples/package/spec/reconfig_spec.rb +4 -0
  40. data/examples/package/spec/remove_spec.rb +4 -0
  41. data/examples/package/spec/upgrade_spec.rb +4 -0
  42. data/examples/pacman_package/spec/install_spec.rb +5 -0
  43. data/examples/pacman_package/spec/purge_spec.rb +5 -0
  44. data/examples/pacman_package/spec/remove_spec.rb +5 -0
  45. data/examples/pacman_package/spec/upgrade_spec.rb +5 -0
  46. data/examples/powershell_script/spec/run_spec.rb +5 -0
  47. data/examples/reboot/recipes/cancel.rb +3 -0
  48. data/examples/reboot/recipes/now.rb +3 -0
  49. data/examples/reboot/recipes/request.rb +3 -0
  50. data/examples/reboot/spec/cancel_spec.rb +10 -0
  51. data/examples/reboot/spec/now_spec.rb +10 -0
  52. data/examples/reboot/spec/request_spec.rb +10 -0
  53. data/examples/render_file/spec/default_spec.rb +40 -0
  54. data/examples/rpm_package/spec/install_spec.rb +5 -0
  55. data/examples/rpm_package/spec/remove_spec.rb +5 -0
  56. data/examples/rpm_package/spec/upgrade_spec.rb +5 -0
  57. data/examples/server/spec/node_spec.rb +1 -1
  58. data/examples/server/spec/search_spec.rb +4 -0
  59. data/examples/step_into/providers/provides.rb +3 -0
  60. data/examples/step_into/recipes/default.rb +2 -0
  61. data/examples/step_into/resources/lwrp.rb +1 -1
  62. data/examples/step_into/resources/provides.rb +6 -0
  63. data/examples/step_into/spec/default_spec.rb +10 -2
  64. data/examples/windows_package/recipes/install.rb +13 -0
  65. data/examples/windows_package/recipes/remove.rb +13 -0
  66. data/examples/windows_package/spec/install_spec.rb +24 -0
  67. data/examples/windows_package/spec/remove_spec.rb +24 -0
  68. data/examples/windows_service/recipes/configure_startup.rb +13 -0
  69. data/examples/windows_service/recipes/disable.rb +13 -0
  70. data/examples/windows_service/recipes/enable.rb +13 -0
  71. data/examples/windows_service/recipes/reload.rb +13 -0
  72. data/examples/windows_service/recipes/restart.rb +13 -0
  73. data/examples/windows_service/recipes/start.rb +13 -0
  74. data/examples/windows_service/recipes/stop.rb +13 -0
  75. data/examples/windows_service/spec/configure_startup_spec.rb +24 -0
  76. data/examples/windows_service/spec/disable_spec.rb +24 -0
  77. data/examples/windows_service/spec/enable_spec.rb +24 -0
  78. data/examples/windows_service/spec/reload_spec.rb +24 -0
  79. data/examples/windows_service/spec/restart_spec.rb +24 -0
  80. data/examples/windows_service/spec/start_spec.rb +24 -0
  81. data/examples/windows_service/spec/stop_spec.rb +24 -0
  82. data/features/chocolatey_package.feature +29 -0
  83. data/features/dsc_resource.feature +18 -0
  84. data/features/reboot.feature +19 -0
  85. data/features/step_definitions/background_steps.rb +4 -1
  86. data/features/step_into.feature +7 -0
  87. data/features/support/env.rb +5 -4
  88. data/features/windows_package.feature +24 -0
  89. data/features/windows_service.feature +23 -0
  90. data/gemfiles/chefspec.gemfile +9 -0
  91. data/lib/chefspec/api/chocolatey_package.rb +107 -0
  92. data/lib/chefspec/api/directory.rb +10 -10
  93. data/lib/chefspec/api/dsc_resource.rb +49 -0
  94. data/lib/chefspec/api/group.rb +5 -5
  95. data/lib/chefspec/api/link.rb +10 -10
  96. data/lib/chefspec/api/mdadm.rb +5 -5
  97. data/lib/chefspec/api/reboot.rb +18 -0
  98. data/lib/chefspec/api/remote_directory.rb +10 -10
  99. data/lib/chefspec/api/route.rb +5 -5
  100. data/lib/chefspec/api/user.rb +5 -5
  101. data/lib/chefspec/api/windows_package.rb +86 -0
  102. data/lib/chefspec/api/windows_service.rb +286 -0
  103. data/lib/chefspec/api.rb +5 -0
  104. data/lib/chefspec/berkshelf.rb +7 -1
  105. data/lib/chefspec/coverage/filters.rb +2 -1
  106. data/lib/chefspec/coverage.rb +1 -1
  107. data/lib/chefspec/deprecations.rb +6 -2
  108. data/lib/chefspec/errors.rb +4 -0
  109. data/lib/chefspec/extensions/chef/lwrp_base.rb +23 -0
  110. data/lib/chefspec/file_cache_path_proxy.rb +15 -0
  111. data/lib/chefspec/matchers/render_file_matcher.rb +20 -2
  112. data/lib/chefspec/matchers/resource_matcher.rb +9 -2
  113. data/lib/chefspec/mixins/normalize.rb +7 -1
  114. data/lib/chefspec/policyfile.rb +62 -0
  115. data/lib/chefspec/renderer.rb +2 -4
  116. data/lib/chefspec/rspec.rb +3 -0
  117. data/lib/chefspec/server_methods.rb +1 -0
  118. data/lib/chefspec/server_runner.rb +9 -0
  119. data/lib/chefspec/solo_runner.rb +13 -3
  120. data/lib/chefspec/version.rb +1 -1
  121. data/lib/chefspec.rb +1 -1
  122. data/spec/unit/coverage/filters_spec.rb +60 -0
  123. data/spec/unit/deprecations_spec.rb +3 -1
  124. data/spec/unit/macros_spec.rb +1 -1
  125. data/spec/unit/matchers/render_file_matcher_spec.rb +11 -0
  126. data/spec/unit/renderer_spec.rb +20 -2
  127. data/spec/unit/server_runner_spec.rb +28 -0
  128. data/spec/unit/solo_runner_spec.rb +3 -1
  129. data/templates/errors/invalid_berkshelf_options.erb +4 -0
  130. data/templates/errors/may_need_to_specify_platform.erb +25 -0
  131. metadata +72 -18
  132. data/gemfiles/chef-11.14.0.gemfile +0 -5
  133. data/gemfiles/chef-11.16.0.gemfile +0 -5
  134. data/gemfiles/chef-12.0.0.gemfile +0 -5
  135. data/gemfiles/chef-master.gemfile +0 -5
@@ -1,5 +1,10 @@
1
1
  require 'chefspec'
2
2
 
3
+ RSpec.configure do |config|
4
+ config.platform = 'windows'
5
+ config.version = '2012R2'
6
+ end
7
+
3
8
  describe 'env::create' do
4
9
  let(:chef_run) { ChefSpec::SoloRunner.converge(described_recipe) }
5
10
 
@@ -1,5 +1,10 @@
1
1
  require 'chefspec'
2
2
 
3
+ RSpec.configure do |config|
4
+ config.platform = 'windows'
5
+ config.version = '2012R2'
6
+ end
7
+
3
8
  describe 'env::delete' do
4
9
  let(:chef_run) { ChefSpec::SoloRunner.converge(described_recipe) }
5
10
 
@@ -1,5 +1,10 @@
1
1
  require 'chefspec'
2
2
 
3
+ RSpec.configure do |config|
4
+ config.platform = 'windows'
5
+ config.version = '2012R2'
6
+ end
7
+
3
8
  describe 'env::modify' do
4
9
  let(:chef_run) { ChefSpec::SoloRunner.converge(described_recipe) }
5
10
 
@@ -1,5 +1,10 @@
1
1
  require 'chefspec'
2
2
 
3
+ RSpec.configure do |config|
4
+ config.platform = 'solaris2'
5
+ config.version = '5.11'
6
+ end
7
+
3
8
  describe 'ips_package::install' do
4
9
  let(:chef_run) { ChefSpec::SoloRunner.converge(described_recipe) }
5
10
 
@@ -1,5 +1,10 @@
1
1
  require 'chefspec'
2
2
 
3
+ RSpec.configure do |config|
4
+ config.platform = 'solaris2'
5
+ config.version = '5.11'
6
+ end
7
+
3
8
  describe 'ips_package::remove' do
4
9
  let(:chef_run) { ChefSpec::SoloRunner.converge(described_recipe) }
5
10
 
@@ -1,5 +1,10 @@
1
1
  require 'chefspec'
2
2
 
3
+ RSpec.configure do |config|
4
+ config.platform = 'solaris2'
5
+ config.version = '5.11'
6
+ end
7
+
3
8
  describe 'ips_package::upgrade' do
4
9
  let(:chef_run) { ChefSpec::SoloRunner.converge(described_recipe) }
5
10
 
@@ -11,3 +11,7 @@ end
11
11
  package 'specifying the identity attribute' do
12
12
  package_name 'identity_attribute'
13
13
  end
14
+
15
+ package ['with', 'array'] do
16
+ action :install
17
+ end
@@ -11,3 +11,7 @@ package 'specifying the identity attribute' do
11
11
  package_name 'identity_attribute'
12
12
  action :purge
13
13
  end
14
+
15
+ package ['with', 'array'] do
16
+ action :purge
17
+ end
@@ -11,3 +11,7 @@ package 'specifying the identity attribute' do
11
11
  package_name 'identity_attribute'
12
12
  action :reconfig
13
13
  end
14
+
15
+ package ['with', 'array'] do
16
+ action :reconfig
17
+ end
@@ -11,3 +11,7 @@ package 'specifying the identity attribute' do
11
11
  package_name 'identity_attribute'
12
12
  action :remove
13
13
  end
14
+
15
+ package ['with', 'array'] do
16
+ action :remove
17
+ end
@@ -11,3 +11,7 @@ package 'specifying the identity attribute' do
11
11
  package_name 'identity_attribute'
12
12
  action :upgrade
13
13
  end
14
+
15
+ package ['with', 'array'] do
16
+ action :upgrade
17
+ end
@@ -20,4 +20,8 @@ describe 'package::install' do
20
20
  it 'installs a package when specifying the identity attribute' do
21
21
  expect(chef_run).to install_package('identity_attribute')
22
22
  end
23
+
24
+ it 'installs all packages when given an array of names' do
25
+ expect(chef_run).to install_package(['with', 'array'])
26
+ end
23
27
  end
@@ -16,4 +16,8 @@ describe 'package::purge' do
16
16
  it 'purges a package when specifying the identity attribute' do
17
17
  expect(chef_run).to purge_package('identity_attribute')
18
18
  end
19
+
20
+ it 'purges all packages when given an array of names' do
21
+ expect(chef_run).to purge_package(['with', 'array'])
22
+ end
19
23
  end
@@ -16,4 +16,8 @@ describe 'package::reconfig' do
16
16
  it 'reconfigs a package when specifying the identity attribute' do
17
17
  expect(chef_run).to reconfig_package('identity_attribute')
18
18
  end
19
+
20
+ it 'reconfigs all packages when given an array of names' do
21
+ expect(chef_run).to reconfig_package(['with', 'array'])
22
+ end
19
23
  end
@@ -16,4 +16,8 @@ describe 'package::remove' do
16
16
  it 'removes a package when specifying the identity attribute' do
17
17
  expect(chef_run).to remove_package('identity_attribute')
18
18
  end
19
+
20
+ it 'removes all packages when given an array of names' do
21
+ expect(chef_run).to remove_package(['with', 'array'])
22
+ end
19
23
  end
@@ -16,4 +16,8 @@ describe 'package::upgrade' do
16
16
  it 'upgrades a package when specifying the identity attribute' do
17
17
  expect(chef_run).to upgrade_package('identity_attribute')
18
18
  end
19
+
20
+ it 'upgrades all packages when given an array of names' do
21
+ expect(chef_run).to upgrade_package(['with', 'array'])
22
+ end
19
23
  end
@@ -1,5 +1,10 @@
1
1
  require 'chefspec'
2
2
 
3
+ RSpec.configure do |config|
4
+ config.platform = 'arch'
5
+ config.version = '3.10.5-1-ARCH'
6
+ end
7
+
3
8
  describe 'pacman_package::install' do
4
9
  let(:chef_run) { ChefSpec::SoloRunner.converge(described_recipe) }
5
10
 
@@ -1,5 +1,10 @@
1
1
  require 'chefspec'
2
2
 
3
+ RSpec.configure do |config|
4
+ config.platform = 'arch'
5
+ config.version = '3.10.5-1-ARCH'
6
+ end
7
+
3
8
  describe 'pacman_package::purge' do
4
9
  let(:chef_run) { ChefSpec::SoloRunner.converge(described_recipe) }
5
10
 
@@ -1,5 +1,10 @@
1
1
  require 'chefspec'
2
2
 
3
+ RSpec.configure do |config|
4
+ config.platform = 'arch'
5
+ config.version = '3.10.5-1-ARCH'
6
+ end
7
+
3
8
  describe 'pacman_package::remove' do
4
9
  let(:chef_run) { ChefSpec::SoloRunner.converge(described_recipe) }
5
10
 
@@ -1,5 +1,10 @@
1
1
  require 'chefspec'
2
2
 
3
+ RSpec.configure do |config|
4
+ config.platform = 'arch'
5
+ config.version = '3.10.5-1-ARCH'
6
+ end
7
+
3
8
  describe 'pacman_package::upgrade' do
4
9
  let(:chef_run) { ChefSpec::SoloRunner.converge(described_recipe) }
5
10
 
@@ -1,5 +1,10 @@
1
1
  require 'chefspec'
2
2
 
3
+ RSpec.configure do |config|
4
+ config.platform = 'windows'
5
+ config.version = '2012R2'
6
+ end
7
+
3
8
  describe 'powershell_script::run' do
4
9
  let(:chef_run) { ChefSpec::SoloRunner.converge(described_recipe) }
5
10
 
@@ -0,0 +1,3 @@
1
+ reboot 'explicit cancel' do
2
+ action :cancel
3
+ end
@@ -0,0 +1,3 @@
1
+ reboot 'explicit_action' do
2
+ action :reboot_now
3
+ end
@@ -0,0 +1,3 @@
1
+ reboot 'explicit_action' do
2
+ action :request_reboot
3
+ end
@@ -0,0 +1,10 @@
1
+ require 'chefspec'
2
+
3
+ describe 'reboot::cancel' do
4
+ let(:chef_run) { ChefSpec::SoloRunner.converge(described_recipe) }
5
+
6
+ it 'runs a cancel_reboot' do
7
+ expect(chef_run).to cancel_reboot('explicit cancel')
8
+ end
9
+ end
10
+
@@ -0,0 +1,10 @@
1
+ require 'chefspec'
2
+
3
+ describe 'reboot::now' do
4
+ let(:chef_run) { ChefSpec::SoloRunner.converge(described_recipe) }
5
+
6
+ it 'runs a reboot_now when specifying action' do
7
+ expect(chef_run).to now_reboot('explicit_action')
8
+ end
9
+ end
10
+
@@ -0,0 +1,10 @@
1
+ require 'chefspec'
2
+
3
+ describe 'reboot::request' do
4
+ let(:chef_run) { ChefSpec::SoloRunner.converge(described_recipe) }
5
+
6
+ it 'runs a request_reboot' do
7
+ expect(chef_run).to request_reboot('explicit_action')
8
+ end
9
+ end
10
+
@@ -19,6 +19,16 @@ describe 'render_file::default' do
19
19
  expect(chef_run).to_not render_file('/tmp/file').with_content(/^Not(.+)$/)
20
20
  end
21
21
 
22
+ it 'renders the file when given a block' do
23
+ expect(chef_run).to render_file('/tmp/file').with_content { |content|
24
+ expect(content).to include('This is content!')
25
+ }
26
+
27
+ expect(chef_run).to render_file('/tmp/file').with_content { |content|
28
+ expect(content).to_not include('This is not content!')
29
+ }
30
+ end
31
+
22
32
  it 'renders the file with content matching arbitrary matcher' do
23
33
  expect(chef_run).to render_file('/tmp/file').with_content(
24
34
  start_with('This')
@@ -46,6 +56,16 @@ describe 'render_file::default' do
46
56
  expect(chef_run).to_not render_file('/tmp/cookbook_file').with_content(/^Not(.+)$/)
47
57
  end
48
58
 
59
+ it 'renders the file when given a block' do
60
+ expect(chef_run).to render_file('/tmp/cookbook_file').with_content { |content|
61
+ expect(content).to include('This is content!')
62
+ }
63
+
64
+ expect(chef_run).to render_file('/tmp/cookbook_file').with_content { |content|
65
+ expect(content).to_not include('This is not content!')
66
+ }
67
+ end
68
+
49
69
  it 'renders the file with content matching arbitrary matcher' do
50
70
  expect(chef_run).to render_file('/tmp/cookbook_file').with_content(
51
71
  start_with('This')
@@ -86,6 +106,16 @@ describe 'render_file::default' do
86
106
  expect(chef_run).to_not render_file('/tmp/template').with_content(/^Not(.+)$/)
87
107
  end
88
108
 
109
+ it 'renders the file when given a block' do
110
+ expect(chef_run).to render_file('/tmp/template').with_content { |content|
111
+ expect(content).to include('This is content!')
112
+ }
113
+
114
+ expect(chef_run).to render_file('/tmp/template').with_content { |content|
115
+ expect(content).to_not include('This is not content!')
116
+ }
117
+ end
118
+
89
119
  it 'renders the file with content matching arbitrary matcher' do
90
120
  expect(chef_run).to render_file('/tmp/template').with_content(
91
121
  start_with('This')
@@ -107,6 +137,16 @@ describe 'render_file::default' do
107
137
  expect(chef_run).to_not render_file('/tmp/partial').with_content('This template has a partial: This is not a template partial!')
108
138
  end
109
139
 
140
+ it 'renders the file when given a block' do
141
+ expect(chef_run).to render_file('/tmp/partial').with_content { |content|
142
+ expect(content).to include('has a partial')
143
+ }
144
+
145
+ expect(chef_run).to render_file('/tmp/partial').with_content { |content|
146
+ expect(content).to_not include('not a template partial')
147
+ }
148
+ end
149
+
110
150
  it 'renders the file with matching content' do
111
151
  expect(chef_run).to render_file('/tmp/partial').with_content(/^This(.+)$/)
112
152
  expect(chef_run).to_not render_file('/tmp/partial').with_content(/^Not(.+)$/)
@@ -1,5 +1,10 @@
1
1
  require 'chefspec'
2
2
 
3
+ RSpec.configure do |config|
4
+ config.platform = 'centos'
5
+ config.version = '6.5'
6
+ end
7
+
3
8
  describe 'rpm_package::install' do
4
9
  let(:chef_run) { ChefSpec::SoloRunner.converge(described_recipe) }
5
10
 
@@ -1,5 +1,10 @@
1
1
  require 'chefspec'
2
2
 
3
+ RSpec.configure do |config|
4
+ config.platform = 'centos'
5
+ config.version = '6.5'
6
+ end
7
+
3
8
  describe 'rpm_package::remove' do
4
9
  let(:chef_run) { ChefSpec::SoloRunner.converge(described_recipe) }
5
10
 
@@ -1,5 +1,10 @@
1
1
  require 'chefspec'
2
2
 
3
+ RSpec.configure do |config|
4
+ config.platform = 'centos'
5
+ config.version = '6.5'
6
+ end
7
+
3
8
  describe 'rpm_package::upgrade' do
4
9
  let(:chef_run) { ChefSpec::SoloRunner.converge(described_recipe) }
5
10
 
@@ -27,7 +27,7 @@ describe 'server::node' do
27
27
 
28
28
  node = chef_run.get_node('chefspec')
29
29
  expect(node['kernel']['name']).to eq('Linux')
30
- expect(node['kernel']['release']).to eq('3.2.0-26-generic')
30
+ expect(node['kernel']['release']).to eq('3.2.0-92-generic')
31
31
  expect(node['kernel']['machine']).to eq('x86_64')
32
32
  end
33
33
  end
@@ -34,6 +34,9 @@ describe 'server::search' do
34
34
 
35
35
  let(:chef_run) do
36
36
  ChefSpec::ServerRunner.new do |node, server|
37
+ node.set['bar'] = true
38
+ server.update_node(node)
39
+
37
40
  server.create_node(node_1)
38
41
  server.create_node(node_2)
39
42
  server.create_node(node_3)
@@ -44,6 +47,7 @@ describe 'server::search' do
44
47
  it 'finds all nodes with the bar attribute' do
45
48
  expect(chef_run).to write_log('nodes with an attribute')
46
49
  .with_message(<<-EOH.gsub(/^ {8}/, '').strip)
50
+ chefspec, FQDN: chefspec.local, hostname: chefspec
47
51
  node_1, FQDN: node_1.example.com, hostname: node_1
48
52
  node_2, FQDN: node_2.example.com, hostname: node_2
49
53
  node_3, FQDN: node_3.example.com, hostname: node_3
@@ -0,0 +1,3 @@
1
+ action :something do
2
+ log 'custom message'
3
+ end
@@ -1 +1,3 @@
1
1
  step_into_lwrp 'thing'
2
+
3
+ provides_this 'custom'
@@ -1,4 +1,4 @@
1
1
  actions :something
2
2
  default_action :something
3
3
 
4
- attribute :name, kind_of: String, name_attribute: true
4
+ attribute :name, kind_of: String, name_attribute: true
@@ -0,0 +1,6 @@
1
+ actions :something
2
+ default_action :something
3
+
4
+ provides :provides_this
5
+
6
+ attribute :name, kind_of: String, name_attribute: true
@@ -7,16 +7,24 @@ describe 'step_into::default' do
7
7
  it 'does not execute the LWRPs action' do
8
8
  expect(chef_run).to_not write_log('message')
9
9
  end
10
+
11
+ it 'does not execute the custom LWRPs action' do
12
+ expect(chef_run).to_not write_log('custom message')
13
+ end
10
14
  end
11
15
 
12
16
  context 'with :step_into' do
13
17
  let(:chef_run) do
14
- ChefSpec::SoloRunner.new(step_into: ['step_into_lwrp'])
18
+ ChefSpec::SoloRunner.new(step_into: ['step_into_lwrp', 'provides_this'])
15
19
  .converge(described_recipe)
16
20
  end
17
21
 
18
- it 'does execute the LWRPs action' do
22
+ it 'executes the LWRPs action' do
19
23
  expect(chef_run).to write_log('message')
20
24
  end
25
+
26
+ it 'executes the custom LWRPs action' do
27
+ expect(chef_run).to write_log('custom message')
28
+ end
21
29
  end
22
30
  end
@@ -0,0 +1,13 @@
1
+ windows_package 'explicit_action' do
2
+ action :install
3
+ end
4
+
5
+ windows_package 'with_attributes' do
6
+ installer_type :msi
7
+ action :install
8
+ end
9
+
10
+ windows_package 'specifying the identity attribute' do
11
+ name 'identity_attribute'
12
+ action :install
13
+ end
@@ -0,0 +1,13 @@
1
+ windows_package 'explicit_action' do
2
+ action :remove
3
+ end
4
+
5
+ windows_package 'with_attributes' do
6
+ installer_type :msi
7
+ action :remove
8
+ end
9
+
10
+ windows_package 'specifying the identity attribute' do
11
+ name 'identity_attribute'
12
+ action :remove
13
+ end
@@ -0,0 +1,24 @@
1
+ require 'chefspec'
2
+
3
+ RSpec.configure do |config|
4
+ config.platform = 'windows'
5
+ config.version = '2012R2'
6
+ end
7
+
8
+ describe 'windows_package::install' do
9
+ let(:chef_run) { ChefSpec::SoloRunner.converge(described_recipe) }
10
+
11
+ it 'installs a windows_package with an explicit action' do
12
+ expect(chef_run).to install_windows_package('explicit_action')
13
+ expect(chef_run).to_not install_windows_package('not_explicit_action')
14
+ end
15
+
16
+ it 'installs a windows_package with attributes' do
17
+ expect(chef_run).to install_windows_package('with_attributes').with(installer_type: :msi)
18
+ expect(chef_run).to_not install_windows_package('with_attributes').with(installer_type: 'bacon')
19
+ end
20
+
21
+ it 'installs a windows_package when specifying the identity attribute' do
22
+ expect(chef_run).to install_windows_package('identity_attribute')
23
+ end
24
+ end
@@ -0,0 +1,24 @@
1
+ require 'chefspec'
2
+
3
+ RSpec.configure do |config|
4
+ config.platform = 'windows'
5
+ config.version = '2012R2'
6
+ end
7
+
8
+ describe 'windows_package::remove' do
9
+ let(:chef_run) { ChefSpec::SoloRunner.converge(described_recipe) }
10
+
11
+ it 'removes a windows_package with an explicit action' do
12
+ expect(chef_run).to remove_windows_package('explicit_action')
13
+ expect(chef_run).to_not remove_windows_package('not_explicit_action')
14
+ end
15
+
16
+ it 'removes a windows_package with attributes' do
17
+ expect(chef_run).to remove_windows_package('with_attributes').with(installer_type: :msi)
18
+ expect(chef_run).to_not remove_windows_package('with_attributes').with(installer_type: 'bacon')
19
+ end
20
+
21
+ it 'removes a windows_package when specifying the identity attribute' do
22
+ expect(chef_run).to remove_windows_package('identity_attribute')
23
+ end
24
+ end
@@ -0,0 +1,13 @@
1
+ windows_service 'explicit_action' do
2
+ action :configure_startup
3
+ end
4
+
5
+ windows_service 'with_attributes' do
6
+ pattern 'pattern'
7
+ action :configure_startup
8
+ end
9
+
10
+ windows_service 'specifying the identity attribute' do
11
+ service_name 'identity_attribute'
12
+ action :configure_startup
13
+ end
@@ -0,0 +1,13 @@
1
+ windows_service 'explicit_action' do
2
+ action :disable
3
+ end
4
+
5
+ windows_service 'with_attributes' do
6
+ pattern 'pattern'
7
+ action :disable
8
+ end
9
+
10
+ windows_service 'specifying the identity attribute' do
11
+ service_name 'identity_attribute'
12
+ action :disable
13
+ end
@@ -0,0 +1,13 @@
1
+ windows_service 'explicit_action' do
2
+ action :enable
3
+ end
4
+
5
+ windows_service 'with_attributes' do
6
+ pattern 'pattern'
7
+ action :enable
8
+ end
9
+
10
+ windows_service 'specifying the identity attribute' do
11
+ service_name 'identity_attribute'
12
+ action :enable
13
+ end
@@ -0,0 +1,13 @@
1
+ windows_service 'explicit_action' do
2
+ action :reload
3
+ end
4
+
5
+ windows_service 'with_attributes' do
6
+ pattern 'pattern'
7
+ action :reload
8
+ end
9
+
10
+ windows_service 'specifying the identity attribute' do
11
+ service_name 'identity_attribute'
12
+ action :reload
13
+ end
@@ -0,0 +1,13 @@
1
+ windows_service 'explicit_action' do
2
+ action :restart
3
+ end
4
+
5
+ windows_service 'with_attributes' do
6
+ pattern 'pattern'
7
+ action :restart
8
+ end
9
+
10
+ windows_service 'specifying the identity attribute' do
11
+ service_name 'identity_attribute'
12
+ action :restart
13
+ end
@@ -0,0 +1,13 @@
1
+ windows_service 'explicit_action' do
2
+ action :start
3
+ end
4
+
5
+ windows_service 'with_attributes' do
6
+ pattern 'pattern'
7
+ action :start
8
+ end
9
+
10
+ windows_service 'specifying the identity attribute' do
11
+ service_name 'identity_attribute'
12
+ action :start
13
+ end
@@ -0,0 +1,13 @@
1
+ windows_service 'explicit_action' do
2
+ action :stop
3
+ end
4
+
5
+ windows_service 'with_attributes' do
6
+ pattern 'pattern'
7
+ action :stop
8
+ end
9
+
10
+ windows_service 'specifying the identity attribute' do
11
+ service_name 'identity_attribute'
12
+ action :stop
13
+ end