5
5
6
6
class BumpCommandTest < Test ::Unit ::TestCase
7
7
include GemRelease
8
-
8
+
9
9
def setup
10
10
build_sandbox
11
11
stub_command ( BootstrapCommand , :say )
12
+ stub_command ( TagCommand , :say )
12
13
stub_command ( BumpCommand , :say )
14
+ stub_command ( ReleaseCommand , :say )
13
15
BootstrapCommand . new . send ( :write_scaffold )
14
16
end
15
-
17
+
16
18
def teardown
17
19
@version = nil
18
20
teardown_sandbox
19
21
end
20
-
22
+
21
23
def version ( options = { } )
22
24
@version ||= VersionFile . new ( options )
23
25
end
24
-
26
+
25
27
test "gem bump" do
26
28
command = BumpCommand . new
27
29
command . expects ( :` ) . with ( "git add #{ version . send ( :filename ) } " )
28
30
command . expects ( :` ) . with ( 'git commit -m "Bump to 0.0.2"' )
29
31
command . invoke
30
32
end
31
-
33
+
34
+ test "gem bump --version 0.1.0" do
35
+ command = BumpCommand . new
36
+ command . expects ( :` ) . with ( "git add #{ version . send ( :filename ) } " )
37
+ command . expects ( :` ) . with ( 'git commit -m "Bump to 0.1.0"' )
38
+ command . invoke ( '--version' , '0.1.0' )
39
+ end
40
+
32
41
test "gem bump --push" do
33
42
command = BumpCommand . new
34
43
command . expects ( :` ) . with ( "git add #{ version . send ( :filename ) } " )
35
44
command . expects ( :` ) . with ( 'git commit -m "Bump to 0.0.2"' )
36
45
command . expects ( :` ) . with ( 'git push' )
37
46
command . invoke ( '--push' )
38
47
end
39
-
48
+
49
+ test "gem bump --push --tag" do
50
+ command = BumpCommand . new
51
+ command . expects ( :` ) . with ( "git add #{ version . send ( :filename ) } " )
52
+ command . expects ( :` ) . with ( 'git commit -m "Bump to 0.0.2"' )
53
+ command . expects ( :` ) . with ( 'git push' )
54
+ TagCommand . any_instance . stubs ( :gem_version ) . returns ( '0.0.2' )
55
+ TagCommand . any_instance . expects ( :` ) . with ( "git tag -am 'tag v0.0.2' v0.0.2" )
56
+ TagCommand . any_instance . expects ( :` ) . with ( 'git push --tags origin' )
57
+ command . invoke ( '--push' , '--tag' )
58
+ end
59
+
60
+ test "gem bump --push --release" do
61
+ command = BumpCommand . new
62
+ command . expects ( :` ) . with ( "git add #{ version . send ( :filename ) } " )
63
+ command . expects ( :` ) . with ( 'git commit -m "Bump to 0.0.2"' )
64
+ command . expects ( :` ) . with ( 'git push' )
65
+
66
+ release_command = ReleaseCommand . new
67
+ ReleaseCommand . expects ( :new ) . returns ( release_command )
68
+ ReleaseCommand . any_instance . expects ( :build )
69
+ ReleaseCommand . any_instance . expects ( :push )
70
+ ReleaseCommand . any_instance . expects ( :remove )
71
+
72
+ command . invoke ( '--push' , '--release' )
73
+ end
74
+
75
+ test "gem bump --push --tag --release" do
76
+ command = BumpCommand . new
77
+ command . expects ( :` ) . with ( "git add #{ version . send ( :filename ) } " )
78
+ command . expects ( :` ) . with ( 'git commit -m "Bump to 0.0.2"' )
79
+ command . expects ( :` ) . with ( 'git push' )
80
+
81
+ release_command = ReleaseCommand . new
82
+ ReleaseCommand . expects ( :new ) . returns ( release_command )
83
+ ReleaseCommand . any_instance . expects ( :build )
84
+ ReleaseCommand . any_instance . expects ( :push )
85
+ ReleaseCommand . any_instance . expects ( :remove )
86
+
87
+ release_command = TagCommand . new
88
+ TagCommand . expects ( :new ) . returns ( release_command )
89
+ TagCommand . any_instance . expects ( :tag )
90
+ TagCommand . any_instance . expects ( :push )
91
+
92
+ command . invoke ( '--push' , '--tag' , '--release' )
93
+ end
94
+
40
95
test "old_number" do
41
96
assert_equal '0.0.1' , version . old_number
42
97
end
43
-
98
+
44
99
test "new_number w/ default target" do
45
100
assert_equal '0.0.2' , version . new_number
46
101
end
47
-
102
+
48
103
test "new_number w/ :patch target" do
49
104
assert_equal '0.0.2' , version ( :target => :patch ) . new_number
50
105
end
51
-
106
+
52
107
test "new_number w/ :minor target" do
53
108
assert_equal '0.1.0' , version ( :target => :minor ) . new_number
54
109
end
55
-
110
+
56
111
test "new_number w/ :major target" do
57
112
assert_equal '1.0.0' , version ( :target => :major ) . new_number
58
113
end
59
-
114
+
60
115
test "new_number w/ given version number" do
61
116
assert_equal '1.1.1' , version ( :target => '1.1.1' ) . new_number
62
117
end
63
-
118
+
64
119
test "bumped_content" do
65
- assert_equal "module FooBar\n VERSION = \" 0.0.2\" \n end" , version . send ( :bumped_content )
120
+ assert_equal "module FooBar\n VERSION = \" 0.0.2\" \n end\n " , version . send ( :bumped_content )
66
121
end
67
- end
122
+ end
0 commit comments