chefspec 8.0.1 → 9.3.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 (95) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +16 -9
  3. data/Rakefile +60 -52
  4. data/chefspec.gemspec +20 -20
  5. data/lib/chefspec.rb +29 -29
  6. data/lib/chefspec/api.rb +15 -13
  7. data/lib/chefspec/api/core.rb +3 -3
  8. data/lib/chefspec/api/described.rb +3 -5
  9. data/lib/chefspec/api/include_any_recipe.rb +24 -0
  10. data/lib/chefspec/api/stubs.rb +2 -2
  11. data/lib/chefspec/api/stubs_for.rb +23 -20
  12. data/lib/chefspec/berkshelf.rb +4 -4
  13. data/lib/chefspec/cacher.rb +2 -2
  14. data/lib/chefspec/coverage.rb +35 -40
  15. data/lib/chefspec/coverage/filters.rb +18 -15
  16. data/lib/chefspec/deprecations.rb +3 -3
  17. data/lib/chefspec/errors.rb +7 -7
  18. data/lib/chefspec/expect_exception.rb +2 -1
  19. data/lib/chefspec/extensions.rb +14 -13
  20. data/lib/chefspec/extensions/chef/client.rb +3 -3
  21. data/lib/chefspec/extensions/chef/conditional.rb +2 -1
  22. data/lib/chefspec/extensions/chef/cookbook/gem_installer.rb +5 -4
  23. data/lib/chefspec/extensions/chef/cookbook_loader.rb +1 -0
  24. data/lib/chefspec/extensions/chef/cookbook_uploader.rb +1 -1
  25. data/lib/chefspec/extensions/chef/data_query.rb +3 -3
  26. data/lib/chefspec/extensions/chef/lwrp_base.rb +1 -0
  27. data/lib/chefspec/extensions/chef/provider.rb +8 -5
  28. data/lib/chefspec/extensions/chef/resource.rb +18 -12
  29. data/lib/chefspec/extensions/chef/resource/freebsd_package.rb +2 -1
  30. data/lib/chefspec/extensions/chef/run_context/cookbook_compiler.rb +21 -1
  31. data/lib/chefspec/extensions/chef/securable.rb +1 -1
  32. data/lib/chefspec/extensions/ohai/system.rb +11 -0
  33. data/lib/chefspec/file_cache_path_proxy.rb +3 -3
  34. data/lib/chefspec/formatter.rb +15 -3
  35. data/lib/chefspec/librarian.rb +7 -6
  36. data/lib/chefspec/matchers.rb +9 -8
  37. data/lib/chefspec/matchers/do_nothing_matcher.rb +15 -15
  38. data/lib/chefspec/matchers/include_any_recipe_matcher.rb +51 -0
  39. data/lib/chefspec/matchers/include_recipe_matcher.rb +1 -1
  40. data/lib/chefspec/matchers/link_to_matcher.rb +2 -2
  41. data/lib/chefspec/matchers/notifications_matcher.rb +5 -4
  42. data/lib/chefspec/matchers/render_file_matcher.rb +3 -3
  43. data/lib/chefspec/matchers/resource_matcher.rb +18 -16
  44. data/lib/chefspec/mixins/normalize.rb +1 -1
  45. data/lib/chefspec/policyfile.rb +6 -6
  46. data/lib/chefspec/renderer.rb +4 -4
  47. data/lib/chefspec/rspec.rb +1 -1
  48. data/lib/chefspec/runner.rb +1 -1
  49. data/lib/chefspec/server.rb +1 -1
  50. data/lib/chefspec/server_methods.rb +8 -8
  51. data/lib/chefspec/server_runner.rb +10 -10
  52. data/lib/chefspec/solo_runner.rb +26 -24
  53. data/lib/chefspec/stubs/command_registry.rb +1 -1
  54. data/lib/chefspec/stubs/command_stub.rb +1 -1
  55. data/lib/chefspec/stubs/data_bag_item_registry.rb +1 -1
  56. data/lib/chefspec/stubs/data_bag_item_stub.rb +1 -1
  57. data/lib/chefspec/stubs/data_bag_registry.rb +1 -1
  58. data/lib/chefspec/stubs/data_bag_stub.rb +1 -1
  59. data/lib/chefspec/stubs/registry.rb +1 -1
  60. data/lib/chefspec/stubs/search_registry.rb +2 -2
  61. data/lib/chefspec/stubs/search_stub.rb +2 -2
  62. data/lib/chefspec/util.rb +7 -7
  63. data/lib/chefspec/version.rb +1 -1
  64. data/lib/chefspec/zero_server.rb +4 -4
  65. data/spec/spec_helper.rb +3 -4
  66. data/spec/support/hash.rb +3 -3
  67. data/spec/unit/cacher_spec.rb +17 -17
  68. data/spec/unit/coverage/filters_spec.rb +16 -16
  69. data/spec/unit/deprecations_spec.rb +8 -9
  70. data/spec/unit/errors_spec.rb +15 -15
  71. data/spec/unit/expect_exception_spec.rb +9 -9
  72. data/spec/unit/macros_spec.rb +50 -50
  73. data/spec/unit/matchers/do_nothing_matcher.rb +1 -1
  74. data/spec/unit/matchers/include_any_recipe_matcher_spec.rb +52 -0
  75. data/spec/unit/matchers/include_recipe_matcher_spec.rb +15 -15
  76. data/spec/unit/matchers/link_to_matcher_spec.rb +18 -18
  77. data/spec/unit/matchers/notifications_matcher_spec.rb +15 -16
  78. data/spec/unit/matchers/render_file_matcher_spec.rb +26 -26
  79. data/spec/unit/matchers/resource_matcher_spec.rb +1 -1
  80. data/spec/unit/matchers/state_attrs_matcher_spec.rb +24 -24
  81. data/spec/unit/matchers/subscribes_matcher_spec.rb +27 -29
  82. data/spec/unit/renderer_spec.rb +36 -36
  83. data/spec/unit/server_runner_spec.rb +6 -6
  84. data/spec/unit/solo_runner_spec.rb +69 -69
  85. data/spec/unit/stubs/command_registry_spec.rb +11 -11
  86. data/spec/unit/stubs/command_stub_spec.rb +26 -26
  87. data/spec/unit/stubs/data_bag_item_registry_spec.rb +17 -17
  88. data/spec/unit/stubs/data_bag_item_stub_spec.rb +14 -14
  89. data/spec/unit/stubs/data_bag_registry_spec.rb +16 -16
  90. data/spec/unit/stubs/data_bag_stub_spec.rb +13 -13
  91. data/spec/unit/stubs/registry_spec.rb +9 -9
  92. data/spec/unit/stubs/search_registry_spec.rb +17 -17
  93. data/spec/unit/stubs/search_stub_spec.rb +14 -14
  94. data/spec/unit/stubs/stub_spec.rb +22 -22
  95. metadata +16 -12
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 74bb24c63b0385dccb22c7a83abcd2350429986bd6de6f1444df2d548d8bb72b
4
- data.tar.gz: a66b22b4e3f705eea2d2d11fc65e9285cb890aa00f76ab826b47b66d37497678
3
+ metadata.gz: 925cb2abc56b376354e60cc27bc9e4539d5841e2d78ecc617dd287052f9340eb
4
+ data.tar.gz: 0534af872e3c3d8feb88564ccb66d976ac23c368f8e2aa85e37d7fbe3429c6ba
5
5
  SHA512:
6
- metadata.gz: 77dd4b42946b4bf2129dba71039fee03a5c1cebf8c9b2026ae4c7b31e443dea9a9a579e78d7b36ba89d75562a6eeaf9d1a701052a143cd2cc26914e15f64a4f7
7
- data.tar.gz: 4471c363638234ee7e5268db4de027b1d0b749c7ae74eaa9343c0a3f35db9b9ce0eb2c97e6b8a8c57efad75fe3b7500c34c7218a040716dfcf8cd1cba60dc6c8
6
+ metadata.gz: 89d4e0d603e9ee1c162b68836fe711e3040e31b7d950aebb25212df1f08d2381f573011665b4a8b5346881f2bf6cf72d19f2d0034fcf8d3f46f6a2373436f411
7
+ data.tar.gz: b9811de2bdba005fa11fb6f3649651310aa9748dd9f91340ab44a65c52120fe7305152b0a41a6706ebff2421b20d3f1fcb2bd55890b27b7324fe3fdcd3286e2b
data/Gemfile CHANGED
@@ -1,21 +1,28 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
3
  gemspec
4
4
 
5
5
  group :development do
6
- gem 'rake'
7
- gem 'redcarpet'
8
- gem 'yard'
9
- gem 'pry'
10
- gem 'pry-byebug'
6
+ gem "rake"
7
+ gem "redcarpet"
8
+ gem "yard"
9
+ gem "pry"
10
+ gem "pry-byebug"
11
+ gem "chefstyle"
11
12
  end
12
13
 
13
14
  if ENV["GEMFILE_MOD"]
14
- puts "GEMFILE_MOD: #{ENV['GEMFILE_MOD']}"
15
+ puts "GEMFILE_MOD: #{ENV["GEMFILE_MOD"]}"
15
16
  instance_eval(ENV["GEMFILE_MOD"])
16
17
  else
17
- gem 'chef', git: "https://github.com/chef/chef"
18
- gem 'ohai', git: "https://github.com/chef/ohai"
18
+ gem "chef", git: "https://github.com/chef/chef"
19
+ gem "ohai", git: "https://github.com/chef/ohai"
20
+ end
21
+
22
+ # TODO: remove when we drop ruby 2.5
23
+ if Gem.ruby_version < Gem::Version.new("2.6")
24
+ # 16.7.23 required ruby 2.6+
25
+ gem "chef-utils", "< 16.7.23"
19
26
  end
20
27
 
21
28
  # If you want to load debugging tools into the bundle exec sandbox,
data/Rakefile CHANGED
@@ -1,77 +1,85 @@
1
- require 'bundler/gem_tasks'
2
- require 'rspec/core'
3
- require 'rspec/core/rake_task'
4
- require 'yard/rake/yardoc_task'
5
- require 'tmpdir'
6
- require 'rspec'
7
- require 'chefspec'
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core"
3
+ require "rspec/core/rake_task"
4
+ require "yard/rake/yardoc_task"
5
+ require "tmpdir"
6
+ require "rspec"
7
+ require "chefspec"
8
+ require "chefstyle"
8
9
 
9
- require 'chef/version'
10
+ require "chef/version"
11
+
12
+ require "rubocop/rake_task"
13
+ RuboCop::RakeTask.new(:style) do |task|
14
+ task.options << "--display-cop-names"
15
+ end
10
16
 
11
17
  YARD::Rake::YardocTask.new
12
18
 
13
19
  RSpec::Core::RakeTask.new(:unit) do |t|
14
20
  t.rspec_opts = [].tap do |a|
15
- a.push('--color')
16
- a.push('--format progress')
17
- end.join(' ')
21
+ a.push("--color")
22
+ a.push("--format progress")
23
+ end.join(" ")
18
24
  end
19
25
 
20
26
  failed = []
21
27
  start_time = nil
22
28
 
23
29
  namespace :acceptance do |ns|
24
- begin
25
- Dir.foreach("examples") do |dir|
26
- next if %w(. .. .DS_Store).include?(dir)
27
- desc "#{dir} acceptance tests"
28
- task dir.to_sym do
29
- start_time ||= Time.now
30
- Dir.mktmpdir do |tmp|
31
- FileUtils.cp_r("examples/#{dir}", tmp)
32
-
33
- pwd = Dir.pwd
34
-
35
- Dir.chdir "#{tmp}/#{dir}" do
36
- puts "rspec examples/#{dir}"
37
-
38
- #
39
- # This bit of mildly awful magic below is to load each file into an in-memory
40
- # RSpec runner while keeping a persistent ChefZero server alive.
41
- #
42
- load "#{pwd}/lib/chefspec/rspec.rb"
43
-
44
- RSpec.configure do |config|
45
- config.color = true
46
- config.run_all_when_everything_filtered = true
47
- config.filter_run(:focus)
48
- config.before(:suite) do
49
- ChefSpec::ZeroServer.setup!
50
- end
51
- config.after(:each) do
52
- ChefSpec::ZeroServer.reset!
53
- end
54
- end
55
30
 
56
- RSpec.clear_examples
57
- exitstatus = RSpec::Core::Runner.run(["spec"])
58
- RSpec.reset
59
- failed << dir unless exitstatus == 0
31
+ Dir.foreach("examples") do |dir|
32
+ next if %w{. .. .DS_Store}.include?(dir)
33
+
34
+ desc "#{dir} acceptance tests"
35
+ task dir.to_sym do
36
+ start_time ||= Time.now
37
+ Dir.mktmpdir do |tmp|
38
+ FileUtils.cp_r("examples/#{dir}", tmp)
39
+
40
+ pwd = Dir.pwd
41
+
42
+ Dir.chdir "#{tmp}/#{dir}" do
43
+ puts "rspec examples/#{dir}"
44
+
45
+ #
46
+ # This bit of mildly awful magic below is to load each file into an in-memory
47
+ # RSpec runner while keeping a persistent ChefZero server alive.
48
+ #
49
+ load "#{pwd}/lib/chefspec/rspec.rb"
50
+
51
+ RSpec.configure do |config|
52
+ config.full_backtrace = true
53
+ config.color = true
54
+ config.run_all_when_everything_filtered = true
55
+ config.filter_run(:focus)
56
+ config.before(:suite) do
57
+ ChefSpec::ZeroServer.setup!
58
+ end
59
+ config.after(:each) do
60
+ ChefSpec::ZeroServer.reset!
61
+ end
60
62
  end
63
+
64
+ RSpec.clear_examples
65
+ exitstatus = RSpec::Core::Runner.run(["spec"])
66
+ RSpec.reset
67
+ failed << dir unless exitstatus == 0
61
68
  end
62
69
  end
63
70
  end
64
- rescue Errno::ENOENT # examples dir is probably missing
65
- puts "The rake acceptance tests require a full git checkout of chefspec including all examples files!"
66
71
  end
72
+ rescue Errno::ENOENT # examples dir is probably missing
73
+ puts "The rake acceptance tests require a full git checkout of chefspec including all examples files!"
74
+
67
75
  end
68
76
 
69
77
  task acceptance: Rake.application.tasks.select { |t| t.name.start_with?("acceptance:") } do
70
78
  puts "Acceptance tests took #{Time.now - start_time} seconds"
71
- raise "some tests failed: #{failed.join(', ')}" unless failed.empty?
79
+ raise "some tests failed: #{failed.join(", ")}" unless failed.empty?
72
80
  end
73
81
 
74
- desc 'Run all tests'
75
- task :test => [:unit, :acceptance]
82
+ desc "Run all tests"
83
+ task test: %i{unit acceptance}
76
84
 
77
- task :default => [:test]
85
+ task default: [:test]
data/chefspec.gemspec CHANGED
@@ -1,30 +1,30 @@
1
- lib = File.expand_path('../lib/', __FILE__)
1
+ lib = File.expand_path("lib", __dir__)
2
2
  $:.unshift lib unless $:.include?(lib)
3
- require 'chefspec/version'
3
+ require "chefspec/version"
4
4
 
5
5
  Gem::Specification.new do |s|
6
- s.name = 'chefspec'
6
+ s.name = "chefspec"
7
7
  s.version = ChefSpec::VERSION
8
- s.authors = ['Andrew Crump', 'Seth Vargo']
9
- s.email = ['andrew.crump@ieee.org', 'sethvargo@gmail.com']
10
- s.summary = 'Write RSpec examples and generate coverage reports for ' \
11
- 'Chef recipes!'
12
- s.description = 'ChefSpec is a unit testing and resource coverage ' \
13
- '(code coverage) framework for testing Chef cookbooks ' \
14
- 'ChefSpec makes it easy to write examples and get fast ' \
15
- 'feedback on cookbook changes without the need for ' \
16
- 'virtual machines or cloud servers.'
17
- s.homepage = 'https://github.com/chefspec/chefspec'
18
- s.license = 'MIT'
8
+ s.authors = ["Andrew Crump", "Seth Vargo"]
9
+ s.email = ["andrew.crump@ieee.org", "sethvargo@gmail.com"]
10
+ s.summary = "Write RSpec examples and generate coverage reports for " \
11
+ "Chef recipes!"
12
+ s.description = "ChefSpec is a unit testing and resource coverage " \
13
+ "(code coverage) framework for testing Chef cookbooks " \
14
+ "ChefSpec makes it easy to write examples and get fast " \
15
+ "feedback on cookbook changes without the need for " \
16
+ "virtual machines or cloud servers."
17
+ s.homepage = "https://github.com/chefspec/chefspec"
18
+ s.license = "MIT"
19
19
 
20
20
  # Packaging
21
21
  s.files = %w{LICENSE Rakefile Gemfile chefspec.gemspec} + Dir.glob("{lib,templates,spec}/**/*", File::FNM_DOTMATCH).reject { |f| File.directory?(f) }
22
- s.require_paths = ['lib']
22
+ s.require_paths = ["lib"]
23
23
 
24
- s.required_ruby_version = '>= 2.4'
24
+ s.required_ruby_version = ">= 2.5"
25
25
 
26
- s.add_dependency 'chef', '>= 14'
27
- s.add_dependency 'chef-cli'
28
- s.add_dependency 'fauxhai', '>= 6.11'
29
- s.add_dependency 'rspec', '~> 3.0'
26
+ s.add_dependency "chef", ">= 15"
27
+ s.add_dependency "chef-cli"
28
+ s.add_dependency "fauxhai-ng", ">= 7.5"
29
+ s.add_dependency "rspec", "~> 3.0"
30
30
  end
data/lib/chefspec.rb CHANGED
@@ -1,4 +1,4 @@
1
- require 'rspec'
1
+ require "rspec"
2
2
 
3
3
  module ChefSpec
4
4
  #
@@ -25,7 +25,7 @@ module ChefSpec
25
25
  # @return [Pathname]
26
26
  #
27
27
  def root
28
- @root ||= Pathname.new(File.expand_path('../../', __FILE__))
28
+ @root ||= Pathname.new(File.expand_path("..", __dir__))
29
29
  end
30
30
  module_function :root
31
31
 
@@ -42,34 +42,34 @@ module ChefSpec
42
42
  module_function :matchers
43
43
  end
44
44
 
45
- require_relative 'chefspec/extensions'
45
+ require_relative "chefspec/extensions"
46
46
 
47
- require_relative 'chefspec/mixins/normalize'
47
+ require_relative "chefspec/mixins/normalize"
48
48
 
49
- require_relative 'chefspec/stubs/command_registry'
50
- require_relative 'chefspec/stubs/command_stub'
51
- require_relative 'chefspec/stubs/data_bag_item_registry'
52
- require_relative 'chefspec/stubs/data_bag_item_stub'
53
- require_relative 'chefspec/stubs/data_bag_registry'
54
- require_relative 'chefspec/stubs/data_bag_stub'
55
- require_relative 'chefspec/stubs/registry'
56
- require_relative 'chefspec/stubs/stub'
57
- require_relative 'chefspec/stubs/search_registry'
58
- require_relative 'chefspec/stubs/search_stub'
49
+ require_relative "chefspec/stubs/command_registry"
50
+ require_relative "chefspec/stubs/command_stub"
51
+ require_relative "chefspec/stubs/data_bag_item_registry"
52
+ require_relative "chefspec/stubs/data_bag_item_stub"
53
+ require_relative "chefspec/stubs/data_bag_registry"
54
+ require_relative "chefspec/stubs/data_bag_stub"
55
+ require_relative "chefspec/stubs/registry"
56
+ require_relative "chefspec/stubs/stub"
57
+ require_relative "chefspec/stubs/search_registry"
58
+ require_relative "chefspec/stubs/search_stub"
59
59
 
60
- require_relative 'chefspec/api'
61
- require_relative 'chefspec/cacher'
62
- require_relative 'chefspec/coverage'
63
- require_relative 'chefspec/errors'
64
- require_relative 'chefspec/expect_exception'
65
- require_relative 'chefspec/formatter'
66
- require_relative 'chefspec/matchers'
67
- require_relative 'chefspec/renderer'
68
- require_relative 'chefspec/rspec'
69
- require_relative 'chefspec/server_runner'
70
- require_relative 'chefspec/solo_runner'
71
- require_relative 'chefspec/runner'
72
- require_relative 'chefspec/util'
73
- require_relative 'chefspec/version'
60
+ require_relative "chefspec/api"
61
+ require_relative "chefspec/cacher"
62
+ require_relative "chefspec/coverage"
63
+ require_relative "chefspec/errors"
64
+ require_relative "chefspec/expect_exception"
65
+ require_relative "chefspec/formatter"
66
+ require_relative "chefspec/matchers"
67
+ require_relative "chefspec/renderer"
68
+ require_relative "chefspec/rspec"
69
+ require_relative "chefspec/server_runner"
70
+ require_relative "chefspec/solo_runner"
71
+ require_relative "chefspec/runner"
72
+ require_relative "chefspec/util"
73
+ require_relative "chefspec/version"
74
74
 
75
- require_relative 'chefspec/deprecations'
75
+ require_relative "chefspec/deprecations"
data/lib/chefspec/api.rb CHANGED
@@ -1,24 +1,26 @@
1
1
  module ChefSpec
2
2
  module API
3
- autoload :Core, 'chefspec/api/core'
4
- autoload :Described, 'chefspec/api/described'
5
- autoload :DoNothing, 'chefspec/api/do_nothing'
6
- autoload :IncludeRecipe, 'chefspec/api/include_recipe'
7
- autoload :Link, 'chefspec/api/link'
8
- autoload :Notifications, 'chefspec/api/notifications'
9
- autoload :Reboot, 'chefspec/api/reboot'
10
- autoload :RenderFile, 'chefspec/api/render_file'
11
- autoload :StateAttrs, 'chefspec/api/state_attrs'
12
- autoload :Stubs, 'chefspec/api/stubs'
13
- autoload :StubsFor, 'chefspec/api/stubs_for'
14
- autoload :Subscriptions, 'chefspec/api/subscriptions'
15
- autoload :User, 'chefspec/api/user'
3
+ autoload :Core, "chefspec/api/core"
4
+ autoload :Described, "chefspec/api/described"
5
+ autoload :DoNothing, "chefspec/api/do_nothing"
6
+ autoload :IncludeAnyRecipe, "chefspec/api/include_any_recipe"
7
+ autoload :IncludeRecipe, "chefspec/api/include_recipe"
8
+ autoload :Link, "chefspec/api/link"
9
+ autoload :Notifications, "chefspec/api/notifications"
10
+ autoload :Reboot, "chefspec/api/reboot"
11
+ autoload :RenderFile, "chefspec/api/render_file"
12
+ autoload :StateAttrs, "chefspec/api/state_attrs"
13
+ autoload :Stubs, "chefspec/api/stubs"
14
+ autoload :StubsFor, "chefspec/api/stubs_for"
15
+ autoload :Subscriptions, "chefspec/api/subscriptions"
16
+ autoload :User, "chefspec/api/user"
16
17
 
17
18
  def self.included(klass)
18
19
  # non-resources
19
20
  klass.include(ChefSpec::API::Core)
20
21
  klass.include(ChefSpec::API::Described)
21
22
  klass.include(ChefSpec::API::DoNothing)
23
+ klass.include(ChefSpec::API::IncludeAnyRecipe)
22
24
  klass.include(ChefSpec::API::IncludeRecipe)
23
25
  klass.include(ChefSpec::API::DoNothing)
24
26
  klass.include(ChefSpec::API::RenderFile)
@@ -36,7 +36,7 @@ module ChefSpec
36
36
  # @return [Hash<Symbol, Object>]
37
37
  def chef_runner_options
38
38
  options = {
39
- step_into: chefspec_ancestor_gather([], :step_into) {|memo, val| memo | val },
39
+ step_into: chefspec_ancestor_gather([], :step_into) { |memo, val| memo | val },
40
40
  default_attributes: chefspec_default_attributes,
41
41
  normal_attributes: chefspec_normal_attributes,
42
42
  override_attributes: chefspec_override_attributes,
@@ -85,7 +85,7 @@ module ChefSpec
85
85
  # @param block [Proc] Reducer callable.
86
86
  # @return [Object]
87
87
  def chefspec_ancestor_gather(start, method, &block)
88
- candidate_ancestors = self.class.ancestors.select {|cls| cls.respond_to?(method) && cls != ChefSpec::API::Core }
88
+ candidate_ancestors = self.class.ancestors.select { |cls| cls.respond_to?(method) && cls != ChefSpec::API::Core }
89
89
  candidate_ancestors.reverse.inject(start) do |memo, cls|
90
90
  block.call(memo, cls.send(method))
91
91
  end
@@ -115,7 +115,7 @@ module ChefSpec
115
115
  # @param name [String] Platform name to set.
116
116
  # @param version [String, nil] Platform version to set.
117
117
  # @return [void]
118
- def platform(name, version=nil)
118
+ def platform(name, version = nil)
119
119
  let(:chefspec_platform) { name }
120
120
  let(:chefspec_platform_version) { version }
121
121
  end
@@ -20,7 +20,7 @@ module ChefSpec
20
20
  # @return [String]
21
21
  #
22
22
  def described_cookbook
23
- described_recipe.split('::').first
23
+ described_recipe.split("::").first
24
24
  end
25
25
 
26
26
  #
@@ -40,12 +40,10 @@ module ChefSpec
40
40
  # @return [String]
41
41
  #
42
42
  def described_recipe
43
- scope = self.is_a?(Class) ? self : self.class
43
+ scope = is_a?(Class) ? self : self.class
44
44
 
45
45
  metahash = scope.metadata
46
- while metahash.has_key?(:parent_example_group)
47
- metahash = metahash[:parent_example_group]
48
- end
46
+ metahash = metahash[:parent_example_group] while metahash.key?(:parent_example_group)
49
47
 
50
48
  metahash[:description].to_s
51
49
  end
@@ -0,0 +1,24 @@
1
+ module ChefSpec
2
+ module API
3
+ module IncludeAnyRecipe
4
+ #
5
+ # Assert that a Chef run includes any recipe.
6
+ #
7
+ # include_recipe 'apache2::default'
8
+ #
9
+ # The Examples section demonstrates the different ways to test an
10
+ # +include_any_recipe+ directive with ChefSpec.
11
+ #
12
+ # @example Assert the Chef run did not include any recipes
13
+ # expect(chef_run).not_to include_any_recipe
14
+ #
15
+ #
16
+ # @return [ChefSpec::Matchers::IncludeAnyRecipeMatcher]
17
+ #
18
+ def include_any_recipe
19
+ ChefSpec::Matchers::IncludeAnyRecipeMatcher.new
20
+ end
21
+ alias_method :include_any_recipes, :include_any_recipe
22
+ end
23
+ end
24
+ end
@@ -121,7 +121,7 @@ module ChefSpec
121
121
  #
122
122
  def stub_node(*args, &block)
123
123
  options = args.last.is_a?(Hash) ? args.pop : {}
124
- name = args.first || 'node.example'
124
+ name = args.first || "node.example"
125
125
 
126
126
  fauxhai = Fauxhai.mock(options).data
127
127
  fauxhai = fauxhai.merge(options[:ohai] || {})
@@ -165,7 +165,7 @@ module ChefSpec
165
165
  #
166
166
  # @return [ChefSpec::SearchStub]
167
167
  #
168
- def stub_search(type, query = '*:*', &block)
168
+ def stub_search(type, query = "*:*", &block)
169
169
  ChefSpec::Stubs::SearchRegistry.register(ChefSpec::Stubs::SearchStub.new(type, query, &block))
170
170
  end
171
171