fjc-warbler 0.9.12

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.
@@ -0,0 +1,9 @@
1
+ #--
2
+ # (c) Copyright 2007-2008 Sun Microsystems, Inc.
3
+ # See the file LICENSES.txt included with the distribution for
4
+ # software license details.
5
+ #++
6
+
7
+ module Warbler
8
+ VERSION = "0.9.12"
9
+ end
@@ -0,0 +1,43 @@
1
+ #--
2
+ # (c) Copyright 2007-2008 Sun Microsystems, Inc.
3
+ # See the file LICENSES.txt included with the distribution for
4
+ # software license details.
5
+ #++
6
+
7
+ require 'rubygems'
8
+ require 'spec'
9
+
10
+ $LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
11
+ require 'warbler'
12
+
13
+ raise %{Error: detected running Warbler specs in a Rails app;
14
+ Warbler specs are destructive to application directories.} if File.directory?("app")
15
+
16
+ def silence(io = nil)
17
+ require 'stringio'
18
+ old_stdout = $stdout
19
+ old_stderr = $stderr
20
+ $stdout = io || StringIO.new
21
+ $stderr = io || StringIO.new
22
+ yield
23
+ ensure
24
+ $stdout = old_stdout
25
+ $stderr = old_stderr
26
+ end
27
+
28
+ def capture(&block)
29
+ require 'stringio'
30
+ io = StringIO.new
31
+ silence(io, &block)
32
+ io.string
33
+ end
34
+
35
+ Spec::Runner.configure do |config|
36
+ config.after(:each) do
37
+ class << Object
38
+ public :remove_const
39
+ end
40
+ Object.remove_const("Rails") rescue nil
41
+ rm_rf "vendor"
42
+ end
43
+ end
@@ -0,0 +1,110 @@
1
+ #--
2
+ # (c) Copyright 2007-2008 Sun Microsystems, Inc.
3
+ # See the file LICENSES.txt included with the distribution for
4
+ # software license details.
5
+ #++
6
+
7
+ require File.dirname(__FILE__) + '/../spec_helper'
8
+
9
+ describe Warbler::Config do
10
+ it "should have suitable default values" do
11
+ config = Warbler::Config.new
12
+ config.staging_dir.should == "tmp/war"
13
+ config.dirs.should include(*Warbler::Config::TOP_DIRS.select{|d| File.directory?(d)})
14
+ config.includes.should be_empty
15
+ config.java_libs.should_not be_empty
16
+ config.war_name.size.should > 0
17
+ config.webxml.should be_kind_of(OpenStruct)
18
+ config.pathmaps.should be_kind_of(OpenStruct)
19
+ config.pathmaps.public_html.should == ["%{public/,}p"]
20
+ end
21
+
22
+ it "should allow configuration through an initializer block" do
23
+ config = Warbler::Config.new do |c|
24
+ c.staging_dir = "/var/tmp"
25
+ c.war_name = "mywar"
26
+ end
27
+ config.staging_dir.should == "/var/tmp"
28
+ config.war_name.should == "mywar"
29
+ end
30
+
31
+ it "should allow gems to be added/changed with =, +=, -=, <<" do
32
+ config = Warbler::Config.new do |c|
33
+ c.gems += ["activerecord-jdbc-adapter"]
34
+ c.gems -= ["rails"]
35
+ c.gems << "tzinfo"
36
+ c.gems = ["camping"]
37
+ end
38
+ end
39
+
40
+ it "should exclude log files by default" do
41
+ mkdir_p "vendor"
42
+ touch "vendor/test.log"
43
+ config = Warbler::Config.new
44
+ config.exclude_logs.should == true
45
+ config.excludes.include?("vendor/test.log").should == true
46
+ end
47
+
48
+ it "should include log files if exclude_logs is false" do
49
+ mkdir_p "vendor"
50
+ touch "vendor/test.log"
51
+ config = Warbler::Config.new {|c| c.exclude_logs = false }
52
+ config.exclude_logs.should == false
53
+ config.excludes.include?("vendor/test.log").should == false
54
+ end
55
+
56
+ it "should exclude Warbler itself when run as a plugin" do
57
+ config = Warbler::Config.new
58
+ config.excludes.include?("vendor/plugins/warbler").should == false
59
+ config = Warbler::Config.new File.join(Dir.getwd, "vendor", "plugins", "warbler")
60
+ config.excludes.include?("vendor/plugins/warbler").should == true
61
+ end
62
+
63
+ it "should generate context parameters from the webxml openstruct" do
64
+ config = Warbler::Config.new
65
+ config.webxml.a.b.c = "123"
66
+ config.webxml.com.example.config = "blah"
67
+ config.webxml.rails.env = 'staging'
68
+ config.webxml.jruby.min.runtimes = 2
69
+ config.webxml.jruby.max.runtimes = 4
70
+ config.webxml['org']['jruby']['rack'] = "rails"
71
+ params = config.webxml.context_params
72
+ params.should have_key('a.b.c')
73
+ params.should have_key('rails.env')
74
+ params.should have_key('jruby.min.runtimes')
75
+ params.should have_key('jruby.max.runtimes')
76
+ params['a.b.c'].should == "123"
77
+ params['com.example.config'].should == "blah"
78
+ params['rails.env'].should == "staging"
79
+ params['jruby.min.runtimes'].should == "2"
80
+ params['jruby.max.runtimes'].should == "4"
81
+ params['org.jruby.rack'].should == "rails"
82
+ end
83
+
84
+ it "should determine the context listener from the webxml.booter parameter" do
85
+ config = Warbler::Config.new
86
+ config.webxml.booter = :rack
87
+ config.webxml.servlet_context_listener.should == "org.jruby.rack.RackServletContextListener"
88
+ config = Warbler::Config.new
89
+ config.webxml.booter = :merb
90
+ config.webxml.servlet_context_listener.should == "org.jruby.rack.merb.MerbServletContextListener"
91
+ config = Warbler::Config.new
92
+ config.webxml.servlet_context_listener.should == "org.jruby.rack.rails.RailsServletContextListener"
93
+ end
94
+
95
+ it "should not include ignored webxml keys in the context params hash" do
96
+ Warbler::Config.new.webxml.context_params.should_not have_key('ignored')
97
+ Warbler::Config.new.webxml.context_params.should_not have_key('jndi')
98
+ Warbler::Config.new.webxml.context_params.should_not have_key('booter')
99
+ end
100
+
101
+ it "should have a helpful string representation for an empty key" do
102
+ Warbler::Config.new.webxml.missing_key.to_s.should =~ /No value for 'missing_key' found/
103
+ end
104
+
105
+ it "should HTML-escape all webxml keys and values" do
106
+ config = Warbler::Config.new
107
+ config.webxml.a["b&"].c = "123<hi>456"
108
+ config.webxml.context_params['a.b&amp;.c'].should == "123&lt;hi&gt;456"
109
+ end
110
+ end
@@ -0,0 +1,39 @@
1
+ #--
2
+ # (c) Copyright 2007-2008 Sun Microsystems, Inc.
3
+ # See the file LICENSES.txt included with the distribution for
4
+ # software license details.
5
+ #++
6
+
7
+ require File.dirname(__FILE__) + '/../spec_helper'
8
+
9
+ describe Warbler::Gems do
10
+ it "should accept a hash for initialization" do
11
+ gems = Warbler::Gems.new({"actionpack" => "1.2.3"})
12
+ gems.should have_key("actionpack")
13
+ gems["actionpack"].should == "1.2.3"
14
+ end
15
+
16
+ it "should accept an array for initialization" do
17
+ gems = Warbler::Gems.new ["activerecord"]
18
+ gems.should have_key("activerecord")
19
+ end
20
+
21
+ it "should allow gems with a version" do
22
+ gems = Warbler::Gems.new
23
+ gems["actionpack"] = "> 1.2.3"
24
+ gems["actionpack"].should == "> 1.2.3"
25
+ end
26
+
27
+ it "should allow gems without an explicit version" do
28
+ gems = Warbler::Gems.new
29
+ gems << "actionpack"
30
+ gems.should have_key("actionpack")
31
+ end
32
+
33
+ it "should allow to add gems" do
34
+ gems = Warbler::Gems.new
35
+ gems << "rails"
36
+ gems += ["activerecord-jdbcmysql-adapter", "jdbc-mysql", "jruby-openssl"]
37
+ ["rails", "activerecord-jdbcmysql-adapter", "jdbc-mysql", "jruby-openssl"].each {|g| gems.should have_key(g)}
38
+ end
39
+ end
@@ -0,0 +1,432 @@
1
+ #--
2
+ # (c) Copyright 2007-2008 Sun Microsystems, Inc.
3
+ # See the file LICENSES.txt included with the distribution for
4
+ # software license details.
5
+ #++
6
+
7
+ require File.dirname(__FILE__) + '/../spec_helper'
8
+
9
+ describe Warbler::Task do
10
+ before(:each) do
11
+ @rake = Rake::Application.new
12
+ Rake.application = @rake
13
+ verbose(false)
14
+ @pwd = Dir.getwd
15
+ Dir.chdir("spec/sample")
16
+ mkdir_p "log"
17
+ touch "log/test.log"
18
+ @config = Warbler::Config.new do |config|
19
+ config.staging_dir = "tmp/war"
20
+ config.war_name = "warbler"
21
+ config.gems = ["rake"]
22
+ config.webxml.jruby.max.runtimes = 5
23
+ end
24
+ end
25
+
26
+ after(:each) do
27
+ define_tasks "clean"
28
+ Rake::Task["warble:clean"].invoke
29
+ rm_rf "log"
30
+ rm_f FileList["config.ru", "*web.xml", "config/web.xml*", "config/warble.rb"]
31
+ Dir.chdir(@pwd)
32
+ end
33
+
34
+ def define_tasks(*tasks)
35
+ options = tasks.last.kind_of?(Hash) ? tasks.pop : {}
36
+ @defined_tasks ||= []
37
+ tasks.each do |task|
38
+ unless @defined_tasks.include?(task)
39
+ Warbler::Task.new "warble", @config, "define_#{task}_task".to_sym do |t|
40
+ options.each {|k,v| t.send "#{k}=", v }
41
+ end
42
+ @defined_tasks << task
43
+ end
44
+ end
45
+ end
46
+
47
+ def file_list(regex)
48
+ FileList["#{@config.staging_dir}/**/*"].select {|f| f =~ regex }
49
+ end
50
+
51
+ it "should define a clean task for removing the staging directory" do
52
+ define_tasks "clean"
53
+ mkdir_p @config.staging_dir
54
+ Rake::Task["warble:clean"].invoke
55
+ File.exist?(@config.staging_dir).should == false
56
+ end
57
+
58
+ it "should define a public task for copying the public files" do
59
+ define_tasks "public"
60
+ Rake::Task["warble:public"].invoke
61
+ file_list(%r{^#{@config.staging_dir}/index\.html}).should_not be_empty
62
+ end
63
+
64
+ it "should define a gems task for unpacking gems" do
65
+ @config.gems << "rails"
66
+ define_tasks "gems"
67
+ Rake::Task["warble:gems"].invoke
68
+ file_list(%r{WEB-INF/gems/gems/rake.*/lib/rake.rb}).should_not be_empty
69
+ file_list(%r{WEB-INF/gems/specifications/rake.*\.gemspec}).should_not be_empty
70
+ end
71
+
72
+ it "should define a app task for copying application files" do
73
+ define_tasks "app", "gems"
74
+ Rake::Task["warble:app"].invoke
75
+ file_list(%r{WEB-INF/log}).should_not be_empty
76
+ file_list(%r{WEB-INF/log/*.log}).should be_empty
77
+ end
78
+
79
+ def expand_webxml
80
+ define_tasks "webxml"
81
+ Rake::Task["warble:webxml"].invoke
82
+ require 'rexml/document'
83
+ File.open("#{@config.staging_dir}/WEB-INF/web.xml") do |f|
84
+ REXML::Document.new(f).root.elements
85
+ end
86
+ end
87
+
88
+ it "should define a webxml task for creating web.xml" do
89
+ elements = expand_webxml
90
+ elements.to_a(
91
+ "context-param/param-name[text()='jruby.max.runtimes']"
92
+ ).should_not be_empty
93
+ elements.to_a(
94
+ "context-param/param-name[text()='jruby.max.runtimes']/../param-value"
95
+ ).first.text.should == "5"
96
+ end
97
+
98
+ it "should include custom context parameters" do
99
+ @config.webxml.some.custom.config = "myconfig"
100
+ elements = expand_webxml
101
+ elements.to_a(
102
+ "context-param/param-name[text()='some.custom.config']"
103
+ ).should_not be_empty
104
+ elements.to_a(
105
+ "context-param/param-name[text()='some.custom.config']/../param-value"
106
+ ).first.text.should == "myconfig"
107
+ end
108
+
109
+ it "should allow one jndi resource to be included" do
110
+ @config.webxml.jndi = 'jndi/rails'
111
+ elements = expand_webxml
112
+ elements.to_a(
113
+ "resource-ref/res-ref-name[text()='jndi/rails']"
114
+ ).should_not be_empty
115
+ end
116
+
117
+ it "should allow multiple jndi resources to be included" do
118
+ @config.webxml.jndi = ['jndi/rails1', 'jndi/rails2']
119
+ elements = expand_webxml
120
+ elements.to_a(
121
+ "resource-ref/res-ref-name[text()='jndi/rails1']"
122
+ ).should_not be_empty
123
+ elements.to_a(
124
+ "resource-ref/res-ref-name[text()='jndi/rails2']"
125
+ ).should_not be_empty
126
+ end
127
+
128
+ it "should not include any ignored context parameters" do
129
+ @config.webxml.foo = "bar"
130
+ @config.webxml.ignored << "foo"
131
+ elements = expand_webxml
132
+ elements.to_a(
133
+ "context-param/param-name[text()='foo']"
134
+ ).should be_empty
135
+ elements.to_a(
136
+ "context-param/param-name[text()='ignored']"
137
+ ).should be_empty
138
+ elements.to_a(
139
+ "context-param/param-name[text()='jndi']"
140
+ ).should be_empty
141
+ end
142
+
143
+ it "should use a config/web.xml if it exists" do
144
+ define_tasks "webxml"
145
+ mkdir_p "config"
146
+ File.open("config/web.xml", "w") {|f| f << "Hi there" }
147
+ Rake::Task["warble:webxml"].invoke
148
+ files = file_list(%r{WEB-INF/web.xml$})
149
+ files.should_not be_empty
150
+ File.open(files.first) {|f| f.read}.should == "Hi there"
151
+ end
152
+
153
+ it "should use a config/web.xml.erb if it exists" do
154
+ define_tasks "webxml"
155
+ mkdir_p "config"
156
+ File.open("config/web.xml.erb", "w") {|f| f << "Hi <%= webxml.public.root %>" }
157
+ Rake::Task["warble:webxml"].invoke
158
+ files = file_list(%r{WEB-INF/web.xml$})
159
+ files.should_not be_empty
160
+ File.open(files.first) {|f| f.read}.should == "Hi /"
161
+ end
162
+
163
+ it "should define a java_libs task for copying java libraries" do
164
+ define_tasks "java_libs"
165
+ Rake::Task["warble:java_libs"].invoke
166
+ file_list(%r{WEB-INF/lib/jruby-complete.*\.jar$}).should_not be_empty
167
+ end
168
+
169
+ it "should define an app task for copying application files" do
170
+ gems_ran = false
171
+ task "warble:gems" do
172
+ gems_ran = true
173
+ end
174
+ define_tasks "app"
175
+ Rake::Task["warble:app"].invoke
176
+ file_list(%r{WEB-INF/app$}).should_not be_empty
177
+ file_list(%r{WEB-INF/config$}).should_not be_empty
178
+ file_list(%r{WEB-INF/lib$}).should_not be_empty
179
+ gems_ran.should == true
180
+ end
181
+
182
+ it "should define a jar task for creating the .war" do
183
+ define_tasks "jar"
184
+ mkdir_p @config.staging_dir
185
+ touch "#{@config.staging_dir}/file.txt"
186
+ Rake::Task["warble:jar"].invoke
187
+ File.exist?("warbler.war").should == true
188
+ end
189
+
190
+ it "should define an exploded task for creating an exploded Rails app" do
191
+ @config.java_classes = ["Rakefile"]
192
+ @config.java_libs = []
193
+ define_tasks "webxml", "exploded", "java_classes", "gems"
194
+ Rake::Task['warble:exploded'].invoke
195
+ File.exist?("web.xml").should == true
196
+ File.exist?("sun-web.xml").should == true
197
+ File.symlink?("gems").should == true
198
+ File.symlink?("public/WEB-INF").should == true
199
+ Rake::Task['warble:clean:exploded'].invoke
200
+ end
201
+
202
+ it "should accept an autodeploy directory where the war should be created" do
203
+ define_tasks "jar"
204
+ require 'tempfile'
205
+ @config.autodeploy_dir = Dir::tmpdir
206
+ mkdir_p @config.staging_dir
207
+ touch "#{@config.staging_dir}/file.txt"
208
+ Rake::Task["warble:jar"].invoke
209
+ File.exist?(File.join("#{Dir::tmpdir}","warbler.war")).should == true
210
+ end
211
+
212
+ it "should define a war task for bundling up everything" do
213
+ app_ran = false; task "warble:app" do; app_ran = true; end
214
+ public_ran = false; task "warble:public" do; public_ran = true; end
215
+ jar_ran = false; task "warble:jar" do; jar_ran = true; end
216
+ webxml_ran = false; task "warble:webxml" do; webxml_ran = true; end
217
+ define_tasks "main"
218
+ Rake::Task["warble"].invoke
219
+ app_ran.should == true
220
+ public_ran.should == true
221
+ jar_ran.should == true
222
+ webxml_ran.should == true
223
+ end
224
+
225
+ it "should be able to exclude files from the .war" do
226
+ @config.excludes += FileList['lib/tasks/utils.rake']
227
+ task "warble:gems" do; end
228
+ define_tasks "app"
229
+ Rake::Task["warble:app"].invoke
230
+ file_list(%r{lib/tasks/utils.rake}).should be_empty
231
+ end
232
+
233
+ it "should be able to define all tasks successfully" do
234
+ Warbler::Task.new "warble", @config
235
+ end
236
+
237
+ it "should read configuration from #{Warbler::Config::FILE}" do
238
+ mkdir_p "config"
239
+ File.open(Warbler::Config::FILE, "w") do |dest|
240
+ contents =
241
+ File.open("#{Warbler::WARBLER_HOME}/generators/warble/templates/warble.rb") do |src|
242
+ src.read
243
+ end
244
+ dest << contents.sub(/# config\.war_name/, 'config.war_name'
245
+ ).sub(/# config.gems << "tzinfo"/, 'config.gems = []')
246
+ end
247
+ t = Warbler::Task.new "warble"
248
+ t.config.war_name.should == "mywar"
249
+ end
250
+
251
+ it "should fail if a gem is requested that is not installed" do
252
+ @config.gems = ["nonexistent-gem"]
253
+ lambda {
254
+ Warbler::Task.new "warble", @config
255
+ }.should raise_error
256
+ end
257
+
258
+ it "should handle platform-specific gems" do
259
+ spec = mock "gem spec"
260
+ spec.stub!(:name).and_return "hpricot"
261
+ spec.stub!(:version).and_return "0.6.157"
262
+ spec.stub!(:platform).and_return "java"
263
+ spec.stub!(:original_platform).and_return "java"
264
+ spec.stub!(:loaded_from).and_return "hpricot.gemspec"
265
+ spec.stub!(:dependencies).and_return []
266
+ Gem.source_index.should_receive(:search).and_return do |gem|
267
+ gem.name.should == "hpricot"
268
+ [spec]
269
+ end
270
+ File.should_receive(:exist?).with(File.join(Gem.dir, 'cache', "hpricot-0.6.157-java.gem")).and_return true
271
+ @config.gems = ["hpricot"]
272
+ define_tasks "gems"
273
+ end
274
+
275
+ it "should allow specification of dependency by Gem::Dependency" do
276
+ spec = mock "gem spec"
277
+ spec.stub!(:name).and_return "hpricot"
278
+ spec.stub!(:version).and_return "0.6.157"
279
+ spec.stub!(:platform).and_return "java"
280
+ spec.stub!(:original_platform).and_return "java"
281
+ spec.stub!(:loaded_from).and_return "hpricot.gemspec"
282
+ spec.stub!(:dependencies).and_return []
283
+ Gem.source_index.should_receive(:search).and_return do |gem|
284
+ gem.name.should == "hpricot"
285
+ [spec]
286
+ end
287
+ File.should_receive(:exist?).with(File.join(Gem.dir, 'cache', "hpricot-0.6.157-java.gem")).and_return true
288
+ @config.gems = [Gem::Dependency.new("hpricot", "> 0.6")]
289
+ define_tasks "gems"
290
+ end
291
+
292
+ it "should define a java_classes task for copying loose java classes" do
293
+ @config.java_classes = FileList["Rakefile"]
294
+ define_tasks "java_classes"
295
+ Rake::Task["warble:java_classes"].invoke
296
+ file_list(%r{WEB-INF/classes/Rakefile$}).should_not be_empty
297
+ end
298
+
299
+ def mock_rails_module
300
+ rails = Module.new
301
+ Object.const_set("Rails", rails)
302
+ version = Module.new
303
+ rails.const_set("VERSION", version)
304
+ version.const_set("STRING", "2.1.0")
305
+ rails
306
+ end
307
+
308
+ it "should auto-detect a Rails application" do
309
+ task :environment do
310
+ mock_rails_module
311
+ end
312
+ @config = Warbler::Config.new
313
+ @config.webxml.booter.should == :rails
314
+ @config.gems["rails"].should == "2.1.0"
315
+ end
316
+
317
+ it "should provide Rails gems by default, unless vendor/rails is present" do
318
+ rails = nil
319
+ task :environment do
320
+ rails = mock_rails_module
321
+ end
322
+
323
+ config = Warbler::Config.new
324
+ config.gems.should have_key("rails")
325
+
326
+ mkdir_p "vendor/rails"
327
+ config = Warbler::Config.new
328
+ config.gems.should be_empty
329
+
330
+ rm_rf "vendor/rails"
331
+ rails.stub!(:vendor_rails?).and_return true
332
+ config = Warbler::Config.new
333
+ config.gems.should be_empty
334
+ end
335
+
336
+ it "should not try to autodetect frameworks when Warbler.framework_detection is false" do
337
+ begin
338
+ Warbler.framework_detection = false
339
+ task :environment
340
+ config = Warbler::Config.new
341
+ config.webxml.booter.should_not == :rails
342
+ t = Rake::Task['environment']
343
+ class << t; public :instance_variable_get; end
344
+ t.instance_variable_get("@already_invoked").should == false
345
+ ensure
346
+ Warbler.framework_detection = true
347
+ end
348
+ end
349
+
350
+ it "should auto-detect a Merb application" do
351
+ task :merb_env do
352
+ merb = Module.new
353
+ Object.const_set("Merb", merb)
354
+ merb.const_set("VERSION", "0.9.3")
355
+ end
356
+ @config = Warbler::Config.new
357
+ @config.webxml.booter.should == :merb
358
+ @config.gems["merb-core"].should == "0.9.3"
359
+ @config.gems.keys.should_not include("rails")
360
+ end
361
+
362
+ it "should auto-detect a Rack application with a config.ru file" do
363
+ rackup = "run Proc.new {|env| [200, {}, ['Hello World']]}"
364
+ File.open("config.ru", "w") {|f| f << rackup }
365
+ @config = Warbler::Config.new
366
+ @config.webxml.booter.should == :rack
367
+ @config.webxml.rackup.should == rackup
368
+ end
369
+
370
+ it "should automatically add Rails.configuration.gems to the list of gems" do
371
+ task :environment do
372
+ rails = mock_rails_module
373
+ config = mock "config"
374
+ rails.stub!(:configuration).and_return(config)
375
+ gem = mock "gem"
376
+ gem.stub!(:name).and_return "hpricot"
377
+ gem.stub!(:version).and_return "=0.6"
378
+ config.stub!(:gems).and_return [gem]
379
+ end
380
+
381
+ @config = Warbler::Config.new
382
+ @config.webxml.booter.should == :rails
383
+ @config.gems["hpricot"].should == "=0.6"
384
+ end
385
+
386
+ it "should set the jruby max runtimes to 1 when MT Rails is detected" do
387
+ task :environment do
388
+ rails = mock_rails_module
389
+ config = mock "config"
390
+ rails.stub!(:configuration).and_return(config)
391
+ config.stub!(:threadsafe!)
392
+ end
393
+ @config = Warbler::Config.new
394
+ @config.webxml.booter.should == :rails
395
+ @config.webxml.jruby.max.runtimes.should == 1
396
+ end
397
+ end
398
+
399
+ describe "The warbler.rake file" do
400
+ it "should be able to list its contents" do
401
+ output = `#{FileUtils::RUBY} -S rake -f #{Warbler::WARBLER_HOME}/tasks/warbler.rake -T`
402
+ output.should =~ /war\s/
403
+ output.should =~ /war:exploded/
404
+ output.should =~ /war:app/
405
+ output.should =~ /war:clean/
406
+ output.should =~ /war:gems/
407
+ output.should =~ /war:jar/
408
+ output.should =~ /war:java_libs/
409
+ output.should =~ /war:java_classes/
410
+ output.should =~ /war:public/
411
+ end
412
+ end
413
+
414
+ describe "Debug targets" do
415
+ before(:each) do
416
+ @rake = Rake::Application.new
417
+ Rake.application = @rake
418
+ verbose(false)
419
+ silence { Warbler::Task.new :war, Object.new }
420
+ end
421
+
422
+ it "should print out lists of files" do
423
+ capture { Rake::Task["war:debug:public"].invoke }.should =~ /public/
424
+ capture { Rake::Task["war:debug:gems"].invoke }.should =~ /gems/
425
+ capture { Rake::Task["war:debug:java_libs"].invoke }.should =~ /java_libs/
426
+ capture { Rake::Task["war:debug:java_classes"].invoke }.should =~ /java_classes/
427
+ capture { Rake::Task["war:debug:app"].invoke }.should =~ /app/
428
+ capture { Rake::Task["war:debug:includes"].invoke }.should =~ /include/
429
+ capture { Rake::Task["war:debug:excludes"].invoke }.should =~ /exclude/
430
+ capture { Rake::Task["war:debug"].invoke }.should =~ /Config/
431
+ end
432
+ end