Sha256: 77ed737db352a215a59e5b32d362e38a98a2a6f899d80ffe465f111ff77ae73d

Contents?: true

Size: 1.56 KB

Versions: 11

Compression:

Stored size: 1.56 KB

Contents

module Berkshelf
  module RSpec
    module PathHelpers
      # The path to where berkshelf lives (tmp/berkshelf)
      #
      # @return [Pathname]
      def berkshelf_path
        tmp_path.join("berkshelf").expand_path
      end

      # The Berkshelf cookbook store
      #
      # @return [Berkshelf::CookbookStore]
      def cookbook_store
        Berkshelf.cookbook_store
      end

      # The tmp path where testing support/workspaces are
      #
      # @return [Pathname]
      def tmp_path
        Berkshelf.root.join("spec/tmp")
      end

      # The path to the spec fixtures
      #
      # @return [Pathname]
      def fixtures_path
        Berkshelf.root.join("spec/fixtures")
      end

      # The path to the Chef config fixture
      #
      # @return [String]
      def chef_config_path
        Berkshelf.root.join("spec/config/knife.rb").to_s
      end

      # The actual Chef config object
      #
      # @return [Bershelf::Chef::Config]
      def chef_config
        Berkshelf::ChefConfigCompat.from_file(chef_config_path)
      end

      def clean_tmp_path
        FileUtils.rm_rf(tmp_path)
        FileUtils.mkdir_p(tmp_path)
      end

      private

        # This is the magical "reset" function that gives us a clean working
        # directory on each run.
        #
        # @return [nil]
      def reload_configs
        Berkshelf.chef_config = chef_config

        # This fucking sucks...
        # load 'berkshelf/chef/config.rb'
        load "berkshelf/config.rb"

        Berkshelf.config = Berkshelf::Config.new
        nil
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
berkshelf-7.0.10 spec/support/path_helpers.rb
berkshelf-7.0.9 spec/support/path_helpers.rb
berkshelf-7.0.8 spec/support/path_helpers.rb
berkshelf-7.0.7 spec/support/path_helpers.rb
berkshelf-7.0.6 spec/support/path_helpers.rb
berkshelf-7.0.5 spec/support/path_helpers.rb
berkshelf-7.0.4 spec/support/path_helpers.rb
berkshelf-7.0.3 spec/support/path_helpers.rb
berkshelf-7.0.2 spec/support/path_helpers.rb
berkshelf-7.0.1 spec/support/path_helpers.rb
berkshelf-7.0.0 spec/support/path_helpers.rb