Sha256: 1aff4f069e1f510f960ad8b04d15ebfdec4f5bd3166024fe4ac0100fd625a510

Contents?: true

Size: 1.43 KB

Versions: 1

Compression:

Stored size: 1.43 KB

Contents

require 'spec'

$:.unshift File.join(File.dirname(__FILE__), '..', '..', '..', 'lib', 'buildmaster')

require 'cotta'
require 'cotta/in_memory_system'

module BuildMaster

describe 'Cotta' do
  before do
    # Given
    @system = InMemorySystem.new
    @cotta = Cotta.new(@system)
  end
  
  it 'shell out command to system' do
    # Given
    # When
    @system.output_for_command('shell command', 'test')
    @cotta.shell('shell command')
    # Ensure
    @system.executed_commands.length.should== 1
    @system.executed_commands[0].should == 'shell command'
  end
  
  it 'instantiate dir from cotta' do
    dir = @cotta.dir('dirname')
    dir.name.should == 'dirname'
  end
  
  it 'instantiate file from cotta' do
    file = @cotta.file('one/two/three.txt')
    file.name.should == 'three.txt'
    file.parent.name.should == 'two'
  end
  
  it 'entry creates file or directory based on which one exists' do
    @cotta.file('file').save
    @cotta.dir('dir').mkdirs
    @cotta.entry('file').exists?.should == true
    @cotta.entry('dir').exists?.should == true
  end
  
  it 'nil in, nil out' do
    @cotta.file(nil).should be_nil
    @cotta.dir(nil).should be_nil
    Cotta.file(nil).should be_nil
    Cotta.dir(nil).should be_nil
  end
  
  it 'create parent directory directly from __FILE__' do
    actual = BuildMaster::Cotta.parent_of(__FILE__)
    actual.name.should == 'cotta'
  end
  
end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
BuildMaster-1.1.9 test/buildmaster/cotta/tc_cotta.rb