test/buildmaster/cotta/system_file_specifications.rb in BuildMaster-0.9.1 vs test/buildmaster/cotta/system_file_specifications.rb in BuildMaster-1.0.6
- old
+ new
@@ -1,80 +1,71 @@
-$:.unshift File.join(File.dirname(__FILE__), '..', '..', '..', 'lib')
+$:.unshift File.join(File.dirname(__FILE__), '..', '..', '..', 'lib', 'buildmaster')
-require 'buildmaster/cotta'
+require 'cotta'
require 'pathname'
def register_system_file_specifications
- specify 'Log all the shell commands' do
- @system.shell('my command')
- @system.executed_commands.length.should_equal(1)
- @system.executed_commands[0].should_equal 'my command'
- end
- specify 'root directory always exists' do
- @system.dir_exists?(Pathname.new('/')).should_equal true
- end
-
specify 'current directory always exists' do
- @system.dir_exists?(Pathname.new('.')).should_equal true
+ @system.dir_exists?(Pathname.new('.')).should == true
end
specify 'mkdir should create directory' do
pathname = Pathname.new('/one')
- @system.dir_exists?(pathname).should_equal false
+ @system.dir_exists?(pathname).should == false
@system.mkdir(pathname)
- @system.dir_exists?(pathname).should_equal true
+ @system.dir_exists?(pathname).should == true
end
specify 'mkdir raise error if dir already exists' do
pathname = Pathname.new('/one')
@system.mkdir(pathname)
lambda {@system.mkdir}.should_raise StandardError
end
specify 'io returns IO handle' do
pathname = Pathname.new('file.txt')
- @system.file_exists?(pathname).should_equal false
+ @system.file_exists?(pathname).should == false
write_io = load_io(pathname, 'w')
write_io.puts 'content'
write_io.close
- @system.file_exists?(pathname).should_equal true
+ @system.file_exists?(pathname).should == true
read_io = load_io(pathname, 'r')
- read_io.gets.should_equal "content\n"
+ read_io.gets.should == "content\n"
read_io.close
@system.delete_file(pathname)
end
specify 'file creation should leave file system consistent' do
pathname = Pathname.new('dir/sub/file.txt')
@system.mkdir(pathname.parent.parent)
@system.mkdir(pathname.parent)
- @system.file_exists?(pathname).should_equal false
- @system.dir_exists?(pathname.parent).should_equal true
+ @system.file_exists?(pathname).should == false
+ @system.dir_exists?(pathname.parent).should == true
load_io(pathname, 'w').close
- @system.file_exists?(pathname).should_equal true
- @system.dir_exists?(pathname).should_equal false
- @system.dir_exists?(pathname.parent).should_equal true
+ @system.file_exists?(pathname).should == true
+ @system.dir_exists?(pathname).should == false
+ @system.dir_exists?(pathname.parent).should == true
children = @system.list(pathname.parent)
- children.size.should_equal 1
- children[0].should_equal pathname.basename.to_s
+ children.size.should == 1
+ children[0].should == pathname.basename.to_s
end
specify 'directory creation should leave file system consistent' do
pathname = Pathname.new('root/dir/sub')
- @system.dir_exists?(pathname).should_equal false
- @system.file_exists?(pathname).should_equal false
- @system.dir_exists?(pathname.parent).should_equal false
+ @system.dir_exists?(pathname).should == false
+ @system.file_exists?(pathname).should == false
+ @system.dir_exists?(pathname.parent).should == false
@system.mkdir(pathname.parent.parent)
@system.mkdir(pathname.parent)
@system.mkdir(pathname)
- @system.dir_exists?(pathname).should_equal true
- @system.file_exists?(pathname).should_equal false
- @system.dir_exists?(pathname.parent).should_equal true
+ @system.dir_exists?(pathname).should == true
+ @system.file_exists?(pathname).should == false
+ @system.dir_exists?(pathname.parent).should == true
list = @system.list(pathname.parent)
- list.size.should_equal 1
- list[0].should_equal(pathname.basename.to_s)
+ list.size.should == 1
+ list[0].should ==(pathname.basename.to_s)
end
specify 'read io should raise error if file does not exists' do
pathname = Pathname.new('dir/file.txt')
Proc.new {@system.io(pathname, 'r')}.should_raise Errno::ENOENT
@@ -82,11 +73,11 @@
specify 'delete dir' do
pathname = Pathname.new('dir')
@system.mkdir(pathname)
@system.delete_dir(pathname)
- @system.dir_exists?(pathname).should_equal false
+ @system.dir_exists?(pathname).should == false
end
specify 'deleting dir that does not exist should raise error' do
pathname = Pathname.new('dir/dir2')
Proc.new {@system.delete_dir(pathname)}.should_raise Errno::ENOENT
@@ -97,54 +88,54 @@
write_io = load_io(pathname, 'w')
write_io.puts 'line'
write_io.close
target = Pathname.new('target')
@system.copy_file(pathname, target)
- @system.file_exists?(target).should_equal true
+ @system.file_exists?(target).should == true
read_io = load_io(target, 'r')
- read_io.gets.should_equal "line\n"
+ read_io.gets.should == "line\n"
read_io.close
end
specify 'move file' do
pathname = Pathname.new('file1')
write_content(pathname, 'line')
target = Pathname.new('target')
@system.move_file(pathname, target)
- @system.file_exists?(target).should_equal true
+ @system.file_exists?(target).should == true
read_io = load_io(target, 'r')
- read_io.gets.should_equal "line\n"
+ read_io.gets.should == "line\n"
read_io.close
- @system.file_exists?(pathname).should_equal false
+ @system.file_exists?(pathname).should == 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
+ @system.list(target).size.should == 2
+ @system.dir_exists?(source).should == false
+ @system.dir_exists?(target).should == true
+ @system.file_exists?(Pathname.new('target/file.txt')).should == true
+ @system.dir_exists?(Pathname.new('target/subdir')).should == 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
+ @system.list(target).size.should == 2
+ @system.dir_exists?(source).should == true
+ @system.dir_exists?(target).should == true
+ @system.file_exists?(Pathname.new('target/file.txt')).should == true
end
def write_content(pathname, content)
write_io = load_io(pathname, 'w')
write_io.puts content