test/buildmaster/tc_svn_driver.rb in BuildMaster-0.8.1 vs test/buildmaster/tc_svn_driver.rb in BuildMaster-0.9.0

- old
+ new

@@ -1,73 +1,86 @@ $:.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 SvnDriverTest < Test::Unit::TestCase - protected - def setup - super - @path = File.join(File.dirname(__FILE__), "..", "..") - @info = SvnInfo.new @path + +context 'SVN drivers' do + setup do + @system = InMemorySystem.new + cotta = Cotta.new(@system) + @work_dir_root = cotta.dir('/workdir') + @work_dir_root.dir('.svn').file('entries').save <<CONTENT +<?xml version="1.0" encoding="utf-8"?> +<wc-entries + xmlns="svn:"> +<entry + committed-rev="120" + name="" + committed-date="2006-09-05T06:50:07.932800Z" + url="svn+ssh://wolfdancer@rubyforge.org/var/svn/buildmaster/trunk" + last-author="wolfdancer" + kind="dir" + uuid="ab7ff8c2-9713-0410-a269-a4b56b3120d2" + repos="svn+ssh://wolfdancer@rubyforge.org/var/svn/buildmaster" + prop-time="2006-09-05T06:49:40.625000Z" + revision="120"/> +</wc-entries> +CONTENT + @info = SvnInfo.new @work_dir_root end - public - def test_load_info - info = SvnInfo.new(@path) - assert_equal(@path, info.path) - assert_equal('svn+ssh://wolfdancer@rubyforge.org/var/svn/buildmaster', info.repository_root) + specify 'load svn info from the .svn directory' do + info = SvnInfo.new(@work_dir_root) + info.work_dir.should_equal @work_dir_root + info.repository_root.should_equal 'svn+ssh://wolfdancer@rubyforge.org/var/svn/buildmaster' end - def test_load_driver - svn = SvnDriver.from_path(@path) + specify 'load svn driver from the root directory' do + svn = SvnDriver.from_path(@work_dir_root) svn.command('info') end - def test_status + specify 'svn status command' do log = '' - svn = SvnDriver.new(@info){|command| log = command} + svn = SvnDriver.new(@info) svn.status - assert_equal("svn status #{@path}", log) + @system.executed_commands[0].should_equal "svn status #{@work_dir_root.path}" end - def test_update + specify 'svn update command' do log = '' - svn = SvnDriver.new(@info) {|command| log = command} + svn = SvnDriver.new(@info) svn.update - assert_equal("svn update #{@path}", log) + @system.executed_commands[0].should_equal "svn update #{@work_dir_root.path}" end - def test_commit - log = '' - svn = SvnDriver.new(@info) {|command| log = command} + specify 'svn commit command' do + svn = SvnDriver.new(@info) svn.commit('message') - assert_equal("svn commit #{@path} -m \"message\"", log) + @system.executed_commands[0].should_equal "svn commit #{@work_dir_root.path} -m \"message\"" end - def test_checkout - log = '' - svn = SvnDriver.new(@info) {|command| log = command} + specify 'svn check out command' do + svn = SvnDriver.new(@info) svn.checkout('output') - assert_equal("svn checkout #{@info.repository_root}/trunk output", log) + @system.executed_commands[0].should_equal "svn checkout #{@info.repository_root}/trunk output" end - def test_command - log = '' - svn = SvnDriver.new(@info) {|command| log = command} + specify 'svn command' do + svn = SvnDriver.new(@info) svn.command('info') - assert_equal("svn info #{@path}", log) + @system.executed_commands[0].should_equal "svn info #{@work_dir_root.path}" end - def test_tag - log = '' - svn = SvnDriver.new(@info) {|command| log = command} + specify 'svn tag' do + svn = SvnDriver.new(@info) tag = 'build_0.0.5_b3' svn.tag(tag) - assert_equal( - "svn copy #{@info.repository_root}/trunk #{@info.repository_root}/tags/#{tag} -m \"ruby buildmaster\"", - log) + @system.executed_commands[0].should_equal "svn copy #{@info.repository_root}/trunk #{@info.repository_root}/tags/#{tag} -m \"ruby buildmaster\"" end end end \ No newline at end of file