vic-buildr 1.3.3 → 1.3.4

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