public
Description: 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.
Homepage: http://piston.rubyforge.org/
Clone URL: git://github.com/francois/piston.git
francois (author)
Tue May 13 17:17:53 -0700 2008
commit  1d52246f7acabb0fdec2f555430702840146d418
tree    744b3fa8d01e231c8493bedd58a04a48fccff70c
parent  0d066f30f00db013c1dd0ac62b464156dc061b92
piston / test / unit / test_lock_unlock.rb
100644 47 lines (40 sloc) 1.329 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
36
37
38
39
40
41
42
43
44
45
46
47
require File.dirname(__FILE__) + "/../test_helper"
 
class TestLockUnlock < Test::Unit::TestCase
  def setup
    @values = {"lock" => false}
    @wcdir = "tmp/wcdir"
    @wc = mock("WorkingCopy")
    @wc.stubs(:validate!)
  end
 
  def test_lock_working_copy
    run_and_verify(true) do
      @wc.expects(:recall).returns(@values)
      @wc.expects(:finalize).returns(@values)
      @wc.expects(:remember).with(@values.merge("lock" => true), @values["handler"]).returns(@values)
    end
  end
 
  def test_unlock_working_copy
    run_and_verify(false) do
      @wc.expects(:recall).returns(@values)
      @wc.expects(:finalize).returns(@values)
      @wc.expects(:remember).with(@values.merge("lock" => false), @values["handler"]).returns(@values)
    end
  end
 
  def test_validates_working_copy_before_working
    assert_raise(Piston::WorkingCopy::NotWorkingCopy) do
      run_and_verify do
        @wc.expects(:validate!).raises(Piston::WorkingCopy::NotWorkingCopy)
      end
    end
  end
 
  private
  def run_and_verify(lock=true)
    yield
    lock_unlock_command.run(@wcdir, lock)
  end
 
  def lock_unlock_command
    Piston::WorkingCopy.expects(:guess).with(@wcdir).returns(@wc)
    Piston::Commands::LockUnlock.new(:verbose => "verbose",
                                     :quiet => "quiet", :force => "force")
  end
end