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
Search Repo:
Some tests for Piston::WorkingCopy #exist?, #pistonized? and #validate!
francois (author)
Tue May 13 16:08:45 -0700 2008
commit  4c53f702589f0a701883e779b4bddcd55a2fc283
tree    c1250ad703589324691d1a07aaf903b3dfea861a
parent  81776d2d7148ec158af7ae8f5363db0c2ed40297
...
55
56
57
58
 
 
59
60
61
...
55
56
57
 
58
59
60
61
62
0
@@ -55,7 +55,8 @@
0
     end
0
 
0
     def validate!
0
- raise NotWorkingCopy unless self.exist? && self.pistonized?
0
+ raise NotWorkingCopy unless self.pistonized?
0
+ self
0
     end
0
 
0
     # Creates the initial working copy for pistonizing a new repository.
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
0
@@ -1 +1,69 @@
0
+require File.dirname(__FILE__) + "/../../test_helper"
0
+
0
+class TestWorkingCopyValidate < Test::Unit::TestCase
0
+ def setup
0
+ @wcdir = Pathname.new("tmp/wc")
0
+ @wcdir.rmtree rescue nil
0
+ @wcdir.mkpath
0
+ @wc = Piston::WorkingCopy.new(@wcdir)
0
+ end
0
+
0
+ def teardown
0
+ @wcdir.rmtree rescue nil
0
+ end
0
+
0
+ def test_exists_when_the_directory_exists
0
+ assert @wc.exist?, "WorkingCopy should have existed, since the directory exists"
0
+ end
0
+
0
+ def test_does_not_exist_when_directory_not_present
0
+ @wcdir.rmtree
0
+ deny @wc.exist?, "WorkingCopy should NOT have existed, since the directory does not exist"
0
+ end
0
+
0
+ def test_does_not_exist_when_directory_is_a_file
0
+ @wcdir.rmtree
0
+ touch(@wcdir)
0
+ deny @wc.exist?, "WorkingCopy should NOT have existed, since the directory is a file"
0
+ end
0
+
0
+ def test_is_pistonized_if_exist_and_has_piston_dot_yaml_file
0
+ @wc.stubs(:exist?).returns(true)
0
+ touch(@wcdir + ".piston.yml")
0
+ assert @wc.pistonized?, "WorkingCopy should be Pistonized, since the .piston.yml file exists"
0
+ end
0
+
0
+ def test_is_NOT_pistonized_if_no_piston_dot_yaml_file
0
+ @wc.stubs(:exist?).returns(true)
0
+ deny @wc.pistonized?, "WorkingCopy should not be Pistonized, since the .piston.yml does not file exists"
0
+ end
0
+
0
+ def test_is_NOT_pistonized_if_exist_returns_false
0
+ @wc.stubs(:exist?).returns(false)
0
+ deny @wc.pistonized?, "WorkingCopy should not be Pistonized, since #exist? returned false"
0
+ end
0
+
0
+ def test_is_NOT_pistonized_if_piston_dot_yaml_is_a_directory
0
+ @wc.stubs(:exist?).returns(true)
0
+ (@wcdir + ".piston.yml").mkdir
0
+ deny @wc.pistonized?, "WorkingCopy should not be Pistonized, since .piston.yml is a directory"
0
+ end
0
+
0
+ def test_validate_bang_returns_self_when_ok
0
+ @wc.stubs(:pistonized?).returns(true)
0
+ assert_equal @wc, @wc.validate!
0
+ end
0
+
0
+ def test_validate_bang_raises_not_working_copy_when_not_pistonized
0
+ @wc.stubs(:pistonized?).returns(false)
0
+ assert_raise(Piston::WorkingCopy::NotWorkingCopy) do
0
+ @wc.validate!
0
+ end
0
+ end
0
+
0
+ protected
0
+ def touch(path)
0
+ File.open(path, "wb") {|f| f.write ""}
0
+ end
0
+end

Comments

    No one has commented yet.