Sha256: 7b30594b2980a2ff7d594ea6fd7e64cc28552412fe8219a71ebfa29b71fb5048

Contents?: true

Size: 1.71 KB

Versions: 1

Compression:

Stored size: 1.71 KB

Contents

require 'logical-construct/target/platforms'
require 'mattock/testing/rake-example-group'

describe LogicalConstruct::VirtualBox::ChefConfig do
  include Mattock::RakeExampleGroup
  include Mattock::CommandLineExampleGroup
  include FileSandbox

  before :each do
    sandbox.new :directory => "construct-dir"
    sandbox.new :directory => "chef-dir"
  end

  let :provision do
    require 'logical-construct/target/provision'
    LogicalConstruct::Provision.new do |prov|
      prov.construct_dir = "construct-dir"
    end
  end

  let :resolution do
    require 'logical-construct/testing/resolve-configuration'
    LogicalConstruct::Testing::ResolveConfiguration.new(provision) do |resolve|
      resolve.resolutions = {
        'chef_config:cookbook_tarball' => "",
        'chef_config:json_attribs' => "",
      }
    end
  end

  let! :chef_config do
    LogicalConstruct::VirtualBox::ChefConfig.new(provision, resolution) do |cc|
      cc.file_cache_path = "chef-dir"
      cc.solo_rb = "chef-solo.rb"
    end
  end

  it "should make an absolute path for solo.rb" do
    chef_config.solo_rb.should =~ /\A\//
  end

  describe "invoked" do
    before :each do
      expect_command /tar/, 0
      rake[File::join(sandbox["chef-dir"].path, "chef-solo.rb")].invoke
    end

    it "should generate the chef-solo.rb file" do
      sandbox["chef-dir/chef-solo.rb"].should be_exist
    end

    describe "resulting config file" do
      subject do
        sandbox["chef-dir/chef-solo.rb"].contents
      end

      it{ should =~ %r{file_cache_path\s*(["']).*\1} }
      it{ should =~ %r{cookbook_path\s*(["']).*/cookbooks\1} }
      it{ should =~ %r{json_attribs\s*(["']).*/node.json\1} }
      it{ should_not =~ /role_path/ }
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
logical-construct-0.0.1.localtesting spec/target/chef-config.rb