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,631 @@
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
+
20
+ describe Buildr::Application do
21
+
22
+ describe 'home_dir' do
23
+ it 'should point to ~/.buildr' do
24
+ Buildr.application.home_dir.should eql(File.expand_path('.buildr', ENV['HOME']))
25
+ end
26
+
27
+ it 'should point to existing directory' do
28
+ File.directory?(Buildr.application.home_dir).should be_true
29
+ end
30
+ end
31
+
32
+ describe '#run' do
33
+ it 'should execute *_load methods in order' do
34
+ order = [:load_gems, :load_artifact_ns, :load_tasks, :raw_load_buildfile]
35
+ order.each { |method| Buildr.application.should_receive(method).ordered }
36
+ Buildr.application.stub!(:exit) # With this, shows the correct error instead of SystemExit.
37
+ Buildr.application.run
38
+ end
39
+
40
+ it 'should load imports after loading buildfile' do
41
+ method = Buildr.application.method(:raw_load_buildfile)
42
+ Buildr.application.should_receive(:raw_load_buildfile) do
43
+ Buildr.application.should_receive(:load_imports)
44
+ method.call
45
+ end
46
+ Buildr.application.stub!(:exit) # With this, shows the correct error instead of SystemExit.
47
+ Buildr.application.run
48
+ end
49
+
50
+ it 'should evaluate all projects after loading buildfile' do
51
+ Buildr.application.should_receive(:load_imports) do
52
+ Buildr.should_receive(:projects)
53
+ end
54
+ Buildr.application.stub!(:exit) # With this, shows the correct error instead of SystemExit.
55
+ Buildr.application.run
56
+ end
57
+ end
58
+
59
+ describe 'environment' do
60
+ it 'should return value of BUILDR_ENV' do
61
+ ENV['BUILDR_ENV'] = 'qa'
62
+ Buildr.application.environment.should eql('qa')
63
+ end
64
+
65
+ it 'should default to development' do
66
+ Buildr.application.environment.should eql('development')
67
+ end
68
+
69
+ it 'should set environment name from -e argument' do
70
+ ARGV.push('-e', 'test')
71
+ Buildr.application.send(:handle_options)
72
+ Buildr.application.environment.should eql('test')
73
+ ENV['BUILDR_ENV'].should eql('test')
74
+ end
75
+
76
+ it 'should be echoed to user' do
77
+ write 'buildfile'
78
+ ENV['BUILDR_ENV'] = 'spec'
79
+ Buildr.application.send(:handle_options)
80
+ lambda { Buildr.application.send :load_buildfile }.should show(%r{(in .*, spec)})
81
+ end
82
+ end
83
+
84
+ describe 'options' do
85
+ it "should have 'tasks' as the sole default rakelib" do
86
+ Buildr.application.send(:handle_options)
87
+ Buildr.application.options.rakelib.should == ['tasks']
88
+ end
89
+
90
+ it 'should show the version when prompted with -V' do
91
+ ARGV.push('-V')
92
+ test_exit(0) { Buildr.application.send(:handle_options) }.should show(/Buildr #{Buildr::VERSION}.*/)
93
+ end
94
+
95
+ it 'should show the version when prompted with --version' do
96
+ ARGV.push('--version')
97
+ test_exit(0) { Buildr.application.send(:handle_options) }.should show(/Buildr #{Buildr::VERSION}.*/)
98
+ end
99
+
100
+ it 'should enable tracing with --trace' do
101
+ ARGV.push('--trace')
102
+ Buildr.application.send(:handle_options)
103
+ Buildr.application.options.trace.should == true
104
+ end
105
+
106
+ it 'should enable tracing of [:foo, :bar] categories with --trace=foo,bar' do
107
+ ARGV.push('--trace=foo,bar')
108
+ Buildr.application.send(:handle_options)
109
+ Buildr.application.options.trace.should == true
110
+ Buildr.application.options.trace_categories.should == [:foo, :bar]
111
+ trace?(:foo).should == true
112
+ trace?(:not).should == false
113
+ end
114
+
115
+ it 'should enable tracing for all categories with --trace=all' do
116
+ ARGV.push('--trace=all')
117
+ Buildr.application.send(:handle_options)
118
+ Buildr.application.options.trace.should == true
119
+ Buildr.application.options.trace_all.should == true
120
+ trace?(:foo).should == true
121
+ end
122
+
123
+ end
124
+
125
+ describe 'gems' do
126
+ before do
127
+ class << Buildr.application
128
+ public :load_gems
129
+ end
130
+ end
131
+
132
+ def load_with_yaml
133
+ write 'build.yaml', <<-YAML
134
+ gems:
135
+ - rake
136
+ - rspec ~> 2.1.0
137
+ YAML
138
+ Buildr.application.load_gems
139
+ end
140
+
141
+ it 'should return empty array if no gems specified' do
142
+ Buildr.application.load_gems
143
+ Buildr.application.gems.should be_empty
144
+ end
145
+
146
+ it 'should return one entry for each gem specified in buildr.yaml' do
147
+ load_with_yaml
148
+ Buildr.application.gems.size.should be(2)
149
+ end
150
+
151
+ it 'should return a Gem::Specification for each installed gem' do
152
+ load_with_yaml
153
+ Buildr.application.gems.each { |gem| gem.should be_kind_of(Gem::Specification) }
154
+ end
155
+
156
+ it 'should parse Gem name correctly' do
157
+ load_with_yaml
158
+ Buildr.application.gems.map(&:name).should include('rspec', 'rake')
159
+ end
160
+
161
+ it 'should find installed version of Gem' do
162
+ load_with_yaml
163
+ Buildr.application.gems.each { |gem| gem.version.should eql(Gem.loaded_specs[gem.name].version) }
164
+ end
165
+ end
166
+
167
+ describe 'load_gems' do
168
+ before do
169
+ class << Buildr.application
170
+ public :load_gems
171
+ end
172
+ @spec = Gem::Specification.new do |spec|
173
+ spec.name = 'buildr-foo'
174
+ spec.version = '1.2'
175
+ end
176
+ $stdout.stub!(:isatty).and_return(true)
177
+ end
178
+
179
+ it 'should do nothing if no gems specified' do
180
+ lambda { Buildr.application.load_gems }.should_not raise_error
181
+ end
182
+
183
+ it 'should install nothing if specified gems already installed' do
184
+ Buildr.application.should_receive(:listed_gems).and_return([Gem.loaded_specs['rspec']])
185
+ Util.should_not_receive(:ruby)
186
+ lambda { Buildr.application.load_gems }.should_not raise_error
187
+ end
188
+
189
+ it 'should fail if required gem not found in remote repository' do
190
+ Buildr.application.should_receive(:listed_gems).and_return([Gem::Dependency.new('buildr-foo', '>=1.1')])
191
+ Gem.source_index.should_receive(:search).at_least(:once).and_return([])
192
+ lambda { Buildr.application.load_gems }.should raise_error(LoadError, /cannot be found/i)
193
+ end
194
+
195
+ it 'should fail if need to install gem and not running in interactive mode' do
196
+ Buildr.application.should_receive(:listed_gems).and_return([Gem::Dependency.new('buildr-foo', '>=1.1')])
197
+ Gem.source_index.should_receive(:search).and_return([@spec])
198
+ $stdout.should_receive(:isatty).and_return(false)
199
+ lambda { Buildr.application.load_gems }.should raise_error(LoadError, /this build requires the gems/i)
200
+ end
201
+
202
+ it 'should ask permission before installing required gems' do
203
+ Buildr.application.should_receive(:listed_gems).and_return([Gem::Dependency.new('buildr-foo', '>=1.1')])
204
+ Gem.source_index.should_receive(:search).and_return([@spec])
205
+ $terminal.should_receive(:agree).with(/install/, true)
206
+ lambda { Buildr.application.load_gems }.should raise_error
207
+ end
208
+
209
+ it 'should fail if permission not granted to install gem' do
210
+ Buildr.application.should_receive(:listed_gems).and_return([Gem::Dependency.new('buildr-foo', '>=1.1')])
211
+ Gem.source_index.should_receive(:search).and_return([@spec])
212
+ $terminal.should_receive(:agree).and_return(false)
213
+ lambda { Buildr.application.load_gems }.should raise_error(LoadError, /cannot build without/i)
214
+ end
215
+
216
+ it 'should install gem if permission granted' do
217
+ Buildr.application.should_receive(:listed_gems).and_return([Gem::Dependency.new('buildr-foo', '>=1.1')])
218
+ Gem.source_index.should_receive(:search).and_return([@spec])
219
+ $terminal.should_receive(:agree).and_return(true)
220
+ Util.should_receive(:ruby) do |*args|
221
+ args.should include('install', 'buildr-foo', '-v', '1.2')
222
+ end
223
+ Buildr.application.should_receive(:gem).and_return(false)
224
+ Buildr.application.load_gems
225
+ end
226
+
227
+ it 'should reload gem cache after installing required gems' do
228
+ Buildr.application.should_receive(:listed_gems).and_return([Gem::Dependency.new('buildr-foo', '>=1.1')])
229
+ Gem.source_index.should_receive(:search).and_return([@spec])
230
+ $terminal.should_receive(:agree).and_return(true)
231
+ Util.should_receive(:ruby)
232
+ Gem.source_index.should_receive(:load_gems_in).with(Gem::SourceIndex.installed_spec_directories)
233
+ Buildr.application.should_receive(:gem).and_return(false)
234
+ Buildr.application.load_gems
235
+ end
236
+
237
+ it 'should load previously installed gems' do
238
+ Buildr.application.should_receive(:listed_gems).and_return([Gem.loaded_specs['rspec']])
239
+ Buildr.application.should_receive(:gem).with('rspec', Gem.loaded_specs['rspec'].version.to_s)
240
+ Buildr.application.load_gems
241
+ end
242
+
243
+ it 'should load newly installed gems' do
244
+ Buildr.application.should_receive(:listed_gems).and_return([Gem::Dependency.new('buildr-foo', '>=1.1')])
245
+ Gem.source_index.should_receive(:search).and_return([@spec])
246
+ $terminal.should_receive(:agree).and_return(true)
247
+ Util.should_receive(:ruby)
248
+ Buildr.application.should_receive(:gem).with('buildr-foo', @spec.version.to_s)
249
+ Buildr.application.load_gems
250
+ end
251
+
252
+ it 'should default to >=0 version requirement if not specified' do
253
+ write 'build.yaml', 'gems: buildr-foo'
254
+ should_attempt_to_load_dependency(Gem::Dependency.new('buildr-foo', '>= 0'))
255
+ end
256
+
257
+ it 'should parse exact version requirement' do
258
+ write 'build.yaml', 'gems: buildr-foo 2.5'
259
+ should_attempt_to_load_dependency(Gem::Dependency.new('buildr-foo', '=2.5'))
260
+ end
261
+
262
+ it 'should parse range version requirement' do
263
+ write 'build.yaml', 'gems: buildr-foo ~>2.3'
264
+ should_attempt_to_load_dependency(Gem::Dependency.new('buildr-foo', '~>2.3'))
265
+ end
266
+
267
+ it 'should parse multiple version requirements' do
268
+ write 'build.yaml', 'gems: buildr-foo >=2.0 !=2.1'
269
+ should_attempt_to_load_dependency(Gem::Dependency.new('buildr-foo', ['>=2.0', '!=2.1']))
270
+ end
271
+
272
+ def should_attempt_to_load_dependency(dep)
273
+ Gem.source_index.should_receive(:search).with(dep).and_return([])
274
+ lambda { Buildr.application.load_gems }.should raise_missing_gem_error(dep)
275
+ end
276
+
277
+ def raise_missing_gem_error(dep)
278
+ raise_error(Gem::LoadError, /Build requires the gems #{dep.name} #{dep.requirement}, which cannot be found in local or remote repository./)
279
+ end
280
+ end
281
+
282
+ describe 'load_tasks' do
283
+ before do
284
+ class << Buildr.application
285
+ public :load_tasks
286
+ end
287
+ @original_loaded_features = $LOADED_FEATURES.dup
288
+ Buildr.application.options.rakelib = ["tasks"]
289
+ end
290
+
291
+ after do
292
+ $taskfiles = nil
293
+ ($LOADED_FEATURES - @original_loaded_features).each do |new_load|
294
+ $LOADED_FEATURES.delete(new_load)
295
+ end
296
+ end
297
+
298
+ def write_task(filename)
299
+ write filename, <<-RUBY
300
+ $taskfiles ||= []
301
+ $taskfiles << __FILE__
302
+ RUBY
303
+ end
304
+
305
+ def loaded_tasks
306
+ @loaded ||= Buildr.application.load_tasks
307
+ $taskfiles
308
+ end
309
+
310
+ it "should load {options.rakelib}/foo.rake" do
311
+ write_task 'tasks/foo.rake'
312
+ loaded_tasks.should have(1).task
313
+ loaded_tasks.first.should =~ %r{tasks/foo\.rake$}
314
+ end
315
+
316
+ it 'should load all *.rake files from the rakelib' do
317
+ write_task 'tasks/bar.rake'
318
+ write_task 'tasks/quux.rake'
319
+ loaded_tasks.should have(2).tasks
320
+ end
321
+
322
+ it 'should not load files which do not have the .rake extension' do
323
+ write_task 'tasks/foo.rb'
324
+ write_task 'tasks/bar.rake'
325
+ loaded_tasks.should have(1).task
326
+ loaded_tasks.first.should =~ %r{tasks/bar\.rake$}
327
+ end
328
+
329
+ it 'should load files only from the directory specified in the rakelib option' do
330
+ Buildr.application.options.rakelib = ['extensions']
331
+ write_task 'extensions/amp.rake'
332
+ write_task 'tasks/bar.rake'
333
+ write_task 'extensions/foo.rake'
334
+ loaded_tasks.should have(2).tasks
335
+ %w[amp foo].each do |filename|
336
+ loaded_tasks.select{|x| x =~ %r{extensions/#{filename}\.rake}}.should have(1).entry
337
+ end
338
+ end
339
+
340
+ it 'should load files from all the directories specified in the rakelib option' do
341
+ Buildr.application.options.rakelib = ['ext', 'more', 'tasks']
342
+ write_task 'ext/foo.rake'
343
+ write_task 'tasks/bar.rake'
344
+ write_task 'tasks/zeb.rake'
345
+ write_task 'more/baz.rake'
346
+ loaded_tasks.should have(4).tasks
347
+ end
348
+
349
+ it 'should not load files from the rakelib more than once' do
350
+ write_task 'tasks/new_one.rake'
351
+ write_task 'tasks/already.rake'
352
+ $LOADED_FEATURES << 'tasks/already.rake'
353
+
354
+ loaded_tasks.should have(1).task
355
+ loaded_tasks.first.should =~ %r{tasks/new_one\.rake$}
356
+ end
357
+ end
358
+
359
+ describe 'exception handling' do
360
+
361
+ it 'should exit when given a SystemExit exception' do
362
+ test_exit(3) { Buildr.application.standard_exception_handling { raise SystemExit.new(3) } }
363
+ end
364
+
365
+ it 'should exit with status 1 when given an OptionParser::ParseError exception' do
366
+ test_exit(1) { Buildr.application.standard_exception_handling { raise OptionParser::ParseError.new() } }
367
+ end
368
+
369
+ it 'should exit with status 1 when given any other type of exception exception' do
370
+ test_exit(1) { Buildr.application.standard_exception_handling { raise Exception.new() } }
371
+ end
372
+
373
+ it 'should print the class name and the message when receiving an exception (except when the exception is named Exception)' do
374
+
375
+ # Our fake $stderr for the exercise. We could start it with a matcher instead
376
+ class FakeStdErr
377
+
378
+ attr_accessor :messages
379
+
380
+ def puts(*args)
381
+ @messages ||= []
382
+ @messages += args
383
+ end
384
+
385
+ alias :write :puts
386
+ end
387
+
388
+ # Save the old $stderr and make sure to restore it in the end.
389
+ old_stderr = $stderr
390
+ begin
391
+
392
+ $stderr = FakeStdErr.new
393
+ test_exit(1) {
394
+ Buildr.application.send :standard_exception_handling do
395
+ class MyOwnNicelyNamedException < Exception
396
+ end
397
+ raise MyOwnNicelyNamedException.new('My message')
398
+ end
399
+ }.call
400
+ $stderr.messages.select {|msg| msg =~ /.*MyOwnNicelyNamedException : My message.*/}.size.should == 1
401
+ $stderr.messages.clear
402
+ test_exit(1) {
403
+ Buildr.application.send :standard_exception_handling do
404
+ raise Exception.new('My message')
405
+ end
406
+ }.call
407
+ $stderr.messages.select {|msg| msg =~ /.*My message.*/ && !(msg =~ /Exception/)}.size.should == 1
408
+ end
409
+ $stderr = old_stderr
410
+ end
411
+ end
412
+
413
+ end
414
+
415
+
416
+ describe Buildr, 'settings' do
417
+
418
+ describe 'user' do
419
+
420
+ it 'should be empty hash if no settings.yaml file' do
421
+ Buildr.settings.user.should == {}
422
+ end
423
+
424
+ it 'should return loaded settings.yaml file' do
425
+ write 'home/.buildr/settings.yaml', 'foo: bar'
426
+ Buildr.settings.user.should == { 'foo'=>'bar' }
427
+ end
428
+
429
+ it 'should return loaded settings.yml file' do
430
+ write 'home/.buildr/settings.yml', 'foo: bar'
431
+ Buildr.settings.user.should == { 'foo'=>'bar' }
432
+ end
433
+
434
+ it 'should fail if settings.yaml file is not a hash' do
435
+ write 'home/.buildr/settings.yaml', 'foo bar'
436
+ lambda { Buildr.settings.user }.should raise_error(RuntimeError, /expecting.*settings.yaml/i)
437
+ end
438
+
439
+ it 'should be empty hash if settings.yaml file is empty' do
440
+ write 'home/.buildr/settings.yaml'
441
+ Buildr.settings.user.should == {}
442
+ end
443
+ end
444
+
445
+ describe 'configuration' do
446
+ it 'should be empty hash if no build.yaml file' do
447
+ Buildr.settings.build.should == {}
448
+ end
449
+
450
+ it 'should return loaded build.yaml file' do
451
+ write 'build.yaml', 'foo: bar'
452
+ Buildr.settings.build.should == { 'foo'=>'bar' }
453
+ end
454
+
455
+ it 'should return loaded build.yml file' do
456
+ write 'build.yml', 'foo: bar'
457
+ Buildr.settings.build.should == { 'foo'=>'bar' }
458
+ end
459
+
460
+ it 'should fail if build.yaml file is not a hash' do
461
+ write 'build.yaml', 'foo bar'
462
+ lambda { Buildr.settings.build }.should raise_error(RuntimeError, /expecting.*build.yaml/i)
463
+ end
464
+
465
+ it 'should be empty hash if build.yaml file is empty' do
466
+ write 'build.yaml'
467
+ Buildr.settings.build.should == {}
468
+ end
469
+ end
470
+
471
+ describe 'profiles' do
472
+ it 'should be empty hash if no profiles.yaml file' do
473
+ Buildr.settings.profiles.should == {}
474
+ end
475
+
476
+ it 'should return loaded profiles.yaml file' do
477
+ write 'profiles.yaml', <<-YAML
478
+ development:
479
+ foo: bar
480
+ YAML
481
+ Buildr.settings.profiles.should == { 'development'=> { 'foo'=>'bar' } }
482
+ end
483
+
484
+ it 'should return loaded profiles.yml file' do
485
+ write 'profiles.yml', <<-YAML
486
+ development:
487
+ foo: bar
488
+ YAML
489
+ Buildr.settings.profiles.should == { 'development'=> { 'foo'=>'bar' } }
490
+ end
491
+
492
+ it 'should fail if profiles.yaml file is not a hash' do
493
+ write 'profiles.yaml', 'foo bar'
494
+ lambda { Buildr.settings.profiles }.should raise_error(RuntimeError, /expecting.*profiles.yaml/i)
495
+ end
496
+
497
+ it 'should be empty hash if profiles.yaml file is empty' do
498
+ write 'profiles.yaml'
499
+ Buildr.settings.profiles.should == {}
500
+ end
501
+ end
502
+
503
+ describe 'profile' do
504
+ before do
505
+ end
506
+
507
+ it 'should be empty hash if no profiles.yaml' do
508
+ Buildr.settings.profile.should == {}
509
+ end
510
+
511
+ it 'should be empty hash if no matching profile' do
512
+ write 'profiles.yaml', <<-YAML
513
+ test:
514
+ foo: bar
515
+ YAML
516
+ Buildr.settings.profile.should == {}
517
+ end
518
+
519
+ it 'should return profile matching environment name' do
520
+ write 'profiles.yaml', <<-YAML
521
+ development:
522
+ foo: bar
523
+ test:
524
+ foo: baz
525
+ YAML
526
+ Buildr.settings.profile.should == { 'foo'=>'bar' }
527
+ end
528
+ end
529
+
530
+ describe 'buildfile task' do
531
+ before do
532
+ @buildfile_time = Time.now - 10
533
+ write 'buildfile'; File.utime(@buildfile_time, @buildfile_time, 'buildfile')
534
+ end
535
+
536
+ it 'should point to the buildfile' do
537
+ Buildr.application.buildfile.should point_to_path('buildfile')
538
+ end
539
+
540
+ it 'should be a defined task' do
541
+ Buildr.application.buildfile.should == file(File.expand_path('buildfile'))
542
+ end
543
+
544
+ it 'should ignore any rake namespace' do
545
+ namespace 'dummy_ns' do
546
+ Buildr.application.buildfile.should point_to_path('buildfile')
547
+ end
548
+ end
549
+
550
+ it 'should have the same timestamp as the buildfile' do
551
+ Buildr.application.buildfile.timestamp.should be_close(@buildfile_time, 1)
552
+ end
553
+
554
+ it 'should have the same timestamp as build.yaml if the latter is newer' do
555
+ write 'build.yaml'; File.utime(@buildfile_time + 5, @buildfile_time + 5, 'build.yaml')
556
+ Buildr.application.run
557
+ Buildr.application.buildfile.timestamp.should be_close(@buildfile_time + 5, 1)
558
+ end
559
+
560
+ it 'should have the same timestamp as the buildfile if build.yaml is older' do
561
+ write 'build.yaml'; File.utime(@buildfile_time - 5, @buildfile_time - 5, 'build.yaml')
562
+ Buildr.application.run
563
+ Buildr.application.buildfile.timestamp.should be_close(@buildfile_time, 1)
564
+ end
565
+
566
+ it 'should have the same timestamp as build.rb in home dir if the latter is newer (until version 1.6)' do
567
+ Buildr::VERSION.should < '1.6'
568
+ buildfile_should_have_same_timestamp_as 'home/buildr.rb'
569
+ end
570
+
571
+ it 'should have the same timestamp as build.rb in home dir if the latter is newer' do
572
+ buildfile_should_have_same_timestamp_as 'home/.buildr/buildr.rb'
573
+ end
574
+
575
+ it 'should have the same timestamp as .buildr.rb in buildfile dir if the latter is newer' do
576
+ buildfile_should_have_same_timestamp_as '.buildr.rb'
577
+ end
578
+
579
+ it 'should have the same timestamp as _buildr.rb in buildfile dir if the latter is newer' do
580
+ buildfile_should_have_same_timestamp_as '_buildr.rb'
581
+ end
582
+
583
+ def buildfile_should_have_same_timestamp_as(file)
584
+ write file; File.utime(@buildfile_time + 5, @buildfile_time + 5, file)
585
+ Buildr.application.send :load_tasks
586
+ Buildr.application.buildfile.timestamp.should be_close(@buildfile_time + 5, 1)
587
+ end
588
+ end
589
+ end
590
+
591
+
592
+ describe Buildr do
593
+
594
+ describe 'environment' do
595
+ it 'should be same as Buildr.application.environment' do
596
+ Buildr.environment.should eql(Buildr.application.environment)
597
+ end
598
+ end
599
+
600
+ describe 'application' do
601
+ it 'should be same as Rake.application' do
602
+ Buildr.application.should == Rake.application
603
+ end
604
+ end
605
+
606
+ describe 'settings' do
607
+ it 'should be same as Buildr.application.settings' do
608
+ Buildr.settings.should == Buildr.application.settings
609
+ end
610
+ end
611
+
612
+ end
613
+
614
+ describe Rake do
615
+ describe 'define_task' do
616
+ it 'should restore call chain when invoke is called' do
617
+ task1 = Rake::Task.define_task('task1') do
618
+ end
619
+
620
+ task2 = Rake::Task.define_task('task2') do
621
+ chain1 = Thread.current[:rake_chain]
622
+ task1.invoke
623
+ chain2 = Thread.current[:rake_chain]
624
+ chain2.should == chain1
625
+ end
626
+
627
+ task2.invoke
628
+ end
629
+ end
630
+ end
631
+