Sha256: a5a8bf41e0578c250e56e49e43bf4dd0e8ba1d34774b9533ddda287c03e03f4f

Contents?: true

Size: 1.55 KB

Versions: 13

Compression:

Stored size: 1.55 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

13 entries across 13 versions & 1 rubygems

Version Path
berkshelf-8.0.15 spec/support/path_helpers.rb
berkshelf-8.0.13 spec/support/path_helpers.rb
berkshelf-8.0.12 spec/support/path_helpers.rb
berkshelf-8.0.9 spec/support/path_helpers.rb
berkshelf-8.0.7 spec/support/path_helpers.rb
berkshelf-8.0.5 spec/support/path_helpers.rb
berkshelf-8.0.2 spec/support/path_helpers.rb
berkshelf-8.0.1 spec/support/path_helpers.rb
berkshelf-8.0.0 spec/support/path_helpers.rb
berkshelf-7.2.2 spec/support/path_helpers.rb
berkshelf-7.2.1 spec/support/path_helpers.rb
berkshelf-7.2.0 spec/support/path_helpers.rb
berkshelf-7.1.0 spec/support/path_helpers.rb