chefspec 9.1.0 → 9.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 96c39db8c598b7a40e7fd080c65db3a073a1e8e95f59a2628682587e5de4db56
4
- data.tar.gz: a0bc37df1322446f83af4488fa1def9124d821478c0364a40fcce138c10f63cf
3
+ metadata.gz: d5591af3861eae4ba3b5d9c37d274f38fa0279c9a5d91e2668d923251d1885ae
4
+ data.tar.gz: 36be14ae6da887efee4516070e3b6884e43950a8b9fddbbc28660d1ea7f6c841
5
5
  SHA512:
6
- metadata.gz: 354c875c5eb0890aea76c9bb7593dfec11d122157c42ca79842ff8a4264766e6a230fb57a14dfdd6c87887e7c4ba147ee388465e5c2b1fa782ed77a912145844
7
- data.tar.gz: 64ff73a7906b1e4ba085a9d5d9182903de2965c9ea4c979ad95363b45677d083868e0f64c30c2637ee7beed85333d309cbe42c26024c6fc7fddc0f6b3b08861d
6
+ metadata.gz: 24e86fab969faea333b44ab9db94663efe783383c37760ce581bd0a088e1f3dc96927dc8bab7624da966d5e60440cf6c97e31a2b56b3c72a89135b0805d17ebc
7
+ data.tar.gz: d6b244cc4207077b59a6f53f343b632fe2550549b4e3778bdbfca9848a510861d7fdbe885bc26556c38ba5d74dbb5d619e1073521a2d0a4da3f7d1bd3b94576d
@@ -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 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)
@@ -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)
@@ -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'
@@ -1,5 +1,5 @@
1
- require 'fileutils'
2
- require 'singleton'
1
+ require 'fileutils' unless defined?(FileUtils)
2
+ require 'singleton' unless defined?(Singleton)
3
3
 
4
4
  module ChefSpec
5
5
  class FileCachePathProxy
@@ -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.1'
3
3
  end
@@ -122,7 +122,7 @@ module ChefSpec
122
122
  require "chef_zero/data_store/memory_store_v2"
123
123
  ChefZero::DataStore::MemoryStoreV2.new
124
124
  when :on_disk
125
- require "tmpdir"
125
+ require "tmpdir" unless defined?(Dir.mktmpdir)
126
126
  require "chef_zero/data_store/raw_file_store"
127
127
  tmpdir = Dir.mktmpdir
128
128
  ChefZero::DataStore::RawFileStore.new(Dir.mktmpdir)
@@ -98,7 +98,7 @@ describe ChefSpec::SoloRunner do
98
98
  it 'sets the attributes from fauxhai' do
99
99
  expect(hash['os']).to eq('linux')
100
100
  expect(hash['languages']['ruby']['ruby_bin']).to eq('/usr/local/bin/ruby')
101
- expect(hash['os_version']).to match(/4.15.0-.*-.*/) # avoid failing when fauxhai data changes
101
+ expect(hash['os_version']).to match(/5.3.0-.*-.*/) # avoid failing when fauxhai data changes
102
102
  expect(hash['fqdn']).to eq('fauxhai.local')
103
103
  expect(hash['domain']).to eq('local')
104
104
  expect(hash['ipaddress']).to eq('10.0.0.2')
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.1
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-08-14 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: []