require File.dirname(__FILE__) + '/../test_helper' require File.dirname(__FILE__) + '/../../lib/provisional/scm/repo_man_git' class RepoManGitTest < Test::Unit::TestCase def setup @scm = Provisional::SCM::RepoManGit.new( { 'name' => 'name', 'template_path' => 'template_path', 'domain' => 'example.com' } ) end def test_checkin repo_stub = stub() repo_stub.expects(:add).with('.') repo_stub.expects(:commit).with('Initial commit by Provisional') repo_stub.expects(:add_remote) repo_stub.expects(:push) Git.expects(:open).returns(repo_stub) Dir.expects(:chdir) gitignore_file = stub() gitignore_file.expects(:puts).with(@scm.gitignore) File.expects(:open).with('.gitignore', 'w').yields(gitignore_file) RepoMan::Repository.expects(:create).with(:name => 'name', :scm => 'git') @scm.checkin end def test_checkin_should_raise_RuntimeError_if_any_step_raises_any_exception repo_stub = stub() repo_stub.expects(:add).with('.') repo_stub.expects(:commit).with('Initial commit by Provisional') Git.expects(:open).returns(repo_stub) Dir.expects(:chdir) gitignore_file = stub() gitignore_file.expects(:puts).with(@scm.gitignore) File.expects(:open).with('.gitignore', 'w').yields(gitignore_file) RepoMan::Repository.expects(:create).with(:name => 'name', :scm => 'git').raises(Errno::ECONNREFUSED) assert_raise RuntimeError do @scm.checkin end end end