buildr-gemjar 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (252) hide show
  1. data/.braids +8 -0
  2. data/.gitignore +5 -0
  3. data/.rvmrc +1 -0
  4. data/CHANGELOG.md +4 -0
  5. data/Gemfile +4 -0
  6. data/LICENSE +20 -0
  7. data/README.md +98 -0
  8. data/Rakefile +8 -0
  9. data/buildr-gemjar.gemspec +42 -0
  10. data/lib/buildr-gemjar.rb +162 -0
  11. data/lib/buildr-gemjar/version.rb +3 -0
  12. data/meta.rakefile +30 -0
  13. data/spec/buildr-gemjar/version_spec.rb +11 -0
  14. data/spec/buildr-gemjar_spec.rb +179 -0
  15. data/spec/repo_builder.rb +59 -0
  16. data/spec/spec_helper.rb +44 -0
  17. data/vendor/buildr/.gitignore +17 -0
  18. data/vendor/buildr/CHANGELOG +1283 -0
  19. data/vendor/buildr/Gemfile +4 -0
  20. data/vendor/buildr/LICENSE +176 -0
  21. data/vendor/buildr/NOTICE +26 -0
  22. data/vendor/buildr/README.rdoc +134 -0
  23. data/vendor/buildr/Rakefile +44 -0
  24. data/vendor/buildr/_buildr +35 -0
  25. data/vendor/buildr/_jbuildr +35 -0
  26. data/vendor/buildr/addon/buildr/antlr.rb +65 -0
  27. data/vendor/buildr/addon/buildr/bnd.rb +147 -0
  28. data/vendor/buildr/addon/buildr/cobertura.rb +22 -0
  29. data/vendor/buildr/addon/buildr/drb.rb +281 -0
  30. data/vendor/buildr/addon/buildr/emma.rb +22 -0
  31. data/vendor/buildr/addon/buildr/hibernate.rb +149 -0
  32. data/vendor/buildr/addon/buildr/javacc.rb +85 -0
  33. data/vendor/buildr/addon/buildr/jaxb_xjc.rb +72 -0
  34. data/vendor/buildr/addon/buildr/jdepend.rb +60 -0
  35. data/vendor/buildr/addon/buildr/jetty.rb +248 -0
  36. data/vendor/buildr/addon/buildr/jibx.rb +86 -0
  37. data/vendor/buildr/addon/buildr/nailgun.rb +221 -0
  38. data/vendor/buildr/addon/buildr/openjpa.rb +88 -0
  39. data/vendor/buildr/addon/buildr/org/apache/buildr/BuildrNail$Main.class +0 -0
  40. data/vendor/buildr/addon/buildr/org/apache/buildr/BuildrNail.class +0 -0
  41. data/vendor/buildr/addon/buildr/org/apache/buildr/BuildrNail.java +41 -0
  42. data/vendor/buildr/addon/buildr/org/apache/buildr/JettyWrapper$1.class +0 -0
  43. data/vendor/buildr/addon/buildr/org/apache/buildr/JettyWrapper$BuildrHandler.class +0 -0
  44. data/vendor/buildr/addon/buildr/org/apache/buildr/JettyWrapper.class +0 -0
  45. data/vendor/buildr/addon/buildr/org/apache/buildr/JettyWrapper.java +144 -0
  46. data/vendor/buildr/addon/buildr/protobuf.rb +88 -0
  47. data/vendor/buildr/addon/buildr/xmlbeans.rb +93 -0
  48. data/vendor/buildr/all-in-one/_buildr +19 -0
  49. data/vendor/buildr/all-in-one/buildr +368 -0
  50. data/vendor/buildr/all-in-one/buildr.cmd +1 -0
  51. data/vendor/buildr/bin/buildr +19 -0
  52. data/vendor/buildr/buildr.buildfile +58 -0
  53. data/vendor/buildr/buildr.gemspec +74 -0
  54. data/vendor/buildr/doc/_config.yml +1 -0
  55. data/vendor/buildr/doc/_layouts/default.html +90 -0
  56. data/vendor/buildr/doc/_layouts/preface.html +22 -0
  57. data/vendor/buildr/doc/artifacts.textile +217 -0
  58. data/vendor/buildr/doc/building.textile +276 -0
  59. data/vendor/buildr/doc/contributing.textile +268 -0
  60. data/vendor/buildr/doc/css/default.css +236 -0
  61. data/vendor/buildr/doc/css/print.css +101 -0
  62. data/vendor/buildr/doc/css/syntax.css +23 -0
  63. data/vendor/buildr/doc/download.textile +138 -0
  64. data/vendor/buildr/doc/extending.textile +212 -0
  65. data/vendor/buildr/doc/images/1442160941-frontcover.jpg +0 -0
  66. data/vendor/buildr/doc/images/asf-logo.gif +0 -0
  67. data/vendor/buildr/doc/images/asf-logo.png +0 -0
  68. data/vendor/buildr/doc/images/buildr-hires.png +0 -0
  69. data/vendor/buildr/doc/images/buildr.png +0 -0
  70. data/vendor/buildr/doc/images/favicon.png +0 -0
  71. data/vendor/buildr/doc/images/growl-icon.tiff +0 -0
  72. data/vendor/buildr/doc/images/note.png +0 -0
  73. data/vendor/buildr/doc/images/project-structure.png +0 -0
  74. data/vendor/buildr/doc/images/tip.png +0 -0
  75. data/vendor/buildr/doc/images/zbuildr.png +0 -0
  76. data/vendor/buildr/doc/images/zbuildr.tif +0 -0
  77. data/vendor/buildr/doc/index.textile +69 -0
  78. data/vendor/buildr/doc/installing.textile +284 -0
  79. data/vendor/buildr/doc/languages.textile +599 -0
  80. data/vendor/buildr/doc/mailing_lists.textile +29 -0
  81. data/vendor/buildr/doc/more_stuff.textile +845 -0
  82. data/vendor/buildr/doc/packaging.textile +618 -0
  83. data/vendor/buildr/doc/preface.textile +54 -0
  84. data/vendor/buildr/doc/projects.textile +276 -0
  85. data/vendor/buildr/doc/quick_start.textile +210 -0
  86. data/vendor/buildr/doc/releasing.textile +117 -0
  87. data/vendor/buildr/doc/scripts/buildr-git.rb +512 -0
  88. data/vendor/buildr/doc/scripts/gitflow.rb +296 -0
  89. data/vendor/buildr/doc/scripts/install-jruby.sh +44 -0
  90. data/vendor/buildr/doc/scripts/install-linux.sh +73 -0
  91. data/vendor/buildr/doc/scripts/install-osx.sh +52 -0
  92. data/vendor/buildr/doc/settings_profiles.textile +287 -0
  93. data/vendor/buildr/doc/testing.textile +247 -0
  94. data/vendor/buildr/etc/KEYS +189 -0
  95. data/vendor/buildr/lib/buildr.rb +44 -0
  96. data/vendor/buildr/lib/buildr/clojure.rb +34 -0
  97. data/vendor/buildr/lib/buildr/clojure/shell.rb +52 -0
  98. data/vendor/buildr/lib/buildr/core.rb +34 -0
  99. data/vendor/buildr/lib/buildr/core/application.rb +700 -0
  100. data/vendor/buildr/lib/buildr/core/build.rb +516 -0
  101. data/vendor/buildr/lib/buildr/core/cc.rb +166 -0
  102. data/vendor/buildr/lib/buildr/core/checks.rb +253 -0
  103. data/vendor/buildr/lib/buildr/core/common.rb +151 -0
  104. data/vendor/buildr/lib/buildr/core/compile.rb +622 -0
  105. data/vendor/buildr/lib/buildr/core/doc.rb +276 -0
  106. data/vendor/buildr/lib/buildr/core/environment.rb +129 -0
  107. data/vendor/buildr/lib/buildr/core/filter.rb +404 -0
  108. data/vendor/buildr/lib/buildr/core/generate.rb +197 -0
  109. data/vendor/buildr/lib/buildr/core/help.rb +119 -0
  110. data/vendor/buildr/lib/buildr/core/jrebel.rb +42 -0
  111. data/vendor/buildr/lib/buildr/core/linux.rb +30 -0
  112. data/vendor/buildr/lib/buildr/core/osx.rb +46 -0
  113. data/vendor/buildr/lib/buildr/core/progressbar.rb +161 -0
  114. data/vendor/buildr/lib/buildr/core/project.rb +975 -0
  115. data/vendor/buildr/lib/buildr/core/run.rb +43 -0
  116. data/vendor/buildr/lib/buildr/core/shell.rb +137 -0
  117. data/vendor/buildr/lib/buildr/core/test.rb +843 -0
  118. data/vendor/buildr/lib/buildr/core/transports.rb +565 -0
  119. data/vendor/buildr/lib/buildr/core/util.rb +537 -0
  120. data/vendor/buildr/lib/buildr/groovy.rb +20 -0
  121. data/vendor/buildr/lib/buildr/groovy/bdd.rb +106 -0
  122. data/vendor/buildr/lib/buildr/groovy/compiler.rb +153 -0
  123. data/vendor/buildr/lib/buildr/groovy/doc.rb +76 -0
  124. data/vendor/buildr/lib/buildr/groovy/shell.rb +57 -0
  125. data/vendor/buildr/lib/buildr/ide.rb +19 -0
  126. data/vendor/buildr/lib/buildr/ide/eclipse.rb +427 -0
  127. data/vendor/buildr/lib/buildr/ide/eclipse/java.rb +53 -0
  128. data/vendor/buildr/lib/buildr/ide/eclipse/plugin.rb +71 -0
  129. data/vendor/buildr/lib/buildr/ide/eclipse/scala.rb +68 -0
  130. data/vendor/buildr/lib/buildr/ide/idea.rb +576 -0
  131. data/vendor/buildr/lib/buildr/java.rb +25 -0
  132. data/vendor/buildr/lib/buildr/java/ant.rb +94 -0
  133. data/vendor/buildr/lib/buildr/java/bdd.rb +460 -0
  134. data/vendor/buildr/lib/buildr/java/cobertura.rb +297 -0
  135. data/vendor/buildr/lib/buildr/java/commands.rb +223 -0
  136. data/vendor/buildr/lib/buildr/java/compiler.rb +135 -0
  137. data/vendor/buildr/lib/buildr/java/deprecated.rb +141 -0
  138. data/vendor/buildr/lib/buildr/java/doc.rb +86 -0
  139. data/vendor/buildr/lib/buildr/java/ecj.rb +69 -0
  140. data/vendor/buildr/lib/buildr/java/emma.rb +244 -0
  141. data/vendor/buildr/lib/buildr/java/external.rb +73 -0
  142. data/vendor/buildr/lib/buildr/java/jruby.rb +122 -0
  143. data/vendor/buildr/lib/buildr/java/jtestr_result.rb +295 -0
  144. data/vendor/buildr/lib/buildr/java/jtestr_runner.rb.erb +116 -0
  145. data/vendor/buildr/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
  146. data/vendor/buildr/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +142 -0
  147. data/vendor/buildr/lib/buildr/java/packaging.rb +734 -0
  148. data/vendor/buildr/lib/buildr/java/pom.rb +178 -0
  149. data/vendor/buildr/lib/buildr/java/rjb.rb +154 -0
  150. data/vendor/buildr/lib/buildr/java/test_result.rb +101 -0
  151. data/vendor/buildr/lib/buildr/java/tests.rb +362 -0
  152. data/vendor/buildr/lib/buildr/java/version_requirement.rb +172 -0
  153. data/vendor/buildr/lib/buildr/packaging.rb +25 -0
  154. data/vendor/buildr/lib/buildr/packaging/archive.rb +535 -0
  155. data/vendor/buildr/lib/buildr/packaging/artifact.rb +903 -0
  156. data/vendor/buildr/lib/buildr/packaging/artifact_namespace.rb +984 -0
  157. data/vendor/buildr/lib/buildr/packaging/artifact_search.rb +140 -0
  158. data/vendor/buildr/lib/buildr/packaging/gems.rb +105 -0
  159. data/vendor/buildr/lib/buildr/packaging/package.rb +249 -0
  160. data/vendor/buildr/lib/buildr/packaging/tar.rb +189 -0
  161. data/vendor/buildr/lib/buildr/packaging/version_requirement.rb +192 -0
  162. data/vendor/buildr/lib/buildr/packaging/zip.rb +178 -0
  163. data/vendor/buildr/lib/buildr/packaging/ziptask.rb +356 -0
  164. data/vendor/buildr/lib/buildr/resources/buildr.icns +0 -0
  165. data/vendor/buildr/lib/buildr/resources/completed.png +0 -0
  166. data/vendor/buildr/lib/buildr/resources/failed.png +0 -0
  167. data/vendor/buildr/lib/buildr/resources/icons-license.txt +17 -0
  168. data/vendor/buildr/lib/buildr/run.rb +195 -0
  169. data/vendor/buildr/lib/buildr/scala.rb +26 -0
  170. data/vendor/buildr/lib/buildr/scala/bdd.rb +118 -0
  171. data/vendor/buildr/lib/buildr/scala/compiler.rb +242 -0
  172. data/vendor/buildr/lib/buildr/scala/doc.rb +142 -0
  173. data/vendor/buildr/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.class +0 -0
  174. data/vendor/buildr/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.java +57 -0
  175. data/vendor/buildr/lib/buildr/scala/shell.rb +52 -0
  176. data/vendor/buildr/lib/buildr/scala/tests.rb +171 -0
  177. data/vendor/buildr/lib/buildr/shell.rb +185 -0
  178. data/vendor/buildr/lib/buildr/version.rb +18 -0
  179. data/vendor/buildr/rakelib/all-in-one.rake +113 -0
  180. data/vendor/buildr/rakelib/checks.rake +57 -0
  181. data/vendor/buildr/rakelib/doc.rake +137 -0
  182. data/vendor/buildr/rakelib/metrics.rake +39 -0
  183. data/vendor/buildr/rakelib/package.rake +73 -0
  184. data/vendor/buildr/rakelib/release.rake +161 -0
  185. data/vendor/buildr/rakelib/rspec.rake +101 -0
  186. data/vendor/buildr/rakelib/setup.rake +66 -0
  187. data/vendor/buildr/rakelib/stage.rake +220 -0
  188. data/vendor/buildr/spec/addon/bnd_spec.rb +330 -0
  189. data/vendor/buildr/spec/addon/drb_spec.rb +328 -0
  190. data/vendor/buildr/spec/addon/jaxb_xjc_spec.rb +125 -0
  191. data/vendor/buildr/spec/core/application_spec.rb +631 -0
  192. data/vendor/buildr/spec/core/build_spec.rb +837 -0
  193. data/vendor/buildr/spec/core/cc_spec.rb +224 -0
  194. data/vendor/buildr/spec/core/checks_spec.rb +519 -0
  195. data/vendor/buildr/spec/core/common_spec.rb +725 -0
  196. data/vendor/buildr/spec/core/compile_spec.rb +658 -0
  197. data/vendor/buildr/spec/core/doc_spec.rb +195 -0
  198. data/vendor/buildr/spec/core/extension_spec.rb +201 -0
  199. data/vendor/buildr/spec/core/generate_spec.rb +33 -0
  200. data/vendor/buildr/spec/core/project_spec.rb +772 -0
  201. data/vendor/buildr/spec/core/run_spec.rb +93 -0
  202. data/vendor/buildr/spec/core/shell_spec.rb +146 -0
  203. data/vendor/buildr/spec/core/test_spec.rb +1320 -0
  204. data/vendor/buildr/spec/core/transport_spec.rb +544 -0
  205. data/vendor/buildr/spec/core/util_spec.rb +141 -0
  206. data/vendor/buildr/spec/groovy/bdd_spec.rb +80 -0
  207. data/vendor/buildr/spec/groovy/compiler_spec.rb +251 -0
  208. data/vendor/buildr/spec/groovy/doc_spec.rb +65 -0
  209. data/vendor/buildr/spec/ide/eclipse_spec.rb +739 -0
  210. data/vendor/buildr/spec/ide/idea_spec.rb +1144 -0
  211. data/vendor/buildr/spec/java/ant_spec.rb +37 -0
  212. data/vendor/buildr/spec/java/bdd_spec.rb +374 -0
  213. data/vendor/buildr/spec/java/cobertura_spec.rb +112 -0
  214. data/vendor/buildr/spec/java/commands_spec.rb +93 -0
  215. data/vendor/buildr/spec/java/compiler_spec.rb +252 -0
  216. data/vendor/buildr/spec/java/doc_spec.rb +56 -0
  217. data/vendor/buildr/spec/java/ecj_spec.rb +115 -0
  218. data/vendor/buildr/spec/java/emma_spec.rb +121 -0
  219. data/vendor/buildr/spec/java/external_spec.rb +56 -0
  220. data/vendor/buildr/spec/java/java_spec.rb +132 -0
  221. data/vendor/buildr/spec/java/packaging_spec.rb +1270 -0
  222. data/vendor/buildr/spec/java/run_spec.rb +78 -0
  223. data/vendor/buildr/spec/java/test_coverage_helper.rb +257 -0
  224. data/vendor/buildr/spec/java/tests_spec.rb +497 -0
  225. data/vendor/buildr/spec/packaging/archive_spec.rb +775 -0
  226. data/vendor/buildr/spec/packaging/artifact_namespace_spec.rb +743 -0
  227. data/vendor/buildr/spec/packaging/artifact_spec.rb +1066 -0
  228. data/vendor/buildr/spec/packaging/packaging_helper.rb +63 -0
  229. data/vendor/buildr/spec/packaging/packaging_spec.rb +719 -0
  230. data/vendor/buildr/spec/sandbox.rb +165 -0
  231. data/vendor/buildr/spec/scala/bdd_spec.rb +124 -0
  232. data/vendor/buildr/spec/scala/compiler_spec.rb +289 -0
  233. data/vendor/buildr/spec/scala/doc_spec.rb +88 -0
  234. data/vendor/buildr/spec/scala/scala.rb +38 -0
  235. data/vendor/buildr/spec/scala/tests_spec.rb +283 -0
  236. data/vendor/buildr/spec/spec_helpers.rb +369 -0
  237. data/vendor/buildr/spec/version_requirement_spec.rb +143 -0
  238. data/vendor/buildr/spec/xpath_matchers.rb +121 -0
  239. data/vendor/buildr/tests/BUILDR-320/Buildfile +29 -0
  240. data/vendor/buildr/tests/JavaSystemProperty/Buildfile +18 -0
  241. data/vendor/buildr/tests/JavaSystemProperty/src/test/java/FooTest.java +24 -0
  242. data/vendor/buildr/tests/compile_with_parent/Buildfile +18 -0
  243. data/vendor/buildr/tests/compile_with_parent/child/src/main/java/Foo.java +23 -0
  244. data/vendor/buildr/tests/helloWorld/Buildfile +20 -0
  245. data/vendor/buildr/tests/helloWorld/src/main/java/HelloWorld.java +23 -0
  246. data/vendor/buildr/tests/integration_testing.rb +56 -0
  247. data/vendor/buildr/tests/junit3/Buildfile +9 -0
  248. data/vendor/buildr/tests/junit3/src/main/java/Foo.java +23 -0
  249. data/vendor/buildr/tests/junit3/src/test/java/FooTest.java +28 -0
  250. data/vendor/buildr/tests/package_war_as_jar/Buildfile +15 -0
  251. data/vendor/buildr/tests/package_war_as_jar/src/main/java/Foo.java +19 -0
  252. metadata +524 -0
@@ -0,0 +1,837 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one or more
2
+ # contributor license agreements. See the NOTICE file distributed with this
3
+ # work for additional information regarding copyright ownership. The ASF
4
+ # licenses this file to you under the Apache License, Version 2.0 (the
5
+ # "License"); you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+ # License for the specific language governing permissions and limitations under
14
+ # the License.
15
+
16
+
17
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helpers'))
18
+
19
+ shared_examples_for 'local task' do
20
+ it "should execute task for project in current directory" do
21
+ define 'foobar'
22
+ lambda { @task.invoke }.should run_task("foobar:#{@task.name}")
23
+ end
24
+
25
+ it "should not execute task for projects in other directory" do
26
+ define 'foobar', :base_dir=>'elsewhere'
27
+ lambda { task('build').invoke }.should_not run_task('foobar:build')
28
+ end
29
+ end
30
+
31
+
32
+ describe 'build task' do
33
+ it_should_behave_like 'local task'
34
+ before(:each) { @task = task('build') }
35
+ end
36
+
37
+ describe 'clean task' do
38
+ it_should_behave_like 'local task'
39
+ before(:each) { @task = task('clean') }
40
+ end
41
+
42
+ describe 'package task' do
43
+ it_should_behave_like 'local task'
44
+ before(:each) { @task = task('package') }
45
+
46
+ it 'should execute build task as prerequisite' do
47
+ lambda { @task.invoke }.should run_task('build')
48
+ end
49
+ end
50
+
51
+ describe 'install task' do
52
+ it_should_behave_like 'local task'
53
+ before(:each) { @task = task('install') }
54
+
55
+ it 'should execute package task as prerequisite' do
56
+ lambda { @task.invoke }.should run_task('package')
57
+ end
58
+ end
59
+
60
+ describe 'uninstall task' do
61
+ it_should_behave_like 'local task'
62
+ before(:each) { @task = task('uninstall') }
63
+ end
64
+
65
+ describe 'upload task' do
66
+ it_should_behave_like 'local task'
67
+ before(:each) { @task = task('upload') }
68
+
69
+ it 'should execute package task as prerequisite' do
70
+ lambda { @task.invoke }.should run_task('package')
71
+ end
72
+ end
73
+
74
+
75
+ describe Project, '#build' do
76
+ it 'should return the project\'s build task' do
77
+ define('foo').build.should eql(task('foo:build'))
78
+ end
79
+
80
+ it 'should enhance the project\'s build task' do
81
+ task 'prereq'
82
+ task 'action'
83
+ define 'foo' do
84
+ build 'prereq' do
85
+ task('action').invoke
86
+ end
87
+ end
88
+ lambda { project('foo').build.invoke }.should run_tasks('prereq', 'action')
89
+ end
90
+
91
+ it 'should execute build task for sub-project' do
92
+ define 'foo' do
93
+ define 'bar'
94
+ end
95
+ lambda { task('foo:build').invoke }.should run_task('foo:bar:build')
96
+ end
97
+
98
+ it 'should not execute build task of other projects' do
99
+ define 'foo'
100
+ define 'bar'
101
+ lambda { task('foo:build').invoke }.should_not run_task('bar:build')
102
+ end
103
+ end
104
+
105
+
106
+ describe Project, '#clean' do
107
+ it 'should return the project\'s clean task' do
108
+ define('foo').clean.should eql(task('foo:clean'))
109
+ end
110
+
111
+ it 'should enhance the project\'s clean task' do
112
+ task 'prereq'
113
+ task 'action'
114
+ define 'foo' do
115
+ clean 'prereq' do
116
+ task('action').invoke
117
+ end
118
+ end
119
+ lambda { project('foo').clean.invoke }.should run_tasks('prereq', 'action')
120
+ end
121
+
122
+ it 'should remove target directory' do
123
+ define 'foo' do
124
+ self.layout[:target] = 'targeted'
125
+ end
126
+ mkpath 'targeted'
127
+ lambda { project('foo').clean.invoke }.should change { File.exist?('targeted') }.from(true).to(false)
128
+ end
129
+
130
+ it 'should remove reports directory' do
131
+ define 'foo' do
132
+ self.layout[:reports] = 'reported'
133
+ end
134
+ mkpath 'reported'
135
+ lambda { project('foo').clean.invoke }.should change { File.exist?('reported') }.from(true).to(false)
136
+ end
137
+
138
+ it 'should execute clean task for sub-project' do
139
+ define 'foo' do
140
+ define 'bar'
141
+ end
142
+ lambda { task('foo:clean').invoke }.should run_task('foo:bar:clean')
143
+ end
144
+
145
+ it 'should not execute clean task of other projects' do
146
+ define 'foo'
147
+ define 'bar'
148
+ lambda { task('foo:clean').invoke }.should_not run_task('bar:clean')
149
+ end
150
+ end
151
+
152
+
153
+ describe Project, '#target' do
154
+ before :each do
155
+ @project = define('foo', :layout=>Layout.new)
156
+ end
157
+
158
+ it 'should default to target' do
159
+ @project.target.should eql('target')
160
+ end
161
+
162
+ it 'should set layout :target' do
163
+ @project.target = 'bar'
164
+ @project.layout.expand(:target).should point_to_path('bar')
165
+ end
166
+
167
+ it 'should come from layout :target' do
168
+ @project.layout[:target] = 'baz'
169
+ @project.target.should eql('baz')
170
+ end
171
+
172
+ it 'should be removed in version 1.5 since it was deprecated in version 1.3' do
173
+ Buildr::VERSION.should < '1.5'
174
+ end
175
+ end
176
+
177
+
178
+ describe Project, '#reports' do
179
+ before :each do
180
+ @project = define('foo', :layout=>Layout.new)
181
+ end
182
+
183
+ it 'should default to reports' do
184
+ @project.reports.should eql('reports')
185
+ end
186
+
187
+ it 'should set layout :reports' do
188
+ @project.reports = 'bar'
189
+ @project.layout.expand(:reports).should point_to_path('bar')
190
+ end
191
+
192
+ it 'should come from layout :reports' do
193
+ @project.layout[:reports] = 'baz'
194
+ @project.reports.should eql('baz')
195
+ end
196
+
197
+ it 'should be removed in version 1.5 since it was deprecated in version 1.3' do
198
+ Buildr::VERSION.should < '1.5'
199
+ end
200
+ end
201
+
202
+
203
+ describe Git do
204
+ describe '#uncommitted_files' do
205
+ it 'should return an empty array on a clean repository' do
206
+ Git.should_receive(:`).with('git status').and_return <<-EOF
207
+ # On branch master
208
+ nothing to commit (working directory clean)
209
+ EOF
210
+ Git.uncommitted_files.should be_empty
211
+ end
212
+
213
+ it 'should reject a dirty repository, Git 1.4.2 or former' do
214
+ Git.should_receive(:`).with('git status').and_return <<-EOF
215
+ # On branch master
216
+ #
217
+ # Changed but not updated:
218
+ # (use "git add <file>..." to update what will be committed)
219
+ # (use "git checkout -- <file>..." to discard changes in working directory)
220
+ #
221
+ # modified: lib/buildr.rb
222
+ # modified: spec/buildr_spec.rb
223
+ #
224
+ # Untracked files:
225
+ # (use "git add <file>..." to include in what will be committed)
226
+ #
227
+ # error.log
228
+ EOF
229
+ Git.uncommitted_files.should include('lib/buildr.rb', 'error.log')
230
+ end
231
+
232
+ it 'should reject a dirty repository, Git 1.4.3 or higher' do
233
+ Git.should_receive(:`).with('git status').and_return <<-EOF
234
+ # On branch master
235
+ # Changed but not updated:
236
+ # (use "git add <file>..." to update what will be committed)
237
+ #
238
+ #\tmodified: lib/buildr.rb
239
+ #\tmodified: spec/buildr_spec.rb
240
+ #
241
+ # Untracked files:
242
+ # (use "git add <file>..." to include in what will be committed)
243
+ #
244
+ #\terror.log
245
+ no changes added to commit (use "git add" and/or "git commit -a")
246
+ EOF
247
+ Git.uncommitted_files.should include('lib/buildr.rb', 'error.log')
248
+ end
249
+ end
250
+
251
+ describe '#remote' do
252
+ it 'should return the name of the corresponding remote' do
253
+ Git.should_receive(:git).with('config', '--get', 'branch.master.remote').and_return "origin\n"
254
+ Git.should_receive(:git).with('remote').and_return "upstream\norigin\n"
255
+ Git.send(:remote, 'master').should == 'origin'
256
+ end
257
+
258
+ it 'should return nil if no remote for the given branch' do
259
+ Git.should_receive(:git).with('config', '--get', 'branch.master.remote').and_return "\n"
260
+ Git.should_not_receive(:git).with('remote')
261
+ Git.send(:remote, 'master').should be_nil
262
+ end
263
+ end
264
+
265
+ describe '#current_branch' do
266
+ it 'should return the current branch' do
267
+ Git.should_receive(:git).with('branch').and_return(" master\n* a-clever-idea\n ze-great-idea")
268
+ Git.send(:current_branch).should == 'a-clever-idea'
269
+ end
270
+ end
271
+
272
+ end # of Git
273
+
274
+
275
+ describe Svn do
276
+ describe '#tag' do
277
+ it 'should remove any existing tag with the same name' do
278
+ Svn.stub!(:repo_url).and_return('http://my.repo.org/foo/trunk')
279
+ Svn.stub!(:copy)
280
+ Svn.should_receive(:remove).with('http://my.repo.org/foo/tags/1.0.0', 'Removing old copy')
281
+
282
+ Svn.tag '1.0.0'
283
+ end
284
+
285
+ it 'should do an svn copy with the release version' do
286
+ Svn.stub!(:repo_url).and_return('http://my.repo.org/foo/trunk')
287
+ Svn.stub!(:remove)
288
+ Svn.should_receive(:copy).with(Dir.pwd, 'http://my.repo.org/foo/tags/1.0.0', 'Release 1.0.0')
289
+
290
+ Svn.tag '1.0.0'
291
+ end
292
+ end
293
+
294
+ # Reference: http://svnbook.red-bean.com/en/1.4/svn.reposadmin.planning.html#svn.reposadmin.projects.chooselayout
295
+ describe '#tag_url' do
296
+ it 'should accept to tag foo/trunk' do
297
+ Svn.tag_url('http://my.repo.org/foo/trunk', '1.0.0').should == 'http://my.repo.org/foo/tags/1.0.0'
298
+ end
299
+
300
+ it 'should accept to tag foo/branches/1.0' do
301
+ Svn.tag_url('http://my.repo.org/foo/branches/1.0', '1.0.1').should == 'http://my.repo.org/foo/tags/1.0.1'
302
+ end
303
+
304
+ it 'should accept to tag trunk/foo' do
305
+ Svn.tag_url('http://my.repo.org/trunk/foo', '1.0.0').should == 'http://my.repo.org/tags/foo/1.0.0'
306
+ end
307
+
308
+ it 'should accept to tag branches/foo/1.0' do
309
+ Svn.tag_url('http://my.repo.org/branches/foo/1.0', '1.0.0').should == 'http://my.repo.org/tags/foo/1.0.0'
310
+ end
311
+
312
+ describe '#repo_url' do
313
+ it 'should extract the SVN URL from svn info' do
314
+ Svn.should_receive(:svn).and_return <<-XML
315
+ <?xml version="1.0"?>
316
+ <info>
317
+ <entry
318
+ kind="dir"
319
+ path="."
320
+ revision="724987">
321
+ <url>http://my.repo.org/foo/trunk</url>
322
+ <repository>
323
+ <root>http://my.repo.org</root>
324
+ <uuid>13f79535-47bb-0310-9956-ffa450edef68</uuid>
325
+ </repository>
326
+ <wc-info>
327
+ <schedule>normal</schedule>
328
+ <depth>infinity</depth>
329
+ </wc-info>
330
+ <commit
331
+ revision="724955">
332
+ <author>boisvert</author>
333
+ <date>2008-12-10T01:53:51.240936Z</date>
334
+ </commit>
335
+ </entry>
336
+ </info>
337
+ XML
338
+ Svn.repo_url.should == 'http://my.repo.org/foo/trunk'
339
+ end
340
+ end
341
+
342
+ end
343
+
344
+ end # of Buildr::Svn
345
+
346
+
347
+ describe Release do
348
+ describe 'find' do
349
+ it 'should return GitRelease if project uses Git' do
350
+ write '.git/config'
351
+ Release.find.should be_instance_of(GitRelease)
352
+ end
353
+
354
+ it 'should return SvnRelease if project uses SVN' do
355
+ write '.svn/xml'
356
+ Release.find.should be_instance_of(SvnRelease)
357
+ end
358
+
359
+ it 'should return nil if no known release process' do
360
+ Dir.chdir(Dir.tmpdir) do
361
+ Release.find.should be_nil
362
+ end
363
+ end
364
+
365
+ after :each do
366
+ Release.instance_exec { @release = nil }
367
+ end
368
+ end
369
+ end
370
+
371
+
372
+ shared_examples_for 'a release process' do
373
+
374
+ describe '#make' do
375
+ before do
376
+ write 'buildfile', "VERSION_NUMBER = '1.0.0-SNAPSHOT'"
377
+ # Prevent a real call to a spawned buildr process.
378
+ @release.stub!(:buildr)
379
+ @release.stub!(:check)
380
+ @release.should_receive(:ruby).with('-S', 'buildr', "_#{Buildr::VERSION}_", '--buildfile', File.expand_path('buildfile.next'),
381
+ '--environment', 'development', 'clean', 'upload', 'DEBUG=no')
382
+ end
383
+
384
+ it 'should tag a release with the release version' do
385
+ @release.stub!(:update_version_to_next)
386
+ @release.should_receive(:tag_release).with('1.0.0')
387
+ @release.make
388
+ end
389
+
390
+ it 'should not alter the buildfile before tagging' do
391
+ @release.stub!(:update_version_to_next)
392
+ @release.should_receive(:tag_release).with('1.0.0')
393
+ @release.make
394
+ file('buildfile').should contain('VERSION_NUMBER = "1.0.0"')
395
+ end
396
+
397
+ it 'should update the buildfile with the next version number' do
398
+ @release.stub!(:tag_release)
399
+ @release.make
400
+ file('buildfile').should contain('VERSION_NUMBER = "1.0.1-SNAPSHOT"')
401
+ end
402
+
403
+ it 'should keep leading zeros in the next version number' do
404
+ write 'buildfile', "VERSION_NUMBER = '1.0.001-SNAPSHOT'"
405
+ @release.stub!(:tag_release)
406
+ @release.make
407
+ file('buildfile').should contain('VERSION_NUMBER = "1.0.002-SNAPSHOT"')
408
+ end
409
+
410
+ it 'should commit the updated buildfile' do
411
+ @release.stub!(:tag_release)
412
+ @release.make
413
+ file('buildfile').should contain('VERSION_NUMBER = "1.0.1-SNAPSHOT"')
414
+ end
415
+
416
+ it 'should not consider "-rc" as "-SNAPSHOT"' do
417
+ write 'buildfile', "VERSION_NUMBER = '1.0.0-rc1'"
418
+ @release.stub!(:tag_release)
419
+ @release.make
420
+ file('buildfile').should contain('VERSION_NUMBER = "1.0.0-rc1"')
421
+ end
422
+
423
+ it 'should only commit the updated buildfile if the version changed' do
424
+ write 'buildfile', "VERSION_NUMBER = '1.0.0-rc1'"
425
+ @release.should_not_receive(:update_version_to_next)
426
+ @release.stub!(:tag_release)
427
+ @release.make
428
+ end
429
+ end
430
+
431
+ describe '#resolve_next_version' do
432
+
433
+ it 'should increment the version number if SNAPSHOT' do
434
+ @release.send(:resolve_next_version, "1.0.0-SNAPSHOT").should == '1.0.1-SNAPSHOT'
435
+ end
436
+
437
+ it 'should NOT increment the version number if no SNAPSHOT' do
438
+ @release.send(:resolve_next_version, "1.0.0").should == '1.0.0'
439
+ end
440
+
441
+ it 'should return the version specified by NEXT_VERSION env var' do
442
+ ENV['NEXT_VERSION'] = "version_from_env"
443
+ @release.send(:resolve_next_version, "1.0.0").should == 'version_from_env'
444
+ end
445
+
446
+ it 'should return the version specified by next_version' do
447
+ Release.next_version = "ze_next_version"
448
+ @release.send(:resolve_next_version, "1.0.0").should == 'ze_next_version'
449
+ end
450
+
451
+ it 'should return the version specified by next_version if next_version is a proc' do
452
+ Release.next_version = lambda {|version| "#{version}++"}
453
+ @release.send(:resolve_next_version, "1.0.0").should == '1.0.0++'
454
+ end
455
+
456
+ it "should return the version specified by 'NEXT_VERSION' env var even if next_version is non nil" do
457
+ ENV['NEXT_VERSION'] = "ze_version_from_env"
458
+ Release.next_version = lambda {|version| "#{version}++"}
459
+ @release.send(:resolve_next_version, "1.0.0").should == 'ze_version_from_env'
460
+ end
461
+
462
+ it "should return the version specified by 'next_version' env var even if next_version is non nil" do
463
+ ENV['NEXT_VERSION'] = nil
464
+ ENV['next_version'] = "ze_version_from_env_lowercase"
465
+ Release.next_version = lambda {|version| "#{version}++"}
466
+ @release.send(:resolve_next_version, "1.0.0").should == 'ze_version_from_env_lowercase'
467
+ end
468
+ after {
469
+ Release.next_version = nil
470
+ ENV['NEXT_VERSION'] = nil
471
+ ENV['next_version'] = nil
472
+ }
473
+ end
474
+
475
+ describe '#resolve_next_version' do
476
+
477
+ it 'should increment the version number if SNAPSHOT' do
478
+ @release.send(:resolve_next_version, "1.0.0-SNAPSHOT").should == '1.0.1-SNAPSHOT'
479
+ end
480
+
481
+ it 'should NOT increment the version number if no SNAPSHOT' do
482
+ @release.send(:resolve_next_version, "1.0.0").should == '1.0.0'
483
+ end
484
+
485
+ it 'should return the version specified by NEXT_VERSION env var' do
486
+ ENV['NEXT_VERSION'] = "version_from_env"
487
+ @release.send(:resolve_next_version, "1.0.0").should == 'version_from_env'
488
+ end
489
+
490
+ it 'should return the version specified by next_version' do
491
+ Release.next_version = "ze_next_version"
492
+ @release.send(:resolve_next_version, "1.0.0").should == 'ze_next_version'
493
+ end
494
+
495
+ it 'should return the version specified by next_version if next_version is a proc' do
496
+ Release.next_version = lambda {|version| "#{version}++"}
497
+ @release.send(:resolve_next_version, "1.0.0").should == '1.0.0++'
498
+ end
499
+
500
+ it "should return the version specified by 'NEXT_VERSION' env var even if next_version is non nil" do
501
+ ENV['NEXT_VERSION'] = "ze_version_from_env"
502
+ Release.next_version = lambda {|version| "#{version}++"}
503
+ @release.send(:resolve_next_version, "1.0.0").should == 'ze_version_from_env'
504
+ end
505
+
506
+ it "should return the version specified by 'next_version' env var even if next_version is non nil" do
507
+ ENV['NEXT_VERSION'] = nil
508
+ ENV['next_version'] = "ze_version_from_env_lowercase"
509
+ Release.next_version = lambda {|version| "#{version}++"}
510
+ @release.send(:resolve_next_version, "1.0.0").should == 'ze_version_from_env_lowercase'
511
+ end
512
+ after {
513
+ Release.next_version = nil
514
+ ENV['NEXT_VERSION'] = nil
515
+ ENV['next_version'] = nil
516
+ }
517
+ end
518
+
519
+ describe '#resolve_next_version' do
520
+
521
+ it 'should increment the version number if SNAPSHOT' do
522
+ @release.send(:resolve_next_version, "1.0.0-SNAPSHOT").should == '1.0.1-SNAPSHOT'
523
+ end
524
+
525
+ it 'should NOT increment the version number if no SNAPSHOT' do
526
+ @release.send(:resolve_next_version, "1.0.0").should == '1.0.0'
527
+ end
528
+
529
+ it 'should return the version specified by NEXT_VERSION env var' do
530
+ ENV['NEXT_VERSION'] = "version_from_env"
531
+ @release.send(:resolve_next_version, "1.0.0").should == 'version_from_env'
532
+ end
533
+
534
+ it 'should return the version specified by next_version' do
535
+ Release.next_version = "ze_next_version"
536
+ @release.send(:resolve_next_version, "1.0.0").should == 'ze_next_version'
537
+ end
538
+
539
+ it 'should return the version specified by next_version if next_version is a proc' do
540
+ Release.next_version = lambda {|version| "#{version}++"}
541
+ @release.send(:resolve_next_version, "1.0.0").should == '1.0.0++'
542
+ end
543
+
544
+ it "should return the version specified by 'NEXT_VERSION' env var even if next_version is non nil" do
545
+ ENV['NEXT_VERSION'] = "ze_version_from_env"
546
+ Release.next_version = lambda {|version| "#{version}++"}
547
+ @release.send(:resolve_next_version, "1.0.0").should == 'ze_version_from_env'
548
+ end
549
+
550
+ it "should return the version specified by 'next_version' env var even if next_version is non nil" do
551
+ ENV['NEXT_VERSION'] = nil
552
+ ENV['next_version'] = "ze_version_from_env_lowercase"
553
+ Release.next_version = lambda {|version| "#{version}++"}
554
+ @release.send(:resolve_next_version, "1.0.0").should == 'ze_version_from_env_lowercase'
555
+ end
556
+ after {
557
+ Release.next_version = nil
558
+ ENV['NEXT_VERSION'] = nil
559
+ ENV['next_version'] = nil
560
+ }
561
+ end
562
+
563
+ describe '#resolve_tag' do
564
+ before do
565
+ @release.stub!(:extract_version).and_return('1.0.0')
566
+ end
567
+
568
+ it 'should return tag specified by tag_name' do
569
+ Release.tag_name = 'first'
570
+ @release.send(:resolve_tag).should == 'first'
571
+ end
572
+
573
+ it 'should use tag returned by tag_name if tag_name is a proc' do
574
+ Release.tag_name = lambda { |version| "buildr-#{version}" }
575
+ @release.send(:resolve_tag).should == 'buildr-1.0.0'
576
+ end
577
+ after { Release.tag_name = nil }
578
+ end
579
+
580
+ describe '#tag_release' do
581
+ it 'should inform the user' do
582
+ @release.stub!(:extract_version).and_return('1.0.0')
583
+ lambda { @release.tag_release('1.0.0') }.should show_info('Tagging release 1.0.0')
584
+ end
585
+ end
586
+
587
+ describe '#extract_version' do
588
+ it 'should extract VERSION_NUMBER with single quotes' do
589
+ write 'buildfile', "VERSION_NUMBER = '1.0.0-SNAPSHOT'"
590
+ @release.extract_version.should == '1.0.0-SNAPSHOT'
591
+ end
592
+
593
+ it 'should extract VERSION_NUMBER with double quotes' do
594
+ write 'buildfile', %{VERSION_NUMBER = "1.0.1-SNAPSHOT"}
595
+ @release.extract_version.should == '1.0.1-SNAPSHOT'
596
+ end
597
+
598
+ it 'should extract VERSION_NUMBER without any spaces' do
599
+ write 'buildfile', "VERSION_NUMBER='1.0.2-SNAPSHOT'"
600
+ @release.extract_version.should == '1.0.2-SNAPSHOT'
601
+ end
602
+
603
+ it 'should extract THIS_VERSION as an alternative to VERSION_NUMBER' do
604
+ write 'buildfile', "THIS_VERSION = '1.0.3-SNAPSHOT'"
605
+ @release.extract_version.should == '1.0.3-SNAPSHOT'
606
+ end
607
+
608
+ it 'should complain if no current version number' do
609
+ write 'buildfile', 'define foo'
610
+ lambda { @release.extract_version }.should raise_error('Looking for THIS_VERSION = "..." in your Buildfile, none found')
611
+ end
612
+ end
613
+
614
+ describe '#with_release_candidate_version' do
615
+ before do
616
+ Buildr.application.stub!(:buildfile).and_return(file('buildfile'))
617
+ write 'buildfile', "THIS_VERSION = '1.1.0-SNAPSHOT'"
618
+ end
619
+
620
+ it 'should yield the name of the release candidate buildfile' do
621
+ @release.send :with_release_candidate_version do |new_filename|
622
+ File.read(new_filename).should == %{THIS_VERSION = "1.1.0"}
623
+ end
624
+ end
625
+
626
+ it 'should yield a name different from the original buildfile' do
627
+ @release.send :with_release_candidate_version do |new_filename|
628
+ new_filename.should_not point_to_path('buildfile')
629
+ end
630
+ end
631
+ end
632
+
633
+ describe '#update_version_to_next' do
634
+ before do
635
+ write 'buildfile', "VERSION_NUMBER = '1.0.5-SNAPSHOT'"
636
+ @release.send(:this_version=, "1.0.5-SNAPSHOT")
637
+ end
638
+
639
+ it 'should update the buildfile with a new version number' do
640
+ @release.send :update_version_to_next
641
+ `cp buildfile /tmp/out`
642
+ file('buildfile').should contain('VERSION_NUMBER = "1.0.6-SNAPSHOT"')
643
+ end
644
+
645
+ it 'should commit the new buildfile on the trunk' do
646
+ @release.should_receive(:message).and_return('Changed version number to 1.0.1-SNAPSHOT')
647
+ @release.update_version_to_next
648
+ end
649
+
650
+ it 'should use the commit message specified by commit_message' do
651
+ Release.commit_message = 'Here is my custom message'
652
+ @release.should_receive(:message).and_return('Here is my custom message')
653
+ @release.update_version_to_next
654
+ end
655
+
656
+ it 'should use the commit message returned by commit_message if commit_message is a proc' do
657
+ Release.commit_message = lambda { |new_version|
658
+ new_version.should == '1.0.1-SNAPSHOT'
659
+ "increment version number to #{new_version}"
660
+ }
661
+ @release.should_receive(:message).and_return('increment version number to 1.0.1-SNAPSHOT')
662
+ @release.update_version_to_next
663
+ end
664
+
665
+ it 'should inform the user of the new version' do
666
+ lambda { @release.update_version_to_next }.should show_info('Current version is now 1.0.6-SNAPSHOT')
667
+ end
668
+ after { Release.commit_message = nil }
669
+ end
670
+
671
+
672
+ describe '#check' do
673
+ before { @release.send(:this_version=, "1.0.0-SNAPSHOT") }
674
+ it 'should fail if THIS_VERSION equals the next_version' do
675
+ @release.stub!(:resolve_next_version).and_return('1.0.0-SNAPSHOT')
676
+ lambda { @release.check }.should raise_error("The next version can't be equal to the current version 1.0.0-SNAPSHOT.\nUpdate THIS_VERSION/VERSION_NUMBER, specify Release.next_version or use NEXT_VERSION env var")
677
+ end
678
+ end
679
+ end
680
+
681
+
682
+ describe GitRelease do
683
+ it_should_behave_like 'a release process'
684
+
685
+ before do
686
+ write 'buildfile', "VERSION_NUMBER = '1.0.0-SNAPSHOT'"
687
+ @release = GitRelease.new
688
+ Git.stub!(:git)
689
+ Git.stub!(:current_branch).and_return('master')
690
+ end
691
+
692
+ describe '#applies_to?' do
693
+ it 'should reject a non-git repo' do
694
+ Dir.chdir(Dir.tmpdir) do
695
+ GitRelease.applies_to?.should be_false
696
+ end
697
+ end
698
+
699
+ it 'should accept a git repo' do
700
+ FileUtils.mkdir '.git'
701
+ FileUtils.touch File.join('.git', 'config')
702
+ GitRelease.applies_to?.should be_true
703
+ end
704
+ end
705
+
706
+ describe '#check' do
707
+ before do
708
+ @release = GitRelease.new
709
+ @release.send(:this_version=, '1.0.0-SNAPSHOT')
710
+ end
711
+
712
+ it 'should accept a clean repository' do
713
+ Git.should_receive(:`).with('git status').and_return <<-EOF
714
+ # On branch master
715
+ nothing to commit (working directory clean)
716
+ EOF
717
+ Git.should_receive(:remote).and_return('master')
718
+ lambda { @release.check }.should_not raise_error
719
+ end
720
+
721
+ it 'should reject a dirty repository' do
722
+ Git.should_receive(:`).with('git status').and_return <<-EOF
723
+ # On branch master
724
+ # Untracked files:
725
+ # (use "git add <file>..." to include in what will be committed)
726
+ #
727
+ # foo.temp
728
+ EOF
729
+ lambda { @release.check }.should raise_error(RuntimeError, /uncommitted files/i)
730
+ end
731
+
732
+ it 'should reject a repository not tracking remote branch' do
733
+ Git.should_receive(:uncommitted_files).and_return([])
734
+ Git.should_receive(:remote).and_return(nil)
735
+ lambda{ @release.check }.should raise_error(RuntimeError,
736
+ "You are releasing from a local branch that does not track a remote!")
737
+ end
738
+ end
739
+
740
+ describe '#tag_release' do
741
+ before do
742
+ @release = GitRelease.new
743
+ @release.stub!(:extract_version).and_return('1.0.1')
744
+ @release.stub!(:resolve_tag).and_return('TEST_TAG')
745
+ Git.stub!(:git).with('tag', '-a', 'TEST_TAG', '-m', '[buildr] Cutting release TEST_TAG')
746
+ Git.stub!(:git).with('push', 'origin', 'tag', 'TEST_TAG')
747
+ Git.stub!(:commit)
748
+ Git.stub!(:push)
749
+ Git.stub!(:remote).and_return('origin')
750
+ end
751
+
752
+ it 'should delete any existing tag with the same name' do
753
+ Git.should_receive(:git).with('tag', '-d', 'TEST_TAG')
754
+ Git.should_receive(:git).with('push', 'origin', ':refs/tags/TEST_TAG')
755
+ @release.tag_release 'TEST_TAG'
756
+ end
757
+
758
+ it 'should commit the buildfile before tagging' do
759
+ Git.should_receive(:commit).with(File.basename(Buildr.application.buildfile.to_s), "Changed version number to 1.0.1")
760
+ @release.tag_release 'TEST_TAG'
761
+ end
762
+
763
+ it 'should push the tag if a remote is tracked' do
764
+ Git.should_receive(:git).with('tag', '-d', 'TEST_TAG')
765
+ Git.should_receive(:git).with('push', 'origin', ':refs/tags/TEST_TAG')
766
+ Git.should_receive(:git).with('tag', '-a', 'TEST_TAG', '-m', '[buildr] Cutting release TEST_TAG')
767
+ Git.should_receive(:git).with('push', 'origin', 'tag', 'TEST_TAG')
768
+ @release.tag_release 'TEST_TAG'
769
+ end
770
+
771
+ it 'should NOT push the tag if no remote is tracked' do
772
+ Git.stub!(:remote).and_return(nil)
773
+ Git.should_not_receive(:git).with('push', 'origin', 'tag', 'TEST_TAG')
774
+ @release.tag_release 'TEST_TAG'
775
+ end
776
+ end
777
+ end
778
+
779
+
780
+ describe SvnRelease do
781
+ it_should_behave_like 'a release process'
782
+
783
+ before do
784
+ write 'buildfile', "VERSION_NUMBER = '1.0.0-SNAPSHOT'"
785
+ @release = SvnRelease.new
786
+ Svn.stub!(:svn)
787
+ Svn.stub!(:repo_url).and_return('http://my.repo.org/foo/trunk')
788
+ Svn.stub!(:tag)
789
+ end
790
+
791
+ describe '#applies_to?' do
792
+ it 'should reject a non-git repo' do
793
+ SvnRelease.applies_to?.should be_false
794
+ end
795
+
796
+ it 'should accept a git repo' do
797
+ FileUtils.touch '.svn'
798
+ SvnRelease.applies_to?.should be_true
799
+ end
800
+ end
801
+
802
+ describe '#check' do
803
+ before do
804
+ Svn.stub!(:uncommitted_files).and_return([])
805
+ @release = SvnRelease.new
806
+ @release.send(:this_version=, "1.0.0-SNAPSHOT")
807
+ end
808
+
809
+ it 'should accept to release from the trunk' do
810
+ Svn.stub!(:repo_url).and_return('http://my.repo.org/foo/trunk')
811
+ lambda { @release.check }.should_not raise_error
812
+ end
813
+
814
+ it 'should accept to release from a branch' do
815
+ Svn.stub!(:repo_url).and_return('http://my.repo.org/foo/branches/1.0')
816
+ lambda { @release.check }.should_not raise_error
817
+ end
818
+
819
+ it 'should reject releasing from a tag' do
820
+ Svn.stub!(:repo_url).and_return('http://my.repo.org/foo/tags/1.0.0')
821
+ lambda { @release.check }.should raise_error(RuntimeError, "SVN URL must contain 'trunk' or 'branches/...'")
822
+ end
823
+
824
+ it 'should reject a non standard repository layout' do
825
+ Svn.stub!(:repo_url).and_return('http://my.repo.org/foo/bar')
826
+ lambda { @release.check }.should raise_error(RuntimeError, "SVN URL must contain 'trunk' or 'branches/...'")
827
+ end
828
+
829
+ it 'should reject an uncommitted file' do
830
+ Svn.stub!(:repo_url).and_return('http://my.repo.org/foo/trunk')
831
+ Svn.stub!(:uncommitted_files).and_return(['foo.rb'])
832
+ lambda { @release.check }.should raise_error(RuntimeError,
833
+ "Uncommitted files violate the First Principle Of Release!\n" +
834
+ "foo.rb")
835
+ end
836
+ end
837
+ end