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 +4 -4
- data/lib/chefspec/api/stubs_for.rb +12 -9
- data/lib/chefspec/extensions.rb +1 -0
- data/lib/chefspec/extensions/chef/resource.rb +4 -3
- data/lib/chefspec/extensions/chef/run_context/cookbook_compiler.rb +9 -0
- data/lib/chefspec/extensions/ohai/system.rb +11 -0
- data/lib/chefspec/formatter.rb +12 -0
- data/lib/chefspec/version.rb +1 -1
- metadata +7 -6
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: c20bc92ebea039d7261547ec0e91686f1c4c83e57f7bd19e98f4a4e4fce13aa3
         | 
| 4 | 
            +
              data.tar.gz: b6f4060d3844074dfffe298c3a5d0d75a766926abf41e80dbb7b95c2aa26500c
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 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  | 
| 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 | 
            -
                     | 
| 65 | 
            +
                    stubs_for_current_value(target, &block) if current_value
         | 
| 65 66 | 
             
                  end
         | 
| 66 67 |  | 
| 67 | 
            -
                  # Register stubs for  | 
| 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  | 
| 74 | 
            -
                    _chefspec_stubs_for_registry[: | 
| 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# | 
| 115 | 
            -
                    def  | 
| 116 | 
            -
                      before {  | 
| 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/extensions.rb
    CHANGED
    
    | @@ -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 =  | 
| 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, : | 
| 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,  | 
| 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)
         | 
    
        data/lib/chefspec/formatter.rb
    CHANGED
    
    | @@ -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 |  | 
    
        data/lib/chefspec/version.rb
    CHANGED
    
    
    
        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. | 
| 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- | 
| 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. | 
| 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: []
         |