test/buildmaster/tc_cvs_driver.rb in BuildMaster-0.8.1 vs test/buildmaster/tc_cvs_driver.rb in BuildMaster-0.9.0
- old
+ new
@@ -1,65 +1,63 @@
$:.unshift File.join(File.dirname(__FILE__), "..", "..", "lib")
-require 'test/unit'
+require 'spec'
require 'buildmaster'
+require 'buildmaster/cotta'
+require 'buildmaster/cotta/in_memory_system'
module BuildMaster
-class CvsDriverTest < Test::Unit::TestCase
- protected
- def setUp()
- super
+context 'CvsDriverTest' do
+
+ setup do
+ @system = InMemorySystem.new
+ @cotta = Cotta.new(@system)
+ @working = @cotta.dir('working')
end
- private
- def ensure_folder_exists(path)
- if (not File.exists? path)
- Dir.mkdir(path)
- end
+ teardown do
+ @system = nil
+ @cotta = nil
+ @working = nil
end
-
- public
- def test_load_CvsInfo
- folder = 'tmp'
- ensure_folder_exists(folder);
+
+ specify 'load_CvsInfo' do
+ folder = @cotta.dir('tmp')
+ folder.mkdirs
root = ':ext:wolfdancer@cvsserver.com:/cvs/root'
repository = 'xpe'
- write("#{folder}/ROOT", root)
- write("#{folder}/Repository", repository)
+ folder.file('ROOT').save(root)
+ folder.file('Repository').save(repository)
cvs = CvsInfo.load(folder)
- assert_equal(root, cvs.root)
- assert_equal(repository, cvs.repository)
+ cvs.root.should_equal root
+ cvs.repository.should_equal repository
end
- def tes_checkout
- log = ''
- client = CvsDriver.new(CvsInfo.new('root', 'module'), 'working') {|command| log = command}
+ specify 'checkout' do
+ client = CvsDriver.new(CvsInfo.new('root', 'module'), @working)
client.checkout
- assert_equal('cvs -d root co -d working module', log)
+ @system.executed_commands.size.should_equal 1
+ @system.executed_commands[0].should_equal 'cvs -d root co -d working module'
end
- def test_update
+ specify 'update' do
log = ''
- client = CvsDriver.new(CvsInfo.new('root', 'module'), 'working') {|command| log = command}
+ client = CvsDriver.new(CvsInfo.new('root', 'module'), @working)
client.update
- assert_equal('cvs -d root update working', log)
+ @system.executed_commands.size.should_equal 1
+ @system.executed_commands[0].should_equal 'cvs -d root update working'
client.update('-PAd')
- assert_equal('cvs -d root update -PAd working', log)
+ @system.executed_commands.size.should_equal 2
+ @system.executed_commands[1].should_equal 'cvs -d root update -PAd working'
end
- def test_command
+ specify 'command' do
log = ''
- client = CvsDriver.new(CvsInfo.new('root', 'module'), 'working') {|command| log = command}
+ client = CvsDriver.new(CvsInfo.new('root', 'module'), @working)
client.command('command -option argument')
- assert_equal('cvs -d root command -option argument working', log)
- end
-
- private
- def write(fileName, content)
- File.open(fileName, "w") do |file|
- file.puts content
- end
+ @system.executed_commands.size.should_equal 1
+ @system.executed_commands[0].should_equal 'cvs -d root command -option argument working'
end
end
end
\ No newline at end of file