Sha256: 754313685679eb691936b74a82970d947fe9304d85e7bf795cf74d9c1e4745bd

Contents?: true

Size: 1.36 KB

Versions: 2

Compression:

Stored size: 1.36 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

describe SousChef::Resource::Directory do
  before do
    @directory = resource("bin") do
    end
    @directory.to_script # evaluate the block
  end

  it "has a name" do
    @directory.name.should == "bin"
  end

  it "has a path equal to the name when no explicit path is given" do
    @directory.path.should == "bin"
  end

  it "has a path as set when an explicit path is given" do
    @directory = resource("bin") do
      path "/home/user/bin"
    end
    @directory.to_script # evaluate the block
    @directory.path.should == "/home/user/bin"
  end

  it "creates the directory" do
    @directory.to_script.should == %{mkdir -p bin}
  end

  it "allows deleting the directory" do
    directory = resource("bin") do
      action :delete
    end
    directory.to_script.should == %{rmdir bin}
  end

  it "raises an argument error on bad action" do
    lambda {
      resource("bin") { action :email }.setup
    }.should raise_error(ArgumentError)
  end

  it "sets the mode of the directory" do
    @directory = resource("bin") do
      mode 0600
    end

    @directory.to_script.should == %q{
mkdir -p bin
chmod 0600 bin
    }.strip
  end

  it "force deletes the directory" do
    directory = resource("bin") do
      action :delete
      force true
    end
    directory.to_script.should == %{rm -rf bin}
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sous_chef-0.0.4 spec/resource/directory_spec.rb
sous_chef-0.0.3 spec/resource/directory_spec.rb