chefspec 9.2.1 → 9.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) 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 +14 -14
  7. data/lib/chefspec/api/core.rb +3 -3
  8. data/lib/chefspec/api/described.rb +3 -5
  9. data/lib/chefspec/api/stubs.rb +2 -2
  10. data/lib/chefspec/api/stubs_for.rb +12 -12
  11. data/lib/chefspec/berkshelf.rb +4 -4
  12. data/lib/chefspec/cacher.rb +2 -2
  13. data/lib/chefspec/coverage.rb +35 -40
  14. data/lib/chefspec/coverage/filters.rb +18 -15
  15. data/lib/chefspec/deprecations.rb +3 -3
  16. data/lib/chefspec/errors.rb +7 -7
  17. data/lib/chefspec/expect_exception.rb +2 -1
  18. data/lib/chefspec/extensions.rb +14 -14
  19. data/lib/chefspec/extensions/chef/client.rb +3 -3
  20. data/lib/chefspec/extensions/chef/conditional.rb +2 -1
  21. data/lib/chefspec/extensions/chef/cookbook/gem_installer.rb +5 -4
  22. data/lib/chefspec/extensions/chef/cookbook_loader.rb +1 -0
  23. data/lib/chefspec/extensions/chef/cookbook_uploader.rb +1 -1
  24. data/lib/chefspec/extensions/chef/data_query.rb +3 -3
  25. data/lib/chefspec/extensions/chef/lwrp_base.rb +1 -0
  26. data/lib/chefspec/extensions/chef/provider.rb +8 -5
  27. data/lib/chefspec/extensions/chef/resource.rb +14 -9
  28. data/lib/chefspec/extensions/chef/resource/freebsd_package.rb +2 -1
  29. data/lib/chefspec/extensions/chef/run_context/cookbook_compiler.rb +12 -1
  30. data/lib/chefspec/extensions/chef/securable.rb +1 -1
  31. data/lib/chefspec/extensions/ohai/system.rb +1 -1
  32. data/lib/chefspec/file_cache_path_proxy.rb +3 -3
  33. data/lib/chefspec/formatter.rb +3 -3
  34. data/lib/chefspec/librarian.rb +7 -6
  35. data/lib/chefspec/matchers.rb +9 -9
  36. data/lib/chefspec/matchers/do_nothing_matcher.rb +15 -15
  37. data/lib/chefspec/matchers/include_any_recipe_matcher.rb +4 -4
  38. data/lib/chefspec/matchers/include_recipe_matcher.rb +1 -1
  39. data/lib/chefspec/matchers/link_to_matcher.rb +2 -2
  40. data/lib/chefspec/matchers/notifications_matcher.rb +5 -4
  41. data/lib/chefspec/matchers/render_file_matcher.rb +3 -3
  42. data/lib/chefspec/matchers/resource_matcher.rb +18 -16
  43. data/lib/chefspec/mixins/normalize.rb +1 -1
  44. data/lib/chefspec/policyfile.rb +6 -6
  45. data/lib/chefspec/renderer.rb +4 -4
  46. data/lib/chefspec/rspec.rb +1 -1
  47. data/lib/chefspec/server.rb +1 -1
  48. data/lib/chefspec/server_methods.rb +8 -8
  49. data/lib/chefspec/server_runner.rb +10 -10
  50. data/lib/chefspec/solo_runner.rb +26 -24
  51. data/lib/chefspec/stubs/command_registry.rb +1 -1
  52. data/lib/chefspec/stubs/command_stub.rb +1 -1
  53. data/lib/chefspec/stubs/data_bag_item_registry.rb +1 -1
  54. data/lib/chefspec/stubs/data_bag_item_stub.rb +1 -1
  55. data/lib/chefspec/stubs/data_bag_registry.rb +1 -1
  56. data/lib/chefspec/stubs/data_bag_stub.rb +1 -1
  57. data/lib/chefspec/stubs/registry.rb +1 -1
  58. data/lib/chefspec/stubs/search_registry.rb +2 -2
  59. data/lib/chefspec/stubs/search_stub.rb +2 -2
  60. data/lib/chefspec/util.rb +7 -7
  61. data/lib/chefspec/version.rb +1 -1
  62. data/lib/chefspec/zero_server.rb +3 -3
  63. data/spec/spec_helper.rb +3 -4
  64. data/spec/support/hash.rb +3 -3
  65. data/spec/unit/cacher_spec.rb +17 -17
  66. data/spec/unit/coverage/filters_spec.rb +16 -16
  67. data/spec/unit/deprecations_spec.rb +8 -9
  68. data/spec/unit/errors_spec.rb +15 -15
  69. data/spec/unit/expect_exception_spec.rb +9 -9
  70. data/spec/unit/macros_spec.rb +50 -50
  71. data/spec/unit/matchers/do_nothing_matcher.rb +1 -1
  72. data/spec/unit/matchers/include_any_recipe_matcher_spec.rb +23 -23
  73. data/spec/unit/matchers/include_recipe_matcher_spec.rb +15 -15
  74. data/spec/unit/matchers/link_to_matcher_spec.rb +18 -18
  75. data/spec/unit/matchers/notifications_matcher_spec.rb +15 -16
  76. data/spec/unit/matchers/render_file_matcher_spec.rb +26 -26
  77. data/spec/unit/matchers/resource_matcher_spec.rb +1 -1
  78. data/spec/unit/matchers/state_attrs_matcher_spec.rb +24 -24
  79. data/spec/unit/matchers/subscribes_matcher_spec.rb +27 -29
  80. data/spec/unit/renderer_spec.rb +36 -36
  81. data/spec/unit/server_runner_spec.rb +6 -6
  82. data/spec/unit/solo_runner_spec.rb +69 -69
  83. data/spec/unit/stubs/command_registry_spec.rb +11 -11
  84. data/spec/unit/stubs/command_stub_spec.rb +26 -26
  85. data/spec/unit/stubs/data_bag_item_registry_spec.rb +17 -17
  86. data/spec/unit/stubs/data_bag_item_stub_spec.rb +14 -14
  87. data/spec/unit/stubs/data_bag_registry_spec.rb +16 -16
  88. data/spec/unit/stubs/data_bag_stub_spec.rb +13 -13
  89. data/spec/unit/stubs/registry_spec.rb +9 -9
  90. data/spec/unit/stubs/search_registry_spec.rb +17 -17
  91. data/spec/unit/stubs/search_stub_spec.rb +14 -14
  92. data/spec/unit/stubs/stub_spec.rb +22 -22
  93. metadata +6 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d5591af3861eae4ba3b5d9c37d274f38fa0279c9a5d91e2668d923251d1885ae
4
- data.tar.gz: 36be14ae6da887efee4516070e3b6884e43950a8b9fddbbc28660d1ea7f6c841
3
+ metadata.gz: 925cb2abc56b376354e60cc27bc9e4539d5841e2d78ecc617dd287052f9340eb
4
+ data.tar.gz: 0534af872e3c3d8feb88564ccb66d976ac23c368f8e2aa85e37d7fbe3429c6ba
5
5
  SHA512:
6
- metadata.gz: 24e86fab969faea333b44ab9db94663efe783383c37760ce581bd0a088e1f3dc96927dc8bab7624da966d5e60440cf6c97e31a2b56b3c72a89135b0805d17ebc
7
- data.tar.gz: d6b244cc4207077b59a6f53f343b632fe2550549b4e3778bdbfca9848a510861d7fdbe885bc26556c38ba5d74dbb5d619e1073521a2d0a4da3f7d1bd3b94576d
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-ng', '>= 7.5'
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,19 +1,19 @@
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 :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'
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"
17
17
 
18
18
  def self.included(klass)
19
19
  # non-resources
@@ -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
@@ -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
 
@@ -59,8 +59,8 @@ module ChefSpec
59
59
  # @param current_value [Boolean] If true, also register stubs for current_value objects on the same target.
60
60
  # @param block [Proc] A block taking the resource object as a parameter.
61
61
  # @return [void]
62
- def stubs_for_resource(target=nil, current_value: true, current_resource: true, &block)
63
- current_value = false if !current_resource
62
+ def stubs_for_resource(target = nil, current_value: true, current_resource: true, &block)
63
+ current_value = false unless current_resource
64
64
  _chefspec_stubs_for_registry[:resource][target] << block
65
65
  stubs_for_current_value(target, &block) if current_value
66
66
  end
@@ -71,7 +71,7 @@ module ChefSpec
71
71
  # @param target [String, nil] Resource name to inject, or nil for all resources.
72
72
  # @param block [Proc] A block taking the resource object as a parameter.
73
73
  # @return [void]
74
- def stubs_for_current_value(target=nil, &block)
74
+ def stubs_for_current_value(target = nil, &block)
75
75
  _chefspec_stubs_for_registry[:current_value][target] << block
76
76
  end
77
77
  alias_method :stubs_for_current_resource, :stubs_for_current_value
@@ -82,15 +82,15 @@ module ChefSpec
82
82
  # @param target [String, nil] Resource name to inject, or nil for all providers.
83
83
  # @param block [Proc] A block taking the resource object as a parameter.
84
84
  # @return [void]
85
- def stubs_for_provider(target=nil, &block)
85
+ def stubs_for_provider(target = nil, &block)
86
86
  _chefspec_stubs_for_registry[:provider][target] << block
87
87
  end
88
88
 
89
- def receive_shell_out(*cmd, stdout: '', stderr: '', exitstatus: 0, **opts)
89
+ def receive_shell_out(*cmd, stdout: "", stderr: "", exitstatus: 0, **opts)
90
90
  # Ruby does not allow constructing an actual exitstatus object from Ruby code. Really.
91
91
  fake_exitstatus = double(exitstatus: exitstatus)
92
92
  fake_cmd = Mixlib::ShellOut.new(*cmd)
93
- fake_cmd.define_singleton_method(:run_command) { } # Do nothing, just in case.
93
+ fake_cmd.define_singleton_method(:run_command) {} # Do nothing, just in case.
94
94
  # Inject our canned data.
95
95
  fake_cmd.instance_exec do
96
96
  @stdout = stdout
@@ -99,18 +99,18 @@ module ChefSpec
99
99
  end
100
100
  # On newer Chef, we can intercept using the new, better shell_out_compact hook point.
101
101
  shell_out_method ||= if HAS_SHELLOUT_COMPACTED.satisfied_by?(Gem::Version.create(Chef::VERSION))
102
- :shell_out_compacted
103
- else
104
- :shell_out
105
- end
102
+ :shell_out_compacted
103
+ else
104
+ :shell_out
105
+ end
106
106
  with_args = cmd + (opts.empty? ? [any_args] : [hash_including(opts)])
107
107
  receive(shell_out_method).with(*with_args).and_return(fake_cmd)
108
108
  end
109
109
 
110
110
  module ClassMethods
111
111
  # (see StubsFor#stubs_for_resource)
112
- def stubs_for_resource(*args, &block)
113
- before { stubs_for_resource(*args, &block) }
112
+ def stubs_for_resource(*args, **kwargs, &block)
113
+ before { stubs_for_resource(*args, **kwargs, &block) }
114
114
  end
115
115
 
116
116
  # (see StubsFor#stubs_for_current_value)