chefspec 9.1.0 → 9.3.1

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/api/core.rb +3 -3
  6. data/lib/chefspec/api/described.rb +3 -5
  7. data/lib/chefspec/api/stubs.rb +2 -2
  8. data/lib/chefspec/api/stubs_for.rb +22 -19
  9. data/lib/chefspec/api.rb +14 -14
  10. data/lib/chefspec/berkshelf.rb +4 -4
  11. data/lib/chefspec/cacher.rb +2 -2
  12. data/lib/chefspec/coverage/filters.rb +18 -15
  13. data/lib/chefspec/coverage.rb +35 -40
  14. data/lib/chefspec/deprecations.rb +3 -3
  15. data/lib/chefspec/errors.rb +7 -7
  16. data/lib/chefspec/expect_exception.rb +2 -1
  17. data/lib/chefspec/extensions/chef/client.rb +3 -3
  18. data/lib/chefspec/extensions/chef/conditional.rb +2 -1
  19. data/lib/chefspec/extensions/chef/cookbook/gem_installer.rb +5 -4
  20. data/lib/chefspec/extensions/chef/cookbook_loader.rb +1 -0
  21. data/lib/chefspec/extensions/chef/cookbook_uploader.rb +1 -1
  22. data/lib/chefspec/extensions/chef/data_query.rb +3 -3
  23. data/lib/chefspec/extensions/chef/lwrp_base.rb +1 -0
  24. data/lib/chefspec/extensions/chef/provider.rb +8 -5
  25. data/lib/chefspec/extensions/chef/resource/freebsd_package.rb +2 -1
  26. data/lib/chefspec/extensions/chef/resource.rb +18 -12
  27. data/lib/chefspec/extensions/chef/run_context/cookbook_compiler.rb +21 -1
  28. data/lib/chefspec/extensions/chef/securable.rb +1 -1
  29. data/lib/chefspec/extensions/ohai/system.rb +11 -0
  30. data/lib/chefspec/extensions.rb +14 -13
  31. data/lib/chefspec/file_cache_path_proxy.rb +3 -3
  32. data/lib/chefspec/formatter.rb +15 -3
  33. data/lib/chefspec/librarian.rb +7 -6
  34. data/lib/chefspec/matchers/do_nothing_matcher.rb +15 -15
  35. data/lib/chefspec/matchers/include_any_recipe_matcher.rb +4 -4
  36. data/lib/chefspec/matchers/include_recipe_matcher.rb +1 -1
  37. data/lib/chefspec/matchers/link_to_matcher.rb +2 -2
  38. data/lib/chefspec/matchers/notifications_matcher.rb +5 -4
  39. data/lib/chefspec/matchers/render_file_matcher.rb +3 -3
  40. data/lib/chefspec/matchers/resource_matcher.rb +18 -16
  41. data/lib/chefspec/matchers.rb +9 -9
  42. data/lib/chefspec/mixins/normalize.rb +1 -1
  43. data/lib/chefspec/policyfile.rb +6 -6
  44. data/lib/chefspec/renderer.rb +4 -4
  45. data/lib/chefspec/rspec.rb +1 -1
  46. data/lib/chefspec/server.rb +1 -1
  47. data/lib/chefspec/server_methods.rb +8 -8
  48. data/lib/chefspec/server_runner.rb +10 -10
  49. data/lib/chefspec/solo_runner.rb +27 -25
  50. data/lib/chefspec/stubs/command_registry.rb +1 -1
  51. data/lib/chefspec/stubs/command_stub.rb +1 -1
  52. data/lib/chefspec/stubs/data_bag_item_registry.rb +1 -1
  53. data/lib/chefspec/stubs/data_bag_item_stub.rb +1 -1
  54. data/lib/chefspec/stubs/data_bag_registry.rb +1 -1
  55. data/lib/chefspec/stubs/data_bag_stub.rb +1 -1
  56. data/lib/chefspec/stubs/registry.rb +1 -1
  57. data/lib/chefspec/stubs/search_registry.rb +2 -2
  58. data/lib/chefspec/stubs/search_stub.rb +2 -2
  59. data/lib/chefspec/util.rb +7 -7
  60. data/lib/chefspec/version.rb +1 -1
  61. data/lib/chefspec/zero_server.rb +4 -4
  62. data/lib/chefspec.rb +29 -29
  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 +10 -11
  94. data/lib/chefspec/extensions/.DS_Store +0 -0
  95. data/lib/chefspec/extensions/chef/.DS_Store +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 96c39db8c598b7a40e7fd080c65db3a073a1e8e95f59a2628682587e5de4db56
4
- data.tar.gz: a0bc37df1322446f83af4488fa1def9124d821478c0364a40fcce138c10f63cf
3
+ metadata.gz: ef97b147dacaeb64bafc2b4825cfdf18eb7e88a898d82231d2aa4924ff6ccf83
4
+ data.tar.gz: a53dd7fe6e2062efb147f40c364e81022e550cb1a93145a95b8dbb71a677c25e
5
5
  SHA512:
6
- metadata.gz: 354c875c5eb0890aea76c9bb7593dfec11d122157c42ca79842ff8a4264766e6a230fb57a14dfdd6c87887e7c4ba147ee388465e5c2b1fa782ed77a912145844
7
- data.tar.gz: 64ff73a7906b1e4ba085a9d5d9182903de2965c9ea4c979ad95363b45677d083868e0f64c30c2637ee7beed85333d309cbe42c26024c6fc7fddc0f6b3b08861d
6
+ metadata.gz: 6cceb0d5a03b5960e344570d3db7677adbc4b35c4febf8fae0a6e08f223ecd8b4e102ea212f2afb0b959d9555d3409654a1f5da6c654743c06c1fe9d3739879f
7
+ data.tar.gz: 635a5a3217295693c973fae336b9516ea4ca5cf0b3f5530366332cb165c3a7bfeeca740296ff1de0477477d2cfa66fae96f9f10cccaf06c8530353f8c98a5fb5
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
@@ -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
 
@@ -1,5 +1,5 @@
1
1
  require "chef/version"
2
- require "mixlib/shellout"
2
+ require "mixlib/shellout" unless defined?(Mixlib::ShellOut)
3
3
 
4
4
  module ChefSpec
5
5
  module API
@@ -56,23 +56,25 @@ module ChefSpec
56
56
  # expect(subject.some_method).to eq "asdf"
57
57
  # end
58
58
  # @param target [String, nil] Resource name to inject, or nil for all resources.
59
- # @param current_resource [Boolean] If true, also register stubs for current_resource objects on the same target.
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_resource: true, &block)
62
+ def stubs_for_resource(target = nil, current_value: true, current_resource: true, &block)
63
+ current_value = false unless current_resource
63
64
  _chefspec_stubs_for_registry[:resource][target] << block
64
- stubs_for_current_resource(target, &block) if current_resource
65
+ stubs_for_current_value(target, &block) if current_value
65
66
  end
66
67
 
67
- # Register stubs for current_resource objects.
68
+ # Register stubs for current_value objects.
68
69
  #
69
70
  # @see #stubs_for_resource
70
71
  # @param target [String, nil] Resource name to inject, or nil for all resources.
71
72
  # @param block [Proc] A block taking the resource object as a parameter.
72
73
  # @return [void]
73
- def stubs_for_current_resource(target=nil, &block)
74
- _chefspec_stubs_for_registry[:current_resource][target] << block
74
+ def stubs_for_current_value(target = nil, &block)
75
+ _chefspec_stubs_for_registry[:current_value][target] << block
75
76
  end
77
+ alias_method :stubs_for_current_resource, :stubs_for_current_value
76
78
 
77
79
  # Register stubs for provider objects.
78
80
  #
@@ -80,15 +82,15 @@ module ChefSpec
80
82
  # @param target [String, nil] Resource name to inject, or nil for all providers.
81
83
  # @param block [Proc] A block taking the resource object as a parameter.
82
84
  # @return [void]
83
- def stubs_for_provider(target=nil, &block)
85
+ def stubs_for_provider(target = nil, &block)
84
86
  _chefspec_stubs_for_registry[:provider][target] << block
85
87
  end
86
88
 
87
- def receive_shell_out(*cmd, stdout: '', stderr: '', exitstatus: 0, **opts)
89
+ def receive_shell_out(*cmd, stdout: "", stderr: "", exitstatus: 0, **opts)
88
90
  # Ruby does not allow constructing an actual exitstatus object from Ruby code. Really.
89
91
  fake_exitstatus = double(exitstatus: exitstatus)
90
92
  fake_cmd = Mixlib::ShellOut.new(*cmd)
91
- 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.
92
94
  # Inject our canned data.
93
95
  fake_cmd.instance_exec do
94
96
  @stdout = stdout
@@ -97,24 +99,25 @@ module ChefSpec
97
99
  end
98
100
  # On newer Chef, we can intercept using the new, better shell_out_compact hook point.
99
101
  shell_out_method ||= if HAS_SHELLOUT_COMPACTED.satisfied_by?(Gem::Version.create(Chef::VERSION))
100
- :shell_out_compacted
101
- else
102
- :shell_out
103
- end
102
+ :shell_out_compacted
103
+ else
104
+ :shell_out
105
+ end
104
106
  with_args = cmd + (opts.empty? ? [any_args] : [hash_including(opts)])
105
107
  receive(shell_out_method).with(*with_args).and_return(fake_cmd)
106
108
  end
107
109
 
108
110
  module ClassMethods
109
111
  # (see StubsFor#stubs_for_resource)
110
- def stubs_for_resource(*args, &block)
111
- before { stubs_for_resource(*args, &block) }
112
+ def stubs_for_resource(*args, **kwargs, &block)
113
+ before { stubs_for_resource(*args, **kwargs, &block) }
112
114
  end
113
115
 
114
- # (see StubsFor#stubs_for_current_resource)
115
- def stubs_for_current_resource(*args, &block)
116
- before { stubs_for_current_resource(*args, &block) }
116
+ # (see StubsFor#stubs_for_current_value)
117
+ def stubs_for_current_value(*args, &block)
118
+ before { stubs_for_current_value(*args, &block) }
117
119
  end
120
+ alias_method :stubs_for_current_resource, :stubs_for_current_value
118
121
 
119
122
  # (see StubsFor#stubs_for_provider)
120
123
  def stubs_for_provider(*args, &block)
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
@@ -1,7 +1,7 @@
1
1
  begin
2
- require 'berkshelf'
2
+ require "berkshelf"
3
3
  rescue LoadError
4
- raise ChefSpec::Error::GemLoadError.new(gem: 'berkshelf', name: 'Berkshelf')
4
+ raise ChefSpec::Error::GemLoadError.new(gem: "berkshelf", name: "Berkshelf")
5
5
  end
6
6
 
7
7
  module ChefSpec
@@ -23,14 +23,14 @@ module ChefSpec
23
23
  def setup!
24
24
  # Get the list of Berkshelf options
25
25
  opts = RSpec.configuration.berkshelf_options
26
- if !opts.is_a?(Hash)
26
+ unless opts.is_a?(Hash)
27
27
  raise InvalidBerkshelfOptions(value: opts.inspect)
28
28
  end
29
29
 
30
30
  berksfile = ::Berkshelf::Berksfile.from_options(opts)
31
31
 
32
32
  # Grab a handle to tmpdir, since Berkshelf 2 modifies it a bit
33
- tmpdir = File.join(@tmpdir, 'cookbooks')
33
+ tmpdir = File.join(@tmpdir, "cookbooks")
34
34
 
35
35
  ::Berkshelf.ui.mute do
36
36
  if ::Berkshelf::Berksfile.method_defined?(:vendor)