test/buildmaster/cotta/tc_cotta.rb in BuildMaster-0.9.1 vs test/buildmaster/cotta/tc_cotta.rb in BuildMaster-1.0.6

- old
+ new

@@ -1,33 +1,59 @@ -$:.unshift File.join(File.dirname(__FILE__), '..', '..', '..', 'lib') - require 'spec' -require 'buildmaster/cotta' -require 'buildmaster/cotta/in_memory_system' +$:.unshift File.join(File.dirname(__FILE__), '..', '..', '..', 'lib', 'buildmaster') + +require 'cotta' +require 'cotta/in_memory_system' + module BuildMaster context 'Cotta' do setup do + # Given @system = InMemorySystem.new @cotta = Cotta.new(@system) end specify 'shell out command to system' do + # Given + # When + @system.output_for_command('shell command', 'test') @cotta.shell('shell command') - @system.executed_commands.length.should_equal 1 - @system.executed_commands[0].should_equal 'shell command' + # Ensure + @system.executed_commands.length.should== 1 + @system.executed_commands[0].should == 'shell command' end specify 'instantiate dir from cotta' do dir = @cotta.dir('dirname') - dir.name.should_equal 'dirname' + dir.name.should == 'dirname' end specify 'instantiate file from cotta' do file = @cotta.file('one/two/three.txt') - file.name.should_equal 'three.txt' - file.parent.name.should_equal 'two' + file.name.should == 'three.txt' + file.parent.name.should == 'two' end + + specify '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 + + specify '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 + + specify 'create parent directory directly from __FILE__' do + actual = BuildMaster::Cotta.parent_of(__FILE__) + actual.name.should == 'cotta' + end + end end