Sha256: e8a2d9a96cdab7864494d18d3d5ce0d492c289d0cd99ecbaf7aa101e6f516a27

Contents?: true

Size: 1.59 KB

Versions: 16

Compression:

Stored size: 1.59 KB

Contents

class CookbookKitchen < KitchenAcceptance::Kitchen
  resource_name :cookbook_kitchen

  property :command, default: lazy { name.split(" ")[0] }
  property :kitchen_dir, default: lazy { ::File.join(repository_root, cookbook_relative_dir) }
  property :test_cookbook, String, default: lazy { name.split(" ")[1] }
  property :repository, String, default: lazy { "chef-cookbooks/#{test_cookbook}" },
    coerce: proc { |v|
      # chef-cookbooks/runit -> https://github.com/chef-cookbooks/runit.git
      if !v.include?(':')
        "https://github.com/#{v}.git"
      else
        v
      end
    }
  property :repository_root, String, default: lazy { ::File.join(Chef.node["chef-acceptance"]["suite-dir"], "test_run", test_cookbook) }
  property :branch, String, default: "master"
  property :cookbook_relative_dir, String, default: ""
  property :env, default: lazy {
    {
      "BUNDLE_GEMFILE" => ::File.expand_path("../Gemfile", Chef.node["chef-acceptance"]["suite-dir"]),
#      "KITCHEN_GLOBAL_YAML" => ::File.join(kitchen_dir, ".kitchen.yml"),
      "KITCHEN_YAML" => ::File.join(node["chef-acceptance"]["suite-dir"], ".kitchen.#{test_cookbook}.yml")
    }
  }

  action :run do
    # Ensure the parent directory exists
    directory ::File.expand_path("..", repository_root) do
      recursive true
    end

    # Grab the cookbook
    # TODO Grab the source URL from supermarket
    # TODO get git to include its kitchen tests in the cookbook.
    git repository_root do
      repository new_resource.repository
      branch new_resource.branch
    end

    super()
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
chef-13.11.3-universal-mingw32 acceptance/top-cookbooks/.acceptance/acceptance-cookbook/libraries/cookbook_kitchen.rb
chef-13.10.4-universal-mingw32 acceptance/top-cookbooks/.acceptance/acceptance-cookbook/libraries/cookbook_kitchen.rb
chef-13.10.0-universal-mingw32 acceptance/top-cookbooks/.acceptance/acceptance-cookbook/libraries/cookbook_kitchen.rb
chef-13.9.4-universal-mingw32 acceptance/top-cookbooks/.acceptance/acceptance-cookbook/libraries/cookbook_kitchen.rb
chef-14.2.0-universal-mingw32 acceptance/top-cookbooks/.acceptance/acceptance-cookbook/libraries/cookbook_kitchen.rb
chef-14.1.12-universal-mingw32 acceptance/top-cookbooks/.acceptance/acceptance-cookbook/libraries/cookbook_kitchen.rb
chef-14.1.1-universal-mingw32 acceptance/top-cookbooks/.acceptance/acceptance-cookbook/libraries/cookbook_kitchen.rb
chef-13.9.1-universal-mingw32 acceptance/top-cookbooks/.acceptance/acceptance-cookbook/libraries/cookbook_kitchen.rb
chef-14.0.190-universal-mingw32 acceptance/top-cookbooks/.acceptance/acceptance-cookbook/libraries/cookbook_kitchen.rb
chef-13.8.5-universal-mingw32 acceptance/top-cookbooks/.acceptance/acceptance-cookbook/libraries/cookbook_kitchen.rb
chef-13.8.3-universal-mingw32 acceptance/top-cookbooks/.acceptance/acceptance-cookbook/libraries/cookbook_kitchen.rb
chef-12.22.1 acceptance/top-cookbooks/.acceptance/acceptance-cookbook/libraries/cookbook_kitchen.rb
chef-12.22.1-universal-mingw32 acceptance/top-cookbooks/.acceptance/acceptance-cookbook/libraries/cookbook_kitchen.rb
chef-13.8.0-universal-mingw32 acceptance/top-cookbooks/.acceptance/acceptance-cookbook/libraries/cookbook_kitchen.rb
chef-12.8.1 acceptance/top-cookbooks/.acceptance/acceptance-cookbook/libraries/cookbook_kitchen.rb
chef-12.8.1-universal-mingw32 acceptance/top-cookbooks/.acceptance/acceptance-cookbook/libraries/cookbook_kitchen.rb