chefspec 9.1.0 → 9.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 96c39db8c598b7a40e7fd080c65db3a073a1e8e95f59a2628682587e5de4db56
4
- data.tar.gz: a0bc37df1322446f83af4488fa1def9124d821478c0364a40fcce138c10f63cf
3
+ metadata.gz: c20bc92ebea039d7261547ec0e91686f1c4c83e57f7bd19e98f4a4e4fce13aa3
4
+ data.tar.gz: b6f4060d3844074dfffe298c3a5d0d75a766926abf41e80dbb7b95c2aa26500c
5
5
  SHA512:
6
- metadata.gz: 354c875c5eb0890aea76c9bb7593dfec11d122157c42ca79842ff8a4264766e6a230fb57a14dfdd6c87887e7c4ba147ee388465e5c2b1fa782ed77a912145844
7
- data.tar.gz: 64ff73a7906b1e4ba085a9d5d9182903de2965c9ea4c979ad95363b45677d083868e0f64c30c2637ee7beed85333d309cbe42c26024c6fc7fddc0f6b3b08861d
6
+ metadata.gz: 8446ad09b864f601169c69f635ee93fd1089ca8c4031e43884d9c87495ce0a57c86d3620ad9de1c2ddb36ceb1d66074352eeacce862a11dd8e3c7303cc0c19f3
7
+ data.tar.gz: 8d4db22787020c88195ce7ea76bd517b94ab293463b2dddda47614dbd867d8d5490a6a8d77b794bdd273ceca2903d58f46151302482021767c5686f2c549a299
@@ -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 if !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
  #
@@ -111,10 +113,11 @@ module ChefSpec
111
113
  before { stubs_for_resource(*args, &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)
@@ -18,3 +18,4 @@ require_relative 'extensions/chef/lwrp_base'
18
18
  require_relative 'extensions/chef/resource/freebsd_package'
19
19
  require_relative 'extensions/chef/run_context/cookbook_compiler'
20
20
  require_relative 'extensions/chef/cookbook_loader'
21
+ require_relative 'extensions/ohai/system'
@@ -21,7 +21,8 @@ module ChefSpec::Extensions::Chef::Resource
21
21
  # If we're directly inside a `load_current_resource`, this is probably
22
22
  # something like `new_resource.class.new` so we want to call this a current_resource,
23
23
  # Otherwise it's probably a normal resource instantiation.
24
- mode = caller[1].include?("`load_current_resource'") ? :current_resource : :resource
24
+ mode = :resource
25
+ mode = :current_value if caller.any? { |x| x.include?("`load_current_resource'") || x.include?("`load_after_resource'") }
25
26
  ChefSpec::API::StubsFor.setup_stubs_for(self, mode)
26
27
  end
27
28
  end
@@ -33,7 +34,7 @@ module ChefSpec::Extensions::Chef::Resource
33
34
  super.tap do |dup_resource|
34
35
  # We're directly inside a load_current_resource, which is probably via
35
36
  # the load_current_value DSL system, so call this a current resource.
36
- ChefSpec::API::StubsFor.setup_stubs_for(dup_resource, :current_resource) if stack.first.include?("`load_current_resource'")
37
+ ChefSpec::API::StubsFor.setup_stubs_for(dup_resource, :current_value) if caller.any? { |x| x.include?("`load_current_resource'") || x.include?("`load_after_resource'") }
37
38
  end
38
39
  end
39
40
 
@@ -133,7 +134,7 @@ module ChefSpec::Extensions::Chef::Resource
133
134
  super
134
135
  end
135
136
 
136
- def provides(name, *args, &block)
137
+ def provides(name, **options, &block)
137
138
  provides_names << name unless provides_names.include?(name)
138
139
  inject_actions(*allowed_actions)
139
140
  super
@@ -22,6 +22,15 @@ Chef::RunContext::CookbookCompiler.prepend(Module.new do
22
22
  super
23
23
  end
24
24
 
25
+ def load_ohai_plugins_from_cookbook(cookbook)
26
+ return super unless $CHEFSPEC_MODE
27
+ $CHEFSPEC_OHAI_PRELOAD ||= {}
28
+ # Already loaded this once.
29
+ return if $CHEFSPEC_OHAI_PRELOAD[cookbook]
30
+ $CHEFSPEC_OHAI_PRELOAD[cookbook] = true
31
+ super
32
+ end
33
+
25
34
  def load_lwrps_from_cookbook(cookbook)
26
35
  return super unless $CHEFSPEC_MODE
27
36
  $CHEFSPEC_LWRP_PRELOAD ||= {}
@@ -0,0 +1,11 @@
1
+ require 'ohai/system'
2
+
3
+ Ohai::System.prepend(Module.new do
4
+ # If an Ohai segment exists, don't actually pull data in for ohai.
5
+ # (we have fake data for that)
6
+ # @see Ohai::System#run_additional_plugins
7
+ def run_additional_plugins(plugin_path)
8
+ return super unless $CHEFSPEC_MODE
9
+ # noop
10
+ end
11
+ end)
@@ -133,6 +133,18 @@ module ChefSpec
133
133
  # Called when LWRPs are finished loading
134
134
  def lwrp_load_complete; end
135
135
 
136
+ # Called when an ohai plugin file loading starts
137
+ def ohai_plugin_load_start(file_count); end
138
+
139
+ # Called when an ohai plugin file has been loaded
140
+ def ohai_plugin_file_loaded(path); end
141
+
142
+ # Called when an ohai plugin file has an error on load.
143
+ def ohai_plugin_file_load_failed(path, exception); end
144
+
145
+ # Called when an ohai plugin file loading has finished
146
+ def ohai_plugin_load_complete; end
147
+
136
148
  # Called before attribute files are loaded
137
149
  def attribute_load_start(attribute_file_count); end
138
150
 
@@ -1,3 +1,3 @@
1
1
  module ChefSpec
2
- VERSION = '9.1.0'
2
+ VERSION = '9.2.0'
3
3
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chefspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 9.1.0
4
+ version: 9.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Crump
8
8
  - Seth Vargo
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-02-12 00:00:00.000000000 Z
12
+ date: 2020-06-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: chef
@@ -119,6 +119,7 @@ files:
119
119
  - lib/chefspec/extensions/chef/resource/freebsd_package.rb
120
120
  - lib/chefspec/extensions/chef/run_context/cookbook_compiler.rb
121
121
  - lib/chefspec/extensions/chef/securable.rb
122
+ - lib/chefspec/extensions/ohai/system.rb
122
123
  - lib/chefspec/file_cache_path_proxy.rb
123
124
  - lib/chefspec/formatter.rb
124
125
  - lib/chefspec/librarian.rb
@@ -200,7 +201,7 @@ homepage: https://github.com/chefspec/chefspec
200
201
  licenses:
201
202
  - MIT
202
203
  metadata: {}
203
- post_install_message:
204
+ post_install_message:
204
205
  rdoc_options: []
205
206
  require_paths:
206
207
  - lib
@@ -215,8 +216,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
215
216
  - !ruby/object:Gem::Version
216
217
  version: '0'
217
218
  requirements: []
218
- rubygems_version: 3.0.3
219
- signing_key:
219
+ rubygems_version: 3.1.2
220
+ signing_key:
220
221
  specification_version: 4
221
222
  summary: Write RSpec examples and generate coverage reports for Chef recipes!
222
223
  test_files: []