buildr 1.3.5-x86-mswin32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (186) hide show
  1. data/CHANGELOG +998 -0
  2. data/LICENSE +176 -0
  3. data/NOTICE +26 -0
  4. data/README.rdoc +134 -0
  5. data/Rakefile +45 -0
  6. data/_buildr +29 -0
  7. data/_jbuildr +29 -0
  8. data/addon/buildr/antlr.rb +65 -0
  9. data/addon/buildr/cobertura.rb +22 -0
  10. data/addon/buildr/drb.rb +281 -0
  11. data/addon/buildr/emma.rb +22 -0
  12. data/addon/buildr/hibernate.rb +142 -0
  13. data/addon/buildr/javacc.rb +85 -0
  14. data/addon/buildr/jdepend.rb +60 -0
  15. data/addon/buildr/jetty.rb +248 -0
  16. data/addon/buildr/jibx.rb +86 -0
  17. data/addon/buildr/nailgun.rb +221 -0
  18. data/addon/buildr/openjpa.rb +90 -0
  19. data/addon/buildr/org/apache/buildr/BuildrNail$Main.class +0 -0
  20. data/addon/buildr/org/apache/buildr/BuildrNail.class +0 -0
  21. data/addon/buildr/org/apache/buildr/BuildrNail.java +41 -0
  22. data/addon/buildr/org/apache/buildr/JettyWrapper$1.class +0 -0
  23. data/addon/buildr/org/apache/buildr/JettyWrapper$BuildrHandler.class +0 -0
  24. data/addon/buildr/org/apache/buildr/JettyWrapper.class +0 -0
  25. data/addon/buildr/org/apache/buildr/JettyWrapper.java +144 -0
  26. data/addon/buildr/xmlbeans.rb +93 -0
  27. data/bin/buildr +19 -0
  28. data/buildr.buildfile +58 -0
  29. data/buildr.gemspec +65 -0
  30. data/doc/_config.yml +1 -0
  31. data/doc/_layouts/default.html +88 -0
  32. data/doc/_layouts/preface.html +22 -0
  33. data/doc/artifacts.textile +211 -0
  34. data/doc/building.textile +244 -0
  35. data/doc/contributing.textile +252 -0
  36. data/doc/css/default.css +236 -0
  37. data/doc/css/print.css +101 -0
  38. data/doc/css/syntax.css +23 -0
  39. data/doc/download.textile +79 -0
  40. data/doc/extending.textile +186 -0
  41. data/doc/images/1442160941-frontcover.jpg +0 -0
  42. data/doc/images/asf-logo.gif +0 -0
  43. data/doc/images/asf-logo.png +0 -0
  44. data/doc/images/buildr-hires.png +0 -0
  45. data/doc/images/buildr.png +0 -0
  46. data/doc/images/favicon.png +0 -0
  47. data/doc/images/growl-icon.tiff +0 -0
  48. data/doc/images/note.png +0 -0
  49. data/doc/images/project-structure.png +0 -0
  50. data/doc/images/tip.png +0 -0
  51. data/doc/images/zbuildr.png +0 -0
  52. data/doc/images/zbuildr.tif +0 -0
  53. data/doc/index.textile +69 -0
  54. data/doc/installing.textile +266 -0
  55. data/doc/languages.textile +459 -0
  56. data/doc/mailing_lists.textile +25 -0
  57. data/doc/more_stuff.textile +457 -0
  58. data/doc/packaging.textile +430 -0
  59. data/doc/preface.textile +54 -0
  60. data/doc/projects.textile +271 -0
  61. data/doc/quick_start.textile +210 -0
  62. data/doc/scripts/buildr-git.rb +512 -0
  63. data/doc/scripts/gitflow.rb +296 -0
  64. data/doc/scripts/install-jruby.sh +44 -0
  65. data/doc/scripts/install-linux.sh +72 -0
  66. data/doc/scripts/install-osx.sh +52 -0
  67. data/doc/settings_profiles.textile +280 -0
  68. data/doc/testing.textile +222 -0
  69. data/etc/KEYS +151 -0
  70. data/lib/buildr.rb +36 -0
  71. data/lib/buildr/core.rb +35 -0
  72. data/lib/buildr/core/application.rb +656 -0
  73. data/lib/buildr/core/build.rb +452 -0
  74. data/lib/buildr/core/checks.rb +254 -0
  75. data/lib/buildr/core/common.rb +150 -0
  76. data/lib/buildr/core/compile.rb +608 -0
  77. data/lib/buildr/core/environment.rb +129 -0
  78. data/lib/buildr/core/filter.rb +362 -0
  79. data/lib/buildr/core/generate.rb +195 -0
  80. data/lib/buildr/core/help.rb +119 -0
  81. data/lib/buildr/core/osx.rb +46 -0
  82. data/lib/buildr/core/progressbar.rb +156 -0
  83. data/lib/buildr/core/project.rb +866 -0
  84. data/lib/buildr/core/shell.rb +198 -0
  85. data/lib/buildr/core/test.rb +723 -0
  86. data/lib/buildr/core/transports.rb +559 -0
  87. data/lib/buildr/core/util.rb +449 -0
  88. data/lib/buildr/groovy.rb +19 -0
  89. data/lib/buildr/groovy/bdd.rb +106 -0
  90. data/lib/buildr/groovy/compiler.rb +138 -0
  91. data/lib/buildr/groovy/shell.rb +48 -0
  92. data/lib/buildr/ide.rb +19 -0
  93. data/lib/buildr/ide/eclipse.rb +334 -0
  94. data/lib/buildr/ide/eclipse/java.rb +53 -0
  95. data/lib/buildr/ide/eclipse/plugin.rb +68 -0
  96. data/lib/buildr/ide/eclipse/scala.rb +66 -0
  97. data/lib/buildr/ide/idea.ipr.template +300 -0
  98. data/lib/buildr/ide/idea.rb +190 -0
  99. data/lib/buildr/ide/idea7x.ipr.template +290 -0
  100. data/lib/buildr/ide/idea7x.rb +212 -0
  101. data/lib/buildr/java.rb +23 -0
  102. data/lib/buildr/java/ant.rb +94 -0
  103. data/lib/buildr/java/bdd.rb +459 -0
  104. data/lib/buildr/java/cobertura.rb +274 -0
  105. data/lib/buildr/java/commands.rb +213 -0
  106. data/lib/buildr/java/compiler.rb +349 -0
  107. data/lib/buildr/java/deprecated.rb +141 -0
  108. data/lib/buildr/java/emma.rb +244 -0
  109. data/lib/buildr/java/jruby.rb +117 -0
  110. data/lib/buildr/java/jtestr_runner.rb.erb +116 -0
  111. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
  112. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +137 -0
  113. data/lib/buildr/java/packaging.rb +716 -0
  114. data/lib/buildr/java/pom.rb +174 -0
  115. data/lib/buildr/java/rjb.rb +155 -0
  116. data/lib/buildr/java/test_result.rb +353 -0
  117. data/lib/buildr/java/tests.rb +333 -0
  118. data/lib/buildr/java/version_requirement.rb +172 -0
  119. data/lib/buildr/packaging.rb +24 -0
  120. data/lib/buildr/packaging/archive.rb +488 -0
  121. data/lib/buildr/packaging/artifact.rb +749 -0
  122. data/lib/buildr/packaging/artifact_namespace.rb +972 -0
  123. data/lib/buildr/packaging/artifact_search.rb +140 -0
  124. data/lib/buildr/packaging/gems.rb +102 -0
  125. data/lib/buildr/packaging/package.rb +238 -0
  126. data/lib/buildr/packaging/tar.rb +186 -0
  127. data/lib/buildr/packaging/version_requirement.rb +172 -0
  128. data/lib/buildr/packaging/zip.rb +73 -0
  129. data/lib/buildr/packaging/ziptask.rb +316 -0
  130. data/lib/buildr/resources/buildr.icns +0 -0
  131. data/lib/buildr/scala.rb +25 -0
  132. data/lib/buildr/scala/bdd.rb +109 -0
  133. data/lib/buildr/scala/compiler.rb +195 -0
  134. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner$.class +0 -0
  135. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.class +0 -0
  136. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.scala +35 -0
  137. data/lib/buildr/scala/shell.rb +55 -0
  138. data/lib/buildr/scala/tests.rb +157 -0
  139. data/lib/buildr/shell.rb +180 -0
  140. data/rakelib/checks.rake +57 -0
  141. data/rakelib/doc.rake +92 -0
  142. data/rakelib/jekylltask.rb +120 -0
  143. data/rakelib/package.rake +73 -0
  144. data/rakelib/release.rake +149 -0
  145. data/rakelib/rspec.rake +73 -0
  146. data/rakelib/setup.rake +54 -0
  147. data/rakelib/stage.rake +213 -0
  148. data/rakelib/stage.rake~ +213 -0
  149. data/spec/addon/drb_spec.rb +328 -0
  150. data/spec/core/application_spec.rb +502 -0
  151. data/spec/core/build_spec.rb +677 -0
  152. data/spec/core/checks_spec.rb +519 -0
  153. data/spec/core/common_spec.rb +670 -0
  154. data/spec/core/compile_spec.rb +583 -0
  155. data/spec/core/extension_spec.rb +93 -0
  156. data/spec/core/generate_spec.rb +33 -0
  157. data/spec/core/project_spec.rb +762 -0
  158. data/spec/core/test_spec.rb +1098 -0
  159. data/spec/core/transport_spec.rb +537 -0
  160. data/spec/core/util_spec.rb +67 -0
  161. data/spec/groovy/bdd_spec.rb +80 -0
  162. data/spec/groovy/compiler_spec.rb +240 -0
  163. data/spec/ide/eclipse_spec.rb +501 -0
  164. data/spec/ide/idea7x_spec.rb +84 -0
  165. data/spec/java/ant_spec.rb +33 -0
  166. data/spec/java/bdd_spec.rb +382 -0
  167. data/spec/java/cobertura_spec.rb +85 -0
  168. data/spec/java/compiler_spec.rb +446 -0
  169. data/spec/java/emma_spec.rb +119 -0
  170. data/spec/java/java_spec.rb +124 -0
  171. data/spec/java/packaging_spec.rb +1134 -0
  172. data/spec/java/test_coverage_helper.rb +257 -0
  173. data/spec/java/tests_spec.rb +493 -0
  174. data/spec/packaging/archive_spec.rb +527 -0
  175. data/spec/packaging/artifact_namespace_spec.rb +654 -0
  176. data/spec/packaging/artifact_spec.rb +795 -0
  177. data/spec/packaging/packaging_helper.rb +63 -0
  178. data/spec/packaging/packaging_spec.rb +684 -0
  179. data/spec/sandbox.rb +142 -0
  180. data/spec/scala/bdd_spec.rb +119 -0
  181. data/spec/scala/compiler_spec.rb +284 -0
  182. data/spec/scala/scala.rb +38 -0
  183. data/spec/scala/tests_spec.rb +261 -0
  184. data/spec/spec_helpers.rb +340 -0
  185. data/spec/version_requirement_spec.rb +129 -0
  186. metadata +383 -0
@@ -0,0 +1,519 @@
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.join(File.dirname(__FILE__), '../spec_helpers')
18
+
19
+
20
+ describe Project, 'check task' do
21
+
22
+ it "should execute last thing from package task" do
23
+ task 'action'
24
+ define 'foo', :version=>'1.0' do
25
+ package :jar
26
+ task('package').enhance { task('action').invoke }
27
+ end
28
+ lambda { project('foo').task('package').invoke }.should run_tasks(['foo:package', 'action', 'foo:check'])
29
+ end
30
+
31
+ it "should execute all project's expectations" do
32
+ task 'expectation'
33
+ define 'foo', :version=>'1.0' do
34
+ check { task('expectation').invoke }
35
+ end
36
+ lambda { project('foo').task('package').invoke }.should run_task('expectation')
37
+ end
38
+
39
+ it "should succeed if there are no expectations" do
40
+ define 'foo', :version=>'1.0'
41
+ lambda { project('foo').task('package').invoke }.should_not raise_error
42
+ end
43
+
44
+ it "should succeed if all expectations passed" do
45
+ define 'foo', :version=>'1.0' do
46
+ check { true }
47
+ check { false }
48
+ end
49
+ lambda { project('foo').task('package').invoke }.should_not raise_error
50
+ end
51
+
52
+ it "should fail if any expectation failed" do
53
+ define 'foo', :version=>'1.0' do
54
+ check
55
+ check { fail 'sorry' }
56
+ check
57
+ end
58
+ lambda { project('foo').task('package').invoke }.should raise_error(RuntimeError, /Checks failed/)
59
+ end
60
+ end
61
+
62
+
63
+ describe Project, '#check' do
64
+
65
+ it "should add expectation" do
66
+ define 'foo' do
67
+ expectations.should be_empty
68
+ check
69
+ expectations.size.should be(1)
70
+ end
71
+ end
72
+
73
+ it "should treat no arguments as expectation against project" do
74
+ define 'foo' do
75
+ subject = self
76
+ check do
77
+ it.should be(subject)
78
+ description.should eql(subject.to_s)
79
+ end
80
+ end
81
+ lambda { project('foo').task('package').invoke }.should_not raise_error
82
+ end
83
+
84
+ it "should treat single string argument as description, expectation against project" do
85
+ define 'foo' do
86
+ subject = self
87
+ check "should be project" do
88
+ it.should be(subject)
89
+ description.should eql("#{subject} should be project")
90
+ end
91
+ end
92
+ lambda { project('foo').task('package').invoke }.should_not raise_error
93
+ end
94
+
95
+ it "should treat single object argument as subject" do
96
+ define 'foo' do
97
+ subject = Object.new
98
+ check subject do
99
+ it.should be(subject)
100
+ description.should eql(subject.to_s)
101
+ end
102
+ end
103
+ lambda { project('foo').task('package').invoke }.should_not raise_error
104
+ end
105
+
106
+ it "should treat first object as subject, second object as description" do
107
+ define 'foo' do
108
+ subject = Object.new
109
+ check subject, "should exist" do
110
+ it.should be(subject)
111
+ description.should eql("#{subject} should exist")
112
+ end
113
+ end
114
+ lambda { project('foo').task('package').invoke }.should_not raise_error
115
+ end
116
+
117
+ it "should work without block" do
118
+ define 'foo' do
119
+ check "implement later"
120
+ end
121
+ lambda { project('foo').task('package').invoke }.should_not raise_error
122
+ end
123
+
124
+ it 'should pass method calls to context' do
125
+ define 'foo', :version=>'1.0' do
126
+ subject = self
127
+ check "should be project" do
128
+ it.should be(subject)
129
+ name.should eql(subject.name)
130
+ package(:jar).should eql(subject.package(:jar))
131
+ end
132
+ end
133
+ lambda { project('foo').task('package').invoke }.should_not raise_error
134
+ end
135
+ end
136
+
137
+
138
+ describe Buildr::Checks::Expectation, 'matchers' do
139
+
140
+ it "should include Buildr matchers exist and contain" do
141
+ define 'foo' do
142
+ check do
143
+ self.should respond_to(:exist)
144
+ self.should respond_to(:contain)
145
+ end
146
+ end
147
+ lambda { project('foo').task('package').invoke }.should_not raise_error
148
+ end
149
+
150
+ it "should include RSpec matchers like be and eql" do
151
+ define 'foo' do
152
+ check do
153
+ self.should respond_to(:be)
154
+ self.should respond_to(:eql)
155
+ end
156
+ end
157
+ lambda { project('foo').task('package').invoke }.should_not raise_error
158
+ end
159
+
160
+ it "should include RSpec predicates like be_nil and be_empty" do
161
+ define 'foo' do
162
+ check do
163
+ nil.should be_nil
164
+ [].should be_empty
165
+ end
166
+ end
167
+ lambda { project('foo').task('package').invoke }.should_not raise_error
168
+ end
169
+ end
170
+
171
+
172
+ describe Buildr::Checks::Expectation, 'exist' do
173
+
174
+ it "should pass if file exists" do
175
+ define 'foo' do
176
+ build file('test') { |task| write task.name }
177
+ check(file('test')) { it.should exist }
178
+ end
179
+ lambda { project('foo').task('package').invoke }.should_not raise_error
180
+ end
181
+
182
+ it "should fail if file does not exist" do
183
+ define 'foo' do
184
+ check(file('test')) { it.should exist }
185
+ end
186
+ lambda { project('foo').task('package').invoke }.should raise_error(RuntimeError, /Checks failed/)
187
+ end
188
+
189
+ it "should not attempt to invoke task" do
190
+ define 'foo' do
191
+ file('test') { |task| write task.name }
192
+ check(file('test')) { it.should exist }
193
+ end
194
+ lambda { project('foo').task('package').invoke }.should raise_error(RuntimeError, /Checks failed/)
195
+ end
196
+ end
197
+
198
+
199
+ describe Buildr::Checks::Expectation, " be_empty" do
200
+
201
+ it "should pass if file has no content" do
202
+ define 'foo' do
203
+ build file('test') { write 'test' }
204
+ check(file('test')) { it.should be_empty }
205
+ end
206
+ lambda { project('foo').task('package').invoke }.should_not raise_error
207
+ end
208
+
209
+ it "should fail if file has content" do
210
+ define 'foo' do
211
+ build file('test') { write 'test', "something" }
212
+ check(file('test')) { it.should be_empty }
213
+ end
214
+ lambda { project('foo').task('package').invoke }.should raise_error(RuntimeError, /Checks failed/)
215
+ end
216
+
217
+ it "should fail if file does not exist" do
218
+ define 'foo' do
219
+ check(file('test')) { it.should be_empty }
220
+ end
221
+ lambda { project('foo').task('package').invoke }.should raise_error(RuntimeError, /Checks failed/)
222
+ end
223
+
224
+ it "should pass if directory is empty" do
225
+ define 'foo' do
226
+ build file('test') { mkpath 'test' }
227
+ check(file('test')) { it.should be_empty }
228
+ end
229
+ lambda { project('foo').task('package').invoke }.should_not raise_error
230
+ end
231
+
232
+ it "should fail if directory has any files" do
233
+ define 'foo' do
234
+ build file('test') { write 'test/file' }
235
+ check(file('test')) { it.should be_empty }
236
+ end
237
+ lambda { project('foo').task('package').invoke }.should raise_error(RuntimeError, /Checks failed/)
238
+ end
239
+ end
240
+
241
+
242
+ describe Buildr::Checks::Expectation, " contain(file)" do
243
+
244
+ it "should pass if file content matches string" do
245
+ define 'foo' do
246
+ build file('test') { write 'test', 'something' }
247
+ check(file('test')) { it.should contain('thing') }
248
+ end
249
+ lambda { project('foo').task('package').invoke }.should_not raise_error
250
+ end
251
+
252
+ it "should pass if file content matches pattern" do
253
+ define 'foo' do
254
+ build file('test') { write 'test', "something\nor\nanother" }
255
+ check(file('test')) { it.should contain(/or/) }
256
+ end
257
+ lambda { project('foo').task('package').invoke }.should_not raise_error
258
+ end
259
+
260
+ it "should pass if file content matches all arguments" do
261
+ define 'foo' do
262
+ build file('test') { write 'test', "something\nor\nanother" }
263
+ check(file('test')) { it.should contain(/or/, /other/) }
264
+ end
265
+ lambda { project('foo').task('package').invoke }.should_not raise_error
266
+ end
267
+
268
+ it "should fail unless file content matchs all arguments" do
269
+ define 'foo' do
270
+ build file('test') { write 'test', 'something' }
271
+ check(file('test')) { it.should contain(/some/, /other/) }
272
+ end
273
+ lambda { project('foo').task('package').invoke }.should raise_error(RuntimeError, /Checks failed/)
274
+ end
275
+
276
+ it "should fail if file content does not match" do
277
+ define 'foo' do
278
+ build file('test') { write 'test', "something" }
279
+ check(file('test')) { it.should contain(/other/) }
280
+ end
281
+ lambda { project('foo').task('package').invoke }.should raise_error(RuntimeError, /Checks failed/)
282
+ end
283
+
284
+ it "should fail if file does not exist" do
285
+ define 'foo' do
286
+ check(file('test')) { it.should contain(/anything/) }
287
+ end
288
+ lambda { project('foo').task('package').invoke }.should raise_error(RuntimeError, /Checks failed/)
289
+ end
290
+ end
291
+
292
+
293
+ describe Buildr::Checks::Expectation, 'contain(directory)' do
294
+
295
+ it "should pass if directory contains file" do
296
+ write 'resources/test'
297
+ define 'foo' do
298
+ check(file('resources')) { it.should contain('test') }
299
+ end
300
+ lambda { project('foo').task('package').invoke }.should_not raise_error
301
+ end
302
+
303
+ it "should pass if directory contains glob pattern" do
304
+ write 'resources/with/test'
305
+ define 'foo' do
306
+ check(file('resources')) { it.should contain('**/t*st') }
307
+ end
308
+ lambda { project('foo').task('package').invoke }.should_not raise_error
309
+ end
310
+
311
+ it "should pass if directory contains all arguments" do
312
+ write 'resources/with/test'
313
+ define 'foo' do
314
+ check(file('resources')) { it.should contain('**/test', '**/*') }
315
+ end
316
+ lambda { project('foo').task('package').invoke }.should_not raise_error
317
+ end
318
+
319
+ it "should fail unless directory contains all arguments" do
320
+ write 'resources/test'
321
+ define 'foo' do
322
+ check(file('resources')) { it.should contain('test', 'or-not') }
323
+ end
324
+ lambda { project('foo').task('package').invoke }.should raise_error(RuntimeError, /Checks failed/)
325
+ end
326
+
327
+ it "should fail if directory is empty" do
328
+ mkpath 'resources'
329
+ define 'foo' do
330
+ check(file('resources')) { it.should contain('test') }
331
+ end
332
+ lambda { project('foo').task('package').invoke }.should raise_error(RuntimeError, /Checks failed/)
333
+ end
334
+
335
+ it "should fail if directory does not exist" do
336
+ define 'foo' do
337
+ check(file('resources')) { it.should contain }
338
+ end
339
+ lambda { project('foo').task('package').invoke }.should raise_error(RuntimeError, /Checks failed/)
340
+ end
341
+ end
342
+
343
+
344
+ describe Buildr::Checks::Expectation do
345
+
346
+ shared_examples_for 'all archive types' do
347
+
348
+ before do
349
+ archive = @archive
350
+ define 'foo', :version=>'1.0' do
351
+ package(archive).include('resources')
352
+ end
353
+ end
354
+
355
+ def check *args, &block
356
+ project('foo').check *args, &block
357
+ end
358
+
359
+ def package
360
+ project('foo').package(@archive)
361
+ end
362
+
363
+ describe '#exist' do
364
+
365
+ it "should pass if archive path exists" do
366
+ write 'resources/test'
367
+ check(package.path('resources')) { it.should exist }
368
+ lambda { project('foo').task('package').invoke }.should_not raise_error
369
+ end
370
+
371
+ it "should fail if archive path does not exist" do
372
+ mkpath 'resources'
373
+ check(package) { it.path('not-resources').should exist }
374
+ lambda { project('foo').task('package').invoke }.should raise_error(RuntimeError, /Checks failed/)
375
+ end
376
+
377
+ it "should pass if archive entry exists" do
378
+ write 'resources/test'
379
+ check(package.entry('resources/test')) { it.should exist }
380
+ check(package.path('resources').entry('test')) { it.should exist }
381
+ lambda { project('foo').task('package').invoke }.should_not raise_error
382
+ end
383
+
384
+ it "should fail if archive path does not exist" do
385
+ mkpath 'resources'
386
+ check(package.entry('resources/test')) { it.should exist }
387
+ lambda { project('foo').task('package').invoke }.should raise_error(RuntimeError, /Checks failed/)
388
+ end
389
+ end
390
+
391
+ describe '#be_empty' do
392
+ it "should pass if archive path is empty" do
393
+ mkpath 'resources'
394
+ check(package.path('resources')) { it.should be_empty }
395
+ lambda { project('foo').task('package').invoke }.should_not raise_error
396
+ end
397
+
398
+ it "should fail if archive path has any entries" do
399
+ write 'resources/test'
400
+ check(package.path('resources')) { it.should be_empty }
401
+ lambda { project('foo').task('package').invoke }.should raise_error(RuntimeError, /Checks failed/)
402
+ end
403
+
404
+ it "should pass if archive entry has no content" do
405
+ write 'resources/test'
406
+ check(package.entry('resources/test')) { it.should be_empty }
407
+ check(package.path('resources').entry('test')) { it.should be_empty }
408
+ lambda { project('foo').task('package').invoke }.should_not raise_error
409
+ end
410
+
411
+ it "should fail if archive entry has content" do
412
+ write 'resources/test', 'something'
413
+ check(package.entry('resources/test')) { it.should be_empty }
414
+ lambda { project('foo').task('package').invoke }.should raise_error(RuntimeError, /Checks failed/)
415
+ end
416
+
417
+ it "should fail if archive entry does not exist" do
418
+ mkpath 'resources'
419
+ check(package.entry('resources/test')) { it.should be_empty }
420
+ lambda { project('foo').task('package').invoke }.should raise_error(RuntimeError, /Checks failed/)
421
+ end
422
+ end
423
+
424
+ describe '#contain(entry)' do
425
+
426
+ it "should pass if archive entry content matches string" do
427
+ write 'resources/test', 'something'
428
+ check(package.entry('resources/test')) { it.should contain('thing') }
429
+ lambda { project('foo').task('package').invoke }.should_not raise_error
430
+ end
431
+
432
+ it "should pass if archive entry content matches pattern" do
433
+ write 'resources/test', "something\nor\another"
434
+ check(package.entry('resources/test')) { it.should contain(/or/) }
435
+ lambda { project('foo').task('package').invoke }.should_not raise_error
436
+ end
437
+
438
+ it "should pass if archive entry content matches all arguments" do
439
+ write 'resources/test', "something\nor\nanother"
440
+ check(package.entry('resources/test')) { it.should contain(/or/, /other/) }
441
+ lambda { project('foo').task('package').invoke }.should_not raise_error
442
+ end
443
+
444
+ it "should fail unless archive path contains all arguments" do
445
+ write 'resources/test', 'something'
446
+ check(package.entry('resources/test')) { it.should contain(/some/, /other/) }
447
+ lambda { project('foo').task('package').invoke }.should raise_error(RuntimeError, /Checks failed/)
448
+ end
449
+
450
+ it "should fail if archive entry content does not match" do
451
+ write 'resources/test', 'something'
452
+ check(package.entry('resources/test')) { it.should contain(/other/) }
453
+ lambda { project('foo').task('package').invoke }.should raise_error(RuntimeError, /Checks failed/)
454
+ end
455
+
456
+ it "should fail if archive entry does not exist" do
457
+ mkpath 'resources'
458
+ check(package.entry('resources/test')) { it.should contain(/anything/) }
459
+ lambda { project('foo').task('package').invoke }.should raise_error(RuntimeError, /Checks failed/)
460
+ end
461
+ end
462
+
463
+ describe '#contain(path)' do
464
+
465
+ it "should pass if archive path contains file" do
466
+ write 'resources/test'
467
+ check(package.path('resources')) { it.should contain('test') }
468
+ lambda { project('foo').task('package').invoke }.should_not raise_error
469
+ end
470
+
471
+ it "should handle deep nesting" do
472
+ write 'resources/test/test2.efx'
473
+ check(package) { it.should contain('resources/test/test2.efx') }
474
+ check(package.path('resources')) { it.should contain('test/test2.efx') }
475
+ check(package.path('resources/test')) { it.should contain('test2.efx') }
476
+ lambda { project('foo').task('package').invoke }.should_not raise_error
477
+ end
478
+
479
+ it "should pass if archive path contains pattern" do
480
+ write 'resources/with/test'
481
+ check(package.path('resources')) { it.should contain('**/t*st') }
482
+ lambda { project('foo').task('package').invoke }.should_not raise_error
483
+ end
484
+
485
+ it "should pass if archive path contains all arguments" do
486
+ write 'resources/with/test'
487
+ check(package.path('resources')) { it.should contain('**/test', '**/*') }
488
+ lambda { project('foo').task('package').invoke }.should_not raise_error
489
+ end
490
+
491
+ it "should fail unless archive path contains all arguments" do
492
+ write 'resources/test'
493
+ check(package.path('resources')) { it.should contain('test', 'or-not') }
494
+ lambda { project('foo').task('package').invoke }.should raise_error(RuntimeError, /Checks failed/)
495
+ end
496
+
497
+ it "should fail if archive path is empty" do
498
+ mkpath 'resources'
499
+ check(package.path('resources')) { it.should contain('test') }
500
+ lambda { project('foo').task('package').invoke }.should raise_error(RuntimeError, /Checks failed/)
501
+ end
502
+ end
503
+ end
504
+
505
+ describe 'ZIP' do
506
+ before { @archive = :jar }
507
+ it_should_behave_like 'all archive types'
508
+ end
509
+
510
+ describe 'tar' do
511
+ before { @archive = :tar }
512
+ it_should_behave_like 'all archive types'
513
+ end
514
+
515
+ describe 'tgz' do
516
+ before { @archive = :tgz }
517
+ it_should_behave_like 'all archive types'
518
+ end
519
+ end