def setup!
      # Get the list of Berkshelf options
      opts = RSpec.configuration.berkshelf_options
      if !opts.is_a?(Hash)
        raise InvalidBerkshelfOptions(value: opts.inspect)
      end

      berksfile = ::Berkshelf::Berksfile.from_options(opts)

      # Grab a handle to tmpdir, since Berkshelf 2 modifies it a bit
      tmpdir = File.join(@tmpdir, 'cookbooks')

      ::Berkshelf.ui.mute do
        if ::Berkshelf::Berksfile.method_defined?(:vendor)
          # Berkshelf 3.0 requires the directory to not exist
          FileUtils.rm_rf(tmpdir)
          berksfile.vendor(tmpdir)
        else
          berksfile.install(path: tmpdir)
        end
      end

      filter = Coverage::BerkshelfFilter.new(berksfile)
      Coverage.add_filter(filter)

      ::RSpec.configure { |config| config.cookbook_path = tmpdir }
    end
def setup!
      # Get the list of Berkshelf options
      opts = RSpec.configuration.berkshelf_options
      if !opts.is_a?(Hash)
        raise InvalidBerkshelfOptions(value: opts.inspect)
      end

      berksfile = ::Berkshelf::Berksfile.from_options(opts)

      # Grab a handle to tmpdir, since Berkshelf 2 modifies it a bit
      tmpdir = File.join(@tmpdir, 'cookbooks')

      ::Berkshelf.ui.mute do
        if ::Berkshelf::Berksfile.method_defined?(:vendor)
          # Berkshelf 3.0 requires the directory to not exist
          FileUtils.rm_rf(tmpdir)
          berksfile.vendor(tmpdir)
        else
          berksfile.install(path: tmpdir)
        end
      end

      filter = Coverage::BerkshelfFilter.new(berksfile)
      Coverage.add_filter(filter)

      ::RSpec.configure { |config| config.cookbook_path = tmpdir }
    end
Setup and install the necessary dependencies in the temporary directory.