francois / piston

Piston is a utility that eases vendor branch management. This repository is a complete reimplementation of Piston to provide different backends, depending on the repositories and working copies you pistonize from.

Sun Apr 20 08:50:28 -0700 2008
francois (committer)
Mon Apr 21 13:14:28 -0700 2008
piston / test / unit / git / working_copy / test_guessing.rb
100644 35 lines (29 sloc) 1.112 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
require File.dirname(__FILE__) + "/../../../test_helper"
 
class TestGitWorkingCopyGuessing < Test::Unit::TestCase
  def setup
    @dir = Pathname.new("tmp/wc")
  end
 
  def test_does_git_status_on_directory
    Dir.expects(:chdir).with(@dir).yields
    Piston::Git::WorkingCopy.expects(:git).with(:status).returns("# On branch master
nothing to commit (working directory clean)
")
    assert Piston::Git::WorkingCopy.understands_dir?(@dir)
  end
 
  def test_does_git_status_on_parent_directories_recursively
    @wc = @dir
    @tmp = @wc.parent
    @root = @tmp.parent
 
    Dir.expects(:chdir).with(@dir).raises(Errno::ENOENT)
    Dir.expects(:chdir).with(@tmp).raises(Errno::ENOENT)
    Dir.expects(:chdir).with(@root).yields
    Piston::Git::WorkingCopy.expects(:git).with(:status).returns("# On branch master
nothing to commit (working directory clean)
")
    assert Piston::Git::WorkingCopy.understands_dir?(@dir)
  end
 
  def test_denies_when_git_unavailable
    Piston::Git::WorkingCopy.stubs(:git).raises(Piston::Git::Client::BadCommand)
    deny Piston::Git::WorkingCopy.understands_dir?(@dir)
  end
end