chefspec 7.0.0 → 7.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (194) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +11 -1
  3. data/Gemfile +6 -0
  4. data/README.md +43 -11
  5. data/Rakefile +48 -8
  6. data/chefspec.gemspec +0 -8
  7. data/examples/cab_package/spec/install_spec.rb +20 -18
  8. data/examples/cab_package/spec/remove_spec.rb +17 -15
  9. data/examples/cached/spec/default_spec.rb +1 -0
  10. data/examples/compile_time/spec/default_spec.rb +2 -0
  11. data/examples/custom_matcher/libraries/matcher.rb +1 -23
  12. data/examples/dnf_package/spec/install_spec.rb +20 -18
  13. data/examples/dnf_package/spec/purge_spec.rb +17 -15
  14. data/examples/dnf_package/spec/remove_spec.rb +17 -15
  15. data/examples/dnf_package/spec/upgrade_spec.rb +17 -15
  16. data/examples/heavy_provider_light_resource/spec/provider_service_spec.rb +1 -0
  17. data/examples/msu_package/spec/install_spec.rb +20 -18
  18. data/examples/msu_package/spec/remove_spec.rb +17 -15
  19. data/examples/server/spec/exotic_port_spec.rb +15 -2
  20. data/lib/chefspec.rb +1 -8
  21. data/lib/chefspec/api.rb +6 -84
  22. data/lib/chefspec/api/do_nothing.rb +18 -21
  23. data/lib/chefspec/api/include_recipe.rb +20 -23
  24. data/lib/chefspec/api/link.rb +20 -99
  25. data/lib/chefspec/api/notifications.rb +32 -35
  26. data/lib/chefspec/api/reboot.rb +5 -14
  27. data/lib/chefspec/api/render_file.rb +29 -32
  28. data/lib/chefspec/api/state_attrs.rb +22 -25
  29. data/lib/chefspec/api/subscriptions.rb +29 -32
  30. data/lib/chefspec/api/user.rb +216 -219
  31. data/lib/chefspec/extensions.rb +16 -0
  32. data/lib/chefspec/extensions/chef/resource.rb +90 -8
  33. data/lib/chefspec/version.rb +1 -1
  34. data/lib/chefspec/zero_server.rb +20 -18
  35. metadata +3 -313
  36. data/examples/custom_resource/libraries/matchers.rb +0 -5
  37. data/examples/use_inline_resources/libraries/matchers.rb +0 -5
  38. data/features/apt_package.feature +0 -14
  39. data/features/apt_repository.feature +0 -15
  40. data/features/apt_update.feature +0 -13
  41. data/features/attributes.feature +0 -7
  42. data/features/batch.feature +0 -10
  43. data/features/bff_package.feature +0 -12
  44. data/features/cab_package.feature +0 -21
  45. data/features/cached.feature +0 -7
  46. data/features/chef_gem.feature +0 -14
  47. data/features/chocolatey_package.feature +0 -14
  48. data/features/compile_time.feature +0 -7
  49. data/features/cookbook_file.feature +0 -13
  50. data/features/cron.feature +0 -11
  51. data/features/custom_matcher.feature +0 -11
  52. data/features/custom_resource.feature +0 -7
  53. data/features/deploy.feature +0 -12
  54. data/features/directory.feature +0 -11
  55. data/features/dnf_package.feature +0 -26
  56. data/features/do_nothing.feature +0 -10
  57. data/features/dpkg_package.feature +0 -12
  58. data/features/dsc_resource.feature +0 -10
  59. data/features/dsc_script.feature +0 -10
  60. data/features/env.feature +0 -12
  61. data/features/erl_call.feature +0 -10
  62. data/features/execute.feature +0 -10
  63. data/features/exotic_zero_port.feature +0 -7
  64. data/features/expect_exception.feature +0 -12
  65. data/features/file.feature +0 -13
  66. data/features/freebsd_package.feature +0 -11
  67. data/features/gem_package.feature +0 -14
  68. data/features/git.feature +0 -12
  69. data/features/group.feature +0 -13
  70. data/features/guards.feature +0 -10
  71. data/features/heavy_provider_light_resource.feature +0 -10
  72. data/features/homebrew_package.feature +0 -12
  73. data/features/http_request.feature +0 -15
  74. data/features/ifconfig.feature +0 -13
  75. data/features/include_recipe.feature +0 -10
  76. data/features/ips_package.feature +0 -12
  77. data/features/launchd.feature +0 -17
  78. data/features/link.feature +0 -12
  79. data/features/log.feature +0 -10
  80. data/features/macports_package.feature +0 -13
  81. data/features/mdadm.feature +0 -12
  82. data/features/mount.feature +0 -14
  83. data/features/msu_package.feature +0 -23
  84. data/features/multiple_actions.feature +0 -12
  85. data/features/multiple_run_action.feature +0 -7
  86. data/features/notifications.feature +0 -14
  87. data/features/ohai.feature +0 -10
  88. data/features/openbsd_package.feature +0 -12
  89. data/features/osx_profile.feature +0 -13
  90. data/features/package.feature +0 -14
  91. data/features/pacman_package.feature +0 -13
  92. data/features/paludis_package.feature +0 -12
  93. data/features/portage_package.feature +0 -13
  94. data/features/powershell_script.feature +0 -10
  95. data/features/reboot.feature +0 -12
  96. data/features/registry_key.feature +0 -13
  97. data/features/remote_directory.feature +0 -12
  98. data/features/remote_file.feature +0 -13
  99. data/features/render_file.feature +0 -11
  100. data/features/roles.feature +0 -7
  101. data/features/route.feature +0 -11
  102. data/features/rpm_package.feature +0 -12
  103. data/features/ruby_block.feature +0 -11
  104. data/features/script.feature +0 -16
  105. data/features/server.feature +0 -16
  106. data/features/server_on_disk.feature +0 -16
  107. data/features/service.feature +0 -15
  108. data/features/smartos_package.feature +0 -12
  109. data/features/solaris_package.feature +0 -12
  110. data/features/state_attrs.feature +0 -7
  111. data/features/step_definitions/background_steps.rb +0 -7
  112. data/features/step_into.feature +0 -7
  113. data/features/stub_command.feature +0 -7
  114. data/features/stub_data_bag.feature +0 -7
  115. data/features/stub_data_bag_item.feature +0 -7
  116. data/features/stub_node.feature +0 -7
  117. data/features/stub_search.feature +0 -7
  118. data/features/subscribes.feature +0 -14
  119. data/features/subversion.feature +0 -13
  120. data/features/support/env.rb +0 -38
  121. data/features/support/executor.rb +0 -20
  122. data/features/support/exotic_zero_port.rb +0 -3
  123. data/features/support/on_disk.rb +0 -7
  124. data/features/systemd_unit.feature +0 -27
  125. data/features/template.feature +0 -13
  126. data/features/use_inline_resources.feature +0 -7
  127. data/features/user.feature +0 -15
  128. data/features/windows_package.feature +0 -11
  129. data/features/windows_service.feature +0 -16
  130. data/features/yum_package.feature +0 -13
  131. data/features/yum_repository.feature +0 -23
  132. data/features/zypper_package.feature +0 -13
  133. data/lib/chefspec/api/apt_package.rb +0 -192
  134. data/lib/chefspec/api/apt_repository.rb +0 -56
  135. data/lib/chefspec/api/apt_update.rb +0 -53
  136. data/lib/chefspec/api/batch.rb +0 -43
  137. data/lib/chefspec/api/bff_package.rb +0 -154
  138. data/lib/chefspec/api/cab_package.rb +0 -80
  139. data/lib/chefspec/api/chef_gem.rb +0 -191
  140. data/lib/chefspec/api/chocolatey_package.rb +0 -107
  141. data/lib/chefspec/api/cookbook_file.rb +0 -166
  142. data/lib/chefspec/api/cron.rb +0 -80
  143. data/lib/chefspec/api/deploy.rb +0 -117
  144. data/lib/chefspec/api/directory.rb +0 -80
  145. data/lib/chefspec/api/dnf_package.rb +0 -154
  146. data/lib/chefspec/api/dpkg_package.rb +0 -117
  147. data/lib/chefspec/api/dsc_resource.rb +0 -49
  148. data/lib/chefspec/api/dsc_script.rb +0 -37
  149. data/lib/chefspec/api/easy_install_package.rb +0 -154
  150. data/lib/chefspec/api/env.rb +0 -117
  151. data/lib/chefspec/api/erl_call.rb +0 -43
  152. data/lib/chefspec/api/execute.rb +0 -43
  153. data/lib/chefspec/api/file.rb +0 -166
  154. data/lib/chefspec/api/freebsd_package.rb +0 -80
  155. data/lib/chefspec/api/gem_package.rb +0 -191
  156. data/lib/chefspec/api/git.rb +0 -117
  157. data/lib/chefspec/api/group.rb +0 -154
  158. data/lib/chefspec/api/homebrew_package.rb +0 -154
  159. data/lib/chefspec/api/http_request.rb +0 -228
  160. data/lib/chefspec/api/ifconfig.rb +0 -154
  161. data/lib/chefspec/api/ips_package.rb +0 -117
  162. data/lib/chefspec/api/launchd.rb +0 -151
  163. data/lib/chefspec/api/log.rb +0 -43
  164. data/lib/chefspec/api/macports_package.rb +0 -154
  165. data/lib/chefspec/api/mdadm.rb +0 -117
  166. data/lib/chefspec/api/mount.rb +0 -192
  167. data/lib/chefspec/api/msu_package.rb +0 -81
  168. data/lib/chefspec/api/ohai.rb +0 -43
  169. data/lib/chefspec/api/openbsd_package.rb +0 -155
  170. data/lib/chefspec/api/osx_profile.rb +0 -63
  171. data/lib/chefspec/api/package.rb +0 -192
  172. data/lib/chefspec/api/pacman_package.rb +0 -155
  173. data/lib/chefspec/api/paludis_package.rb +0 -155
  174. data/lib/chefspec/api/portage_package.rb +0 -155
  175. data/lib/chefspec/api/powershell_script.rb +0 -43
  176. data/lib/chefspec/api/registry_key.rb +0 -166
  177. data/lib/chefspec/api/remote_directory.rb +0 -120
  178. data/lib/chefspec/api/remote_file.rb +0 -166
  179. data/lib/chefspec/api/route.rb +0 -80
  180. data/lib/chefspec/api/rpm_package.rb +0 -117
  181. data/lib/chefspec/api/ruby_block.rb +0 -68
  182. data/lib/chefspec/api/script.rb +0 -278
  183. data/lib/chefspec/api/service.rb +0 -246
  184. data/lib/chefspec/api/smartos_package.rb +0 -117
  185. data/lib/chefspec/api/solaris_package.rb +0 -117
  186. data/lib/chefspec/api/subversion.rb +0 -154
  187. data/lib/chefspec/api/systemd_unit.rb +0 -353
  188. data/lib/chefspec/api/template.rb +0 -166
  189. data/lib/chefspec/api/windows_package.rb +0 -86
  190. data/lib/chefspec/api/windows_service.rb +0 -286
  191. data/lib/chefspec/api/yum_package.rb +0 -154
  192. data/lib/chefspec/api/yum_repository.rb +0 -130
  193. data/lib/chefspec/api/zypper_package.rb +0 -154
  194. data/spec/unit/api_spec.rb +0 -18
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c5200ce7871519ab0cc3ec4991be81a879de497e
4
- data.tar.gz: 06e54036feed75509905d6d0fa216fca5ad21e70
3
+ metadata.gz: a3617560994bd67eae8bece75bdfcd66c6fcc259
4
+ data.tar.gz: 953c6f0e6e1471483ad9d7fd1f9ecb8b7d77f5be
5
5
  SHA512:
6
- metadata.gz: c01f41111509834f0edfd555ccb1f6cd5b46286834884309ac1045b792404fe7110ad15669e9307f7b85f620eee3cdaf1e5a87c884ab4c41c06d5198b19223bc
7
- data.tar.gz: 90a5eba4f6aaa993733d2880f9fa591fc8504dad190ab855821be27d1d98712644bc2057e16d683e352f49144a1f6f2664d93db4da820349e0d6182801068e86
6
+ metadata.gz: 2f6016eb17cf6fcbb0497d1b9f097f5f4ddc54002572653ff87c666a60bb7819d38e4c452ff14bb3c49cb3c3705fbe79f373f00662e98a5524019b507bc509ee
7
+ data.tar.gz: ab41f6c8868ba16d5f6f350a847e5314d1c983bccb98aab78a9de6bd99ea0a835b95be565263b69c81777063ad98af3d4605a8f2e6fc4fce8363d15ec17d5151
@@ -1,6 +1,16 @@
1
1
  # CHANGELOG for ChefSpec
2
2
 
3
- ## 7.0.0 (April, 18, 2017)
3
+ ## 7.1.0 (May 9, 2017)
4
+
5
+ - Resource matchers are now generated automatically. What does this mean for you? A lot:
6
+ 1. You won't have to worry about older releases of ChefSpec not knowing about new resources in chef-client.
7
+ 2. You won't have to define the matchers in your cookbook code, which also means you won't have issues if a community cookbook lacks matchers
8
+
9
+ - Removed the usage of Cucumber for testing
10
+ - Removed all test deps from the Gemspec
11
+ - Added a warning about stubbing core Ruby methods and the issues that can cause
12
+
13
+ ## 7.0.0 (April 18, 2017)
4
14
 
5
15
  - Increased the chef gem dependency from 12.6+ to 12.14+. Since ChefSpec is consumed within ChefDK this actually has a minor impact on end users who generally consume Chefspec via ChefDK, which will bundle both compatible chef and chefspec releases.
6
16
  - Fixed incompatibilities with Chef 13.
data/Gemfile CHANGED
@@ -10,3 +10,9 @@ if ENV['CHEF_VERSION']
10
10
  end
11
11
 
12
12
  gemspec
13
+
14
+ group :development do
15
+ gem 'rake'
16
+ gem 'redcarpet'
17
+ gem 'yard'
18
+ end
data/README.md CHANGED
@@ -9,26 +9,18 @@ ChefSpec runs your cookbook(s) locally with Chef Solo without actually convergin
9
9
  - It's really fast!
10
10
  - Your tests can vary node attributes, operating systems, and search results to assert behavior under varying conditions.
11
11
 
12
- ## What people are saying
13
-
14
- > I just wanted to drop you a line to say "HELL YES!" to ChefSpec. - [Joe Goggins](https://twitter.com/jgoggins)
15
-
16
- > OK ChefSpec is my new best friend. Delightful few hours working with it. - [Michael Ivey](https://twitter.com/ivey)
17
-
18
- **Chat with us - [#chefspec](irc://irc.freenode.net/chefspec) on Freenode**
19
-
20
12
  ## Important Notes
21
13
 
22
14
  - **ChefSpec requires Ruby 2.2 or later and Chef 12.14.89 or later!**
23
15
  - **This documentation corresponds to the master branch, which may be unreleased. Please check the README of the latest git tag or the gem's source for your version's documentation!**
24
- - **Each resource matcher is self-documented using [Yard](http://rubydoc.info/github/sethvargo/chefspec) and has a corresponding aruba test from the [examples directory](https://github.com/sethvargo/chefspec/tree/master/examples).**
25
- - **ChefSpec aims to maintain compatibility with the two most recent minor versions of Chef.** If you are running an older version of Chef it may work, or you will need to run an older version of ChefSpec.
16
+ - **Each resource matcher is self-documented using [Yard](http://rubydoc.info/github/sethvargo/chefspec) and has a corresponding test recipe in the [examples directory](https://github.com/sethvargo/chefspec/tree/master/examples).**
26
17
 
27
18
  ## Notes on Compatibility with Chef Versions
28
19
 
20
+ **ChefSpec aims to maintain compatibility with the two most recent minor versions of Chef.** If you are running an older version of Chef it may work, or you will need to run an older version of ChefSpec.
21
+
29
22
  As a general rule, if it is tested in the Travis CI matrix, it is a supported version. The section below details any specific versions that are _not_ supported and why:
30
23
 
31
- Additionally, if you look at a cucumber feature and see a tag like `@not_chef_x_y_z`, that means that particular functionality is not supported on those versions of Chef.
32
24
 
33
25
  ## Writing a Cookbook Example
34
26
 
@@ -710,6 +702,34 @@ describe 'example::default' do
710
702
  end
711
703
  ```
712
704
 
705
+ ### Ruby libraries (File, FileUtils, etc)
706
+
707
+ When stubbing core ruby libraries, users must be aware that there is no differentiation between your cookbook code that calls `File.exist?` and core chef
708
+ code (e.g. the cookbook loader) that calls `File.exist?`. If you stub or setup an expectation without qualifying the arguments then you will stub that
709
+ method for all core chef code as well. Also note that if you setup an expectation on a particular argument that invoking the method with any other
710
+ argument will throw an unexpected argument error out of rspec, so you must setup an allowance using `.and_call_original` to avoid breaking core chef.
711
+
712
+ ```ruby
713
+ describe 'example::default' do
714
+ let(:chef_run) { ChefSpec::SoloRunner.new }
715
+
716
+ before do
717
+ # avoid breaking all of core chef wherever it calls File.exist? with other arguments
718
+ allow(File).to receive(:exist?).and_call_original
719
+ end
720
+
721
+ it "tests something when /etc/myfile.txt does not exist" do
722
+ # only setup an expectation on our file
723
+ expect(File).to receive(:exist?).with("/etc/myfile.txt").and_return(false)
724
+ [ ... test that the chef resource collection is constructed correctly in this case ... ]
725
+ end
726
+ end
727
+ ```
728
+
729
+ This is basic usage of rspec and not specific to chefspec. It applies to any class method in `File`, `Dir`, `FileUtils`, `IO` or any other ruby library. In
730
+ general any time you `expect(Some::Symbol).to receive(:a_method).and_return(value)` you run the risk of breaking other code unless you isolate your mocking
731
+ or expectation down to only the arguments which your code uses.
732
+
713
733
  ## Reporting
714
734
 
715
735
  ChefSpec can generate a report of resources read over resources tested.
@@ -893,6 +913,18 @@ end
893
913
 
894
914
  **NOTE:** If your cookbook exposes LWRPs, it is highly recommended you also create a `libraries/matchers.rb` file as outlined below in the "Packaging Custom Matchers" section. **You should never `step_into` an LWRP unless you are testing it. Never `step_into` an LWRP from another cookbook!**
895
915
 
916
+ ## Automatic Matchers
917
+
918
+ As of ChefSpec 7.1.0 there are "custom" matchers generated for all internal core-chef resources, along with any LWRPs/HWRPs/Custom Resources that are user-defined in cookbooks.
919
+
920
+ The matchers follow the standard custom of `<action>_<resource_name>` with the exception of the `create_if_missing` action which *also* gets a `create_<resource_name>_if_missing`
921
+ matcher.
922
+
923
+ Matchers should be wired up for the `resource_name` of the resource along with all define `provides` lines synonyms and any `action` methods or `allowed_actions`.
924
+
925
+ There should be little reason to package custom matchers in cookbooks any more, but the approach below still works if there are special matchers which cookbooks wish to expose which do
926
+ not follow the automatically generated pattern.
927
+
896
928
  ## Packaging Custom Matchers
897
929
 
898
930
  ChefSpec exposes the ability for cookbook authors to package custom matchers inside a cookbook so that other developers may take advantage of them in testing. This is done by creating a special library file in the cookbook named `matchers.rb`:
data/Rakefile CHANGED
@@ -1,7 +1,10 @@
1
1
  require 'bundler/gem_tasks'
2
- require 'cucumber/rake/task'
2
+ require 'rspec/core'
3
3
  require 'rspec/core/rake_task'
4
4
  require 'yard/rake/yardoc_task'
5
+ require 'tmpdir'
6
+ require 'rspec'
7
+ require 'chefspec'
5
8
 
6
9
  require 'chef/version'
7
10
 
@@ -14,13 +17,50 @@ RSpec::Core::RakeTask.new(:unit) do |t|
14
17
  end.join(' ')
15
18
  end
16
19
 
17
- Cucumber::Rake::Task.new(:acceptance) do |t|
18
- t.cucumber_opts = [].tap do |a|
19
- a.push('--color')
20
- a.push('--format progress')
21
- a.push('--strict')
22
- a.push('--tags ~@not_chef_' + Chef::VERSION.gsub('.', '_'))
23
- end.join(' ')
20
+ failed = false
21
+
22
+ namespace :acceptance do |ns|
23
+ Dir.foreach("examples") do |dir|
24
+ next if dir == '.' or dir == '..'
25
+ desc "#{dir} acceptance tests"
26
+ task dir.to_sym do
27
+ Dir.mktmpdir do |tmp|
28
+ FileUtils.cp_r("examples/#{dir}", tmp)
29
+
30
+ pwd = Dir.pwd
31
+
32
+ Dir.chdir "#{tmp}/#{dir}" do
33
+ puts "rspec examples/#{dir}"
34
+
35
+ #
36
+ # This bit of mildly awful magic below is to load each file into an in-memory
37
+ # RSpec runner while keeping a persistent ChefZero server alive.
38
+ #
39
+ load "#{pwd}/lib/chefspec/rspec.rb"
40
+
41
+ RSpec.configure do |config|
42
+ config.color = true
43
+ config.before(:suite) do
44
+ ChefSpec::ZeroServer.setup!
45
+ end
46
+ config.after(:each) do
47
+ ChefSpec::ZeroServer.reset!
48
+ end
49
+ end
50
+
51
+ RSpec.clear_examples
52
+ exitstatus = RSpec::Core::Runner.run(["spec"])
53
+ RSpec.reset
54
+ failed = true unless exitstatus == 0
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
60
+
61
+
62
+ task acceptance: Rake.application.tasks.select { |t| t.name.start_with?("acceptance:") } do
63
+ raise "some tests failed" if failed
24
64
  end
25
65
 
26
66
  desc 'Run all tests'
@@ -28,12 +28,4 @@ Gem::Specification.new do |s|
28
28
  s.add_dependency 'chef', '>= 12.14.89'
29
29
  s.add_dependency 'fauxhai', '>= 4', '< 6'
30
30
  s.add_dependency 'rspec', '~> 3.0'
31
-
32
- # Development Dependencies
33
- s.add_development_dependency 'rake', '< 13.0'
34
- s.add_development_dependency 'redcarpet', '~> 3.3'
35
- s.add_development_dependency 'yard', '~> 0.8'
36
-
37
- # Testing Dependencies
38
- s.add_development_dependency 'aruba', '~> 0.8'
39
31
  end
@@ -1,26 +1,28 @@
1
1
  require 'chefspec'
2
2
 
3
- describe 'cab_package::install' do
4
- let(:chef_run) do
5
- ChefSpec::ServerRunner.new(platform: 'windows', version: '2012R2')
6
- .converge(described_recipe)
7
- end
3
+ if defined?(Chef::Resource::CabPackage)
4
+ describe 'cab_package::install' do
5
+ let(:chef_run) do
6
+ ChefSpec::ServerRunner.new(platform: 'windows', version: '2012R2')
7
+ .converge(described_recipe)
8
+ end
8
9
 
9
- it 'installs a cab_package with the default action' do
10
- expect(chef_run).to install_cab_package('default_action')
11
- expect(chef_run).to_not install_cab_package('not_default_action')
12
- end
10
+ it 'installs a cab_package with the default action' do
11
+ expect(chef_run).to install_cab_package('default_action')
12
+ expect(chef_run).to_not install_cab_package('not_default_action')
13
+ end
13
14
 
14
- it 'installs a cab_package with an explicit action' do
15
- expect(chef_run).to install_cab_package('explicit_action')
16
- end
15
+ it 'installs a cab_package with an explicit action' do
16
+ expect(chef_run).to install_cab_package('explicit_action')
17
+ end
17
18
 
18
- it 'installs a cab_package with attributes' do
19
- expect(chef_run).to install_cab_package('with_attributes').with(version: '1.2.3')
20
- expect(chef_run).to_not install_cab_package('with_attributes').with(version: '1.2.4')
21
- end
19
+ it 'installs a cab_package with attributes' do
20
+ expect(chef_run).to install_cab_package('with_attributes').with(version: '1.2.3')
21
+ expect(chef_run).to_not install_cab_package('with_attributes').with(version: '1.2.4')
22
+ end
22
23
 
23
- it 'installs a cab_package when specifying the identity attribute' do
24
- expect(chef_run).to install_cab_package('identity_attribute')
24
+ it 'installs a cab_package when specifying the identity attribute' do
25
+ expect(chef_run).to install_cab_package('identity_attribute')
26
+ end
25
27
  end
26
28
  end
@@ -1,22 +1,24 @@
1
1
  require 'chefspec'
2
2
 
3
- describe 'cab_package::remove' do
4
- let(:chef_run) do
5
- ChefSpec::ServerRunner.new(platform: 'windows', version: '2012R2')
6
- .converge(described_recipe)
7
- end
3
+ if defined?(Chef::Resource::CabPackage)
4
+ describe 'cab_package::remove' do
5
+ let(:chef_run) do
6
+ ChefSpec::ServerRunner.new(platform: 'windows', version: '2012R2')
7
+ .converge(described_recipe)
8
+ end
8
9
 
9
- it 'removes a cab_package with an explicit action' do
10
- expect(chef_run).to remove_cab_package('explicit_action')
11
- expect(chef_run).to_not remove_cab_package('not_explicit_action')
12
- end
10
+ it 'removes a cab_package with an explicit action' do
11
+ expect(chef_run).to remove_cab_package('explicit_action')
12
+ expect(chef_run).to_not remove_cab_package('not_explicit_action')
13
+ end
13
14
 
14
- it 'removes a cab_package with attributes' do
15
- expect(chef_run).to remove_cab_package('with_attributes').with(version: '1.2.3')
16
- expect(chef_run).to_not remove_cab_package('with_attributes').with(version: '1.2.4')
17
- end
15
+ it 'removes a cab_package with attributes' do
16
+ expect(chef_run).to remove_cab_package('with_attributes').with(version: '1.2.3')
17
+ expect(chef_run).to_not remove_cab_package('with_attributes').with(version: '1.2.4')
18
+ end
18
19
 
19
- it 'removes a cab_package when specifying the identity attribute' do
20
- expect(chef_run).to remove_cab_package('identity_attribute')
20
+ it 'removes a cab_package when specifying the identity attribute' do
21
+ expect(chef_run).to remove_cab_package('identity_attribute')
22
+ end
21
23
  end
22
24
  end
@@ -1,3 +1,4 @@
1
+ require 'chefspec'
1
2
  require 'chefspec/cacher'
2
3
 
3
4
  RSpec.configure do |config|
@@ -1,3 +1,5 @@
1
+ require 'chefspec'
2
+
1
3
  describe 'compile_time::default' do
2
4
  let(:chef_run) { ChefSpec::ServerRunner.new(platform: 'ubuntu', version: '16.04').converge(described_recipe) }
3
5
 
@@ -1,23 +1 @@
1
- if defined?(ChefSpec)
2
- ChefSpec.define_matcher :custom_matcher_thing
3
-
4
- #
5
- # When defining a custom LWRP matcher, you should always add some
6
- # documentation indicating how to use the custom matcher.
7
- #
8
- # @example This is an example
9
- # expect(chef_run).to install_custom_matcher_thing('foo')
10
- #
11
- # @param [String] resource_name
12
- # the resource name
13
- #
14
- # @return [ChefSpec::Matchers::ResourceMatcher]
15
- #
16
- def install_custom_matcher_thing(resource_name)
17
- ChefSpec::Matchers::ResourceMatcher.new(:custom_matcher_thing, :install, resource_name)
18
- end
19
-
20
- def remove_custom_matcher_thing(resource_name)
21
- ChefSpec::Matchers::ResourceMatcher.new(:custom_matcher_thing, :remove, resource_name)
22
- end
23
- end
1
+ # this file is no longer required
@@ -1,26 +1,28 @@
1
1
  require 'chefspec'
2
2
 
3
- describe 'dnf_package::install' do
4
- let(:chef_run) do
5
- ChefSpec::ServerRunner.new(platform: 'fedora', version: '25')
6
- .converge(described_recipe)
7
- end
3
+ if defined?(Chef::Resource::DnfPackage)
4
+ describe 'dnf_package::install' do
5
+ let(:chef_run) do
6
+ ChefSpec::ServerRunner.new(platform: 'fedora', version: '25')
7
+ .converge(described_recipe)
8
+ end
8
9
 
9
- it 'installs a dnf_package with the default action' do
10
- expect(chef_run).to install_dnf_package('default_action')
11
- expect(chef_run).to_not install_dnf_package('not_default_action')
12
- end
10
+ it 'installs a dnf_package with the default action' do
11
+ expect(chef_run).to install_dnf_package('default_action')
12
+ expect(chef_run).to_not install_dnf_package('not_default_action')
13
+ end
13
14
 
14
- it 'installs a dnf_package with an explicit action' do
15
- expect(chef_run).to install_dnf_package('explicit_action')
16
- end
15
+ it 'installs a dnf_package with an explicit action' do
16
+ expect(chef_run).to install_dnf_package('explicit_action')
17
+ end
17
18
 
18
- it 'installs a dnf_package with attributes' do
19
- expect(chef_run).to install_dnf_package('with_attributes').with(version: '1.0.0')
20
- expect(chef_run).to_not install_dnf_package('with_attributes').with(version: '1.2.3')
21
- end
19
+ it 'installs a dnf_package with attributes' do
20
+ expect(chef_run).to install_dnf_package('with_attributes').with(version: '1.0.0')
21
+ expect(chef_run).to_not install_dnf_package('with_attributes').with(version: '1.2.3')
22
+ end
22
23
 
23
- it 'installs a dnf_package when specifying the identity attribute' do
24
- expect(chef_run).to install_dnf_package('identity_attribute')
24
+ it 'installs a dnf_package when specifying the identity attribute' do
25
+ expect(chef_run).to install_dnf_package('identity_attribute')
26
+ end
25
27
  end
26
28
  end
@@ -1,22 +1,24 @@
1
1
  require 'chefspec'
2
2
 
3
- describe 'dnf_package::purge' do
4
- let(:chef_run) do
5
- ChefSpec::ServerRunner.new(platform: 'fedora', version: '25')
6
- .converge(described_recipe)
7
- end
3
+ if defined?(Chef::Resource::DnfPackage)
4
+ describe 'dnf_package::purge' do
5
+ let(:chef_run) do
6
+ ChefSpec::ServerRunner.new(platform: 'fedora', version: '25')
7
+ .converge(described_recipe)
8
+ end
8
9
 
9
- it 'purges a dnf_package with an explicit action' do
10
- expect(chef_run).to purge_dnf_package('explicit_action')
11
- expect(chef_run).to_not purge_dnf_package('not_explicit_action')
12
- end
10
+ it 'purges a dnf_package with an explicit action' do
11
+ expect(chef_run).to purge_dnf_package('explicit_action')
12
+ expect(chef_run).to_not purge_dnf_package('not_explicit_action')
13
+ end
13
14
 
14
- it 'purges a dnf_package with attributes' do
15
- expect(chef_run).to purge_dnf_package('with_attributes').with(version: '1.0.0')
16
- expect(chef_run).to_not purge_dnf_package('with_attributes').with(version: '1.2.3')
17
- end
15
+ it 'purges a dnf_package with attributes' do
16
+ expect(chef_run).to purge_dnf_package('with_attributes').with(version: '1.0.0')
17
+ expect(chef_run).to_not purge_dnf_package('with_attributes').with(version: '1.2.3')
18
+ end
18
19
 
19
- it 'purges a dnf_package when specifying the identity attribute' do
20
- expect(chef_run).to purge_dnf_package('identity_attribute')
20
+ it 'purges a dnf_package when specifying the identity attribute' do
21
+ expect(chef_run).to purge_dnf_package('identity_attribute')
22
+ end
21
23
  end
22
24
  end
@@ -1,22 +1,24 @@
1
1
  require 'chefspec'
2
2
 
3
- describe 'dnf_package::remove' do
4
- let(:chef_run) do
5
- ChefSpec::ServerRunner.new(platform: 'fedora', version: '25')
6
- .converge(described_recipe)
7
- end
3
+ if defined?(Chef::Resource::DnfPackage)
4
+ describe 'dnf_package::remove' do
5
+ let(:chef_run) do
6
+ ChefSpec::ServerRunner.new(platform: 'fedora', version: '25')
7
+ .converge(described_recipe)
8
+ end
8
9
 
9
- it 'removes a dnf_package with an explicit action' do
10
- expect(chef_run).to remove_dnf_package('explicit_action')
11
- expect(chef_run).to_not remove_dnf_package('not_explicit_action')
12
- end
10
+ it 'removes a dnf_package with an explicit action' do
11
+ expect(chef_run).to remove_dnf_package('explicit_action')
12
+ expect(chef_run).to_not remove_dnf_package('not_explicit_action')
13
+ end
13
14
 
14
- it 'removes a dnf_package with attributes' do
15
- expect(chef_run).to remove_dnf_package('with_attributes').with(version: '1.0.0')
16
- expect(chef_run).to_not remove_dnf_package('with_attributes').with(version: '1.2.3')
17
- end
15
+ it 'removes a dnf_package with attributes' do
16
+ expect(chef_run).to remove_dnf_package('with_attributes').with(version: '1.0.0')
17
+ expect(chef_run).to_not remove_dnf_package('with_attributes').with(version: '1.2.3')
18
+ end
18
19
 
19
- it 'removes a dnf_package when specifying the identity attribute' do
20
- expect(chef_run).to remove_dnf_package('identity_attribute')
20
+ it 'removes a dnf_package when specifying the identity attribute' do
21
+ expect(chef_run).to remove_dnf_package('identity_attribute')
22
+ end
21
23
  end
22
24
  end