test/buildmaster/cotta/system_file_specifications.rb in BuildMaster-0.9.0 vs test/buildmaster/cotta/system_file_specifications.rb in BuildMaster-0.9.1

- old
+ new

@@ -96,30 +96,63 @@ pathname = Pathname.new('file1') write_io = load_io(pathname, 'w') write_io.puts 'line' write_io.close target = Pathname.new('target') - @system.copy(pathname, target) + @system.copy_file(pathname, target) @system.file_exists?(target).should_equal true read_io = load_io(target, 'r') read_io.gets.should_equal "line\n" read_io.close end specify 'move file' do pathname = Pathname.new('file1') - write_io = load_io(pathname, 'w') - write_io.puts 'line' - write_io.close + write_content(pathname, 'line') target = Pathname.new('target') - @system.move(pathname, target) + @system.move_file(pathname, target) @system.file_exists?(target).should_equal true read_io = load_io(target, 'r') read_io.gets.should_equal "line\n" read_io.close @system.file_exists?(pathname).should_equal false end + specify 'move dir' do + source = Pathname.new('source') + @system.mkdir source + source_file = Pathname.new('source/file.txt') + write_content(source_file, 'file.txt') + @system.mkdir source.join('subdir') + target = Pathname.new('target') + @system.move_dir(source, target) + @system.list(target).size.should_equal 2 + @system.dir_exists?(source).should_equal false + @system.dir_exists?(target).should_equal true + @system.file_exists?(Pathname.new('target/file.txt')).should_equal true + @system.dir_exists?(Pathname.new('target/subdir')).should_equal true + end + + specify 'copy dir' do + source = Pathname.new('source') + @system.mkdir source + source_file = Pathname.new('source/file.txt') + write_content(source_file, 'file.txt') + @system.mkdir source.join('subdir') + target = Pathname.new('target') + @system.copy_dir(source, target) + @system.list(target).size.should_equal 2 + @system.dir_exists?(source).should_equal true + @system.dir_exists?(target).should_equal true + @system.file_exists?(Pathname.new('target/file.txt')).should_equal true + end + + def write_content(pathname, content) + write_io = load_io(pathname, 'w') + write_io.puts content + write_io.close + end + end def load_io(*args) io = @system.io(*args) if (io) @ios.push(io)