warbler 0.9.14 → 1.0
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.
- data/Gemfile +10 -0
- data/History.txt +16 -0
- data/{LICENSES.txt → LICENSE.txt} +2 -13
- data/Manifest.txt +21 -9
- data/README.txt +38 -53
- data/Rakefile +48 -16
- data/bin/warble +5 -62
- data/ext/WarblerWar.java +113 -0
- data/ext/WarblerWarService.java +17 -0
- data/lib/warbler.rb +20 -4
- data/lib/warbler/application.rb +63 -0
- data/lib/warbler/config.rb +100 -13
- data/lib/warbler/gems.rb +4 -3
- data/lib/warbler/runtime.rb +43 -0
- data/lib/warbler/task.rb +55 -288
- data/lib/warbler/version.rb +5 -4
- data/lib/warbler/war.rb +169 -0
- data/lib/warbler_war.jar +0 -0
- data/spec/sample/config/database.yml +19 -0
- data/spec/sample/lib/tasks/utils.rake +0 -0
- data/spec/sample/public/404.html +30 -0
- data/spec/sample/public/422.html +30 -0
- data/spec/sample/public/500.html +30 -0
- data/spec/sample/public/favicon.ico +0 -0
- data/spec/sample/public/index.html +274 -0
- data/spec/sample/public/robots.txt +5 -0
- data/spec/spec_helper.rb +5 -4
- data/spec/warbler/application_spec.rb +73 -0
- data/spec/warbler/config_spec.rb +8 -6
- data/spec/warbler/gems_spec.rb +4 -3
- data/spec/warbler/task_spec.rb +24 -428
- data/spec/warbler/war_spec.rb +425 -0
- data/{generators/warble/templates/warble.rb → warble.rb} +29 -9
- metadata +94 -26
- data/generators/warble/warble_generator.rb +0 -19
- data/lib/jruby-rack-0.9.5.jar +0 -0
- data/tasks/warbler.rake +0 -18
data/spec/spec_helper.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
#--
|
2
|
-
# (c)
|
3
|
-
#
|
4
|
-
#
|
2
|
+
# Copyright (c) 2010 Engine Yard, Inc.
|
3
|
+
# Copyright (c) 2007-2009 Sun Microsystems, Inc.
|
4
|
+
# This source code is available under the MIT license.
|
5
|
+
# See the file LICENSE.txt for details.
|
5
6
|
#++
|
6
7
|
|
7
8
|
require 'rubygems'
|
@@ -40,4 +41,4 @@ Spec::Runner.configure do |config|
|
|
40
41
|
Object.remove_const("Rails") rescue nil
|
41
42
|
rm_rf "vendor"
|
42
43
|
end
|
43
|
-
end
|
44
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2010 Engine Yard, Inc.
|
3
|
+
# Copyright (c) 2007-2009 Sun Microsystems, Inc.
|
4
|
+
# This source code is available under the MIT license.
|
5
|
+
# See the file LICENSE.txt for details.
|
6
|
+
#++
|
7
|
+
|
8
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
9
|
+
|
10
|
+
describe Warbler::Application do
|
11
|
+
before :each do
|
12
|
+
verbose(false)
|
13
|
+
@pwd = Dir.getwd
|
14
|
+
Dir.chdir("spec/sample")
|
15
|
+
@argv = ARGV.dup
|
16
|
+
ARGV.clear
|
17
|
+
@app = Rake.application
|
18
|
+
rm_f "config/warble.rb"
|
19
|
+
@detection = Warbler.framework_detection
|
20
|
+
Warbler.framework_detection = false
|
21
|
+
end
|
22
|
+
|
23
|
+
after :each do
|
24
|
+
Rake.application = @app
|
25
|
+
Warbler.project_application = nil
|
26
|
+
Warbler.application = nil
|
27
|
+
Warbler.framework_detection = @detection
|
28
|
+
@argv.reverse.each {|a| ARGV.unshift a}
|
29
|
+
Dir.chdir(@pwd)
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should be able to list its tasks" do
|
33
|
+
ARGV.unshift "-T"
|
34
|
+
output = capture do
|
35
|
+
Warbler::Application.new.run
|
36
|
+
end
|
37
|
+
output.should =~ /warble war\s/
|
38
|
+
output.should =~ /warble war:clean/
|
39
|
+
output.should =~ /warble war:debug/
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should display the version" do
|
43
|
+
ARGV.unshift "version"
|
44
|
+
capture { Warbler::Application.new.run }.should =~ /#{Warbler::VERSION}/
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should copy a fresh config file into place" do
|
48
|
+
File.exists?("config/warble.rb").should_not be_true
|
49
|
+
ARGV.unshift "config"
|
50
|
+
silence { Warbler::Application.new.run }
|
51
|
+
File.exists?("config/warble.rb").should be_true
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should refuse to copy over an existing config file" do
|
55
|
+
touch "config/warble.rb"
|
56
|
+
ARGV.unshift "config"
|
57
|
+
capture { Warbler::Application.new.run }.should =~ /already exists/
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should complain if the config directory is missing" do
|
61
|
+
begin
|
62
|
+
mv "config", "config-tmp"
|
63
|
+
ARGV.unshift "config"
|
64
|
+
capture { Warbler::Application.new.run }.should =~ /missing/
|
65
|
+
ensure
|
66
|
+
mv "config-tmp", "config"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should provide a means to load the project Rakefile" do
|
71
|
+
Warbler::Application.new.load_project_rakefile
|
72
|
+
end
|
73
|
+
end
|
data/spec/warbler/config_spec.rb
CHANGED
@@ -1,15 +1,19 @@
|
|
1
1
|
#--
|
2
|
-
# (c)
|
3
|
-
#
|
4
|
-
#
|
2
|
+
# Copyright (c) 2010 Engine Yard, Inc.
|
3
|
+
# Copyright (c) 2007-2009 Sun Microsystems, Inc.
|
4
|
+
# This source code is available under the MIT license.
|
5
|
+
# See the file LICENSE.txt for details.
|
5
6
|
#++
|
6
7
|
|
7
8
|
require File.dirname(__FILE__) + '/../spec_helper'
|
8
9
|
|
9
10
|
describe Warbler::Config do
|
11
|
+
before :each do
|
12
|
+
verbose(false)
|
13
|
+
end
|
14
|
+
|
10
15
|
it "should have suitable default values" do
|
11
16
|
config = Warbler::Config.new
|
12
|
-
config.staging_dir.should == "tmp/war"
|
13
17
|
config.dirs.should include(*Warbler::Config::TOP_DIRS.select{|d| File.directory?(d)})
|
14
18
|
config.includes.should be_empty
|
15
19
|
config.java_libs.should_not be_empty
|
@@ -21,10 +25,8 @@ describe Warbler::Config do
|
|
21
25
|
|
22
26
|
it "should allow configuration through an initializer block" do
|
23
27
|
config = Warbler::Config.new do |c|
|
24
|
-
c.staging_dir = "/var/tmp"
|
25
28
|
c.war_name = "mywar"
|
26
29
|
end
|
27
|
-
config.staging_dir.should == "/var/tmp"
|
28
30
|
config.war_name.should == "mywar"
|
29
31
|
end
|
30
32
|
|
data/spec/warbler/gems_spec.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
#--
|
2
|
-
# (c)
|
3
|
-
#
|
4
|
-
#
|
2
|
+
# Copyright (c) 2010 Engine Yard, Inc.
|
3
|
+
# Copyright (c) 2007-2009 Sun Microsystems, Inc.
|
4
|
+
# This source code is available under the MIT license.
|
5
|
+
# See the file LICENSE.txt for details.
|
5
6
|
#++
|
6
7
|
|
7
8
|
require File.dirname(__FILE__) + '/../spec_helper'
|
data/spec/warbler/task_spec.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
#--
|
2
|
-
# (c)
|
3
|
-
#
|
4
|
-
#
|
2
|
+
# Copyright (c) 2010 Engine Yard, Inc.
|
3
|
+
# Copyright (c) 2007-2009 Sun Microsystems, Inc.
|
4
|
+
# This source code is available under the MIT license.
|
5
|
+
# See the file LICENSE.txt for details.
|
5
6
|
#++
|
6
7
|
|
7
8
|
require File.dirname(__FILE__) + '/../spec_helper'
|
@@ -16,453 +17,53 @@ describe Warbler::Task do
|
|
16
17
|
mkdir_p "log"
|
17
18
|
touch "log/test.log"
|
18
19
|
@config = Warbler::Config.new do |config|
|
19
|
-
config.staging_dir = "tmp/war"
|
20
20
|
config.war_name = "warbler"
|
21
21
|
config.gems = ["rake"]
|
22
22
|
config.webxml.jruby.max.runtimes = 5
|
23
23
|
end
|
24
|
+
@task = Warbler::Task.new "warble", @config
|
24
25
|
end
|
25
26
|
|
26
27
|
after(:each) do
|
27
|
-
define_tasks "clean"
|
28
28
|
Rake::Task["warble:clean"].invoke
|
29
29
|
rm_rf "log"
|
30
|
-
rm_f FileList["config.ru", "*web.xml", "config/web.xml*", "config/warble.rb"
|
30
|
+
rm_f FileList["config.ru", "*web.xml", "config/web.xml*", "config/warble.rb",
|
31
|
+
"tmp/gems.jar", "file.txt", 'manifest', 'Gemfile']
|
31
32
|
Dir.chdir(@pwd)
|
32
33
|
end
|
33
34
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
tasks.each do |task|
|
38
|
-
unless @defined_tasks.include?(task)
|
39
|
-
meth = "define_#{task}_task"
|
40
|
-
meth = "define_#{task}_tasks" unless Warbler::Task.private_instance_methods.include?(meth)
|
41
|
-
Warbler::Task.new "warble", @config, meth.to_sym do |t|
|
42
|
-
options.each {|k,v| t.send "#{k}=", v }
|
43
|
-
end
|
44
|
-
@defined_tasks << task
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
def file_list(regex)
|
50
|
-
FileList["#{@config.staging_dir}/**/*"].select {|f| f =~ regex }
|
51
|
-
end
|
52
|
-
|
53
|
-
it "should define a clean task for removing the staging directory" do
|
54
|
-
define_tasks "clean"
|
55
|
-
mkdir_p @config.staging_dir
|
35
|
+
it "should define a clean task for removing the war file" do
|
36
|
+
war_file = "#{@config.war_name}.war"
|
37
|
+
touch war_file
|
56
38
|
Rake::Task["warble:clean"].invoke
|
57
|
-
File.exist?(
|
58
|
-
end
|
59
|
-
|
60
|
-
it "should define a public task for copying the public files" do
|
61
|
-
define_tasks "public"
|
62
|
-
Rake::Task["warble:public"].invoke
|
63
|
-
file_list(%r{^#{@config.staging_dir}/index\.html}).should_not be_empty
|
64
|
-
end
|
65
|
-
|
66
|
-
it "should define a gems task for unpacking gems" do
|
67
|
-
@config.gems << "rails"
|
68
|
-
define_tasks "gems"
|
69
|
-
Rake::Task["warble:gems"].invoke
|
70
|
-
file_list(%r{WEB-INF/gems/gems/rake.*/lib/rake.rb}).should_not be_empty
|
71
|
-
file_list(%r{WEB-INF/gems/specifications/rake.*\.gemspec}).should_not be_empty
|
72
|
-
end
|
73
|
-
|
74
|
-
it "should define a app task for copying application files" do
|
75
|
-
define_tasks "app", "gems"
|
76
|
-
Rake::Task["warble:app"].invoke
|
77
|
-
file_list(%r{WEB-INF/log}).should_not be_empty
|
78
|
-
file_list(%r{WEB-INF/log/*.log}).should be_empty
|
79
|
-
end
|
80
|
-
|
81
|
-
def expand_webxml
|
82
|
-
define_tasks "webxml"
|
83
|
-
Rake::Task["warble:webxml"].invoke
|
84
|
-
require 'rexml/document'
|
85
|
-
File.open("#{@config.staging_dir}/WEB-INF/web.xml") do |f|
|
86
|
-
REXML::Document.new(f).root.elements
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
it "should define a webxml task for creating web.xml" do
|
91
|
-
elements = expand_webxml
|
92
|
-
elements.to_a(
|
93
|
-
"context-param/param-name[text()='jruby.max.runtimes']"
|
94
|
-
).should_not be_empty
|
95
|
-
elements.to_a(
|
96
|
-
"context-param/param-name[text()='jruby.max.runtimes']/../param-value"
|
97
|
-
).first.text.should == "5"
|
98
|
-
end
|
99
|
-
|
100
|
-
it "should include custom context parameters" do
|
101
|
-
@config.webxml.some.custom.config = "myconfig"
|
102
|
-
elements = expand_webxml
|
103
|
-
elements.to_a(
|
104
|
-
"context-param/param-name[text()='some.custom.config']"
|
105
|
-
).should_not be_empty
|
106
|
-
elements.to_a(
|
107
|
-
"context-param/param-name[text()='some.custom.config']/../param-value"
|
108
|
-
).first.text.should == "myconfig"
|
109
|
-
end
|
110
|
-
|
111
|
-
it "should allow one jndi resource to be included" do
|
112
|
-
@config.webxml.jndi = 'jndi/rails'
|
113
|
-
elements = expand_webxml
|
114
|
-
elements.to_a(
|
115
|
-
"resource-ref/res-ref-name[text()='jndi/rails']"
|
116
|
-
).should_not be_empty
|
117
|
-
end
|
118
|
-
|
119
|
-
it "should allow multiple jndi resources to be included" do
|
120
|
-
@config.webxml.jndi = ['jndi/rails1', 'jndi/rails2']
|
121
|
-
elements = expand_webxml
|
122
|
-
elements.to_a(
|
123
|
-
"resource-ref/res-ref-name[text()='jndi/rails1']"
|
124
|
-
).should_not be_empty
|
125
|
-
elements.to_a(
|
126
|
-
"resource-ref/res-ref-name[text()='jndi/rails2']"
|
127
|
-
).should_not be_empty
|
128
|
-
end
|
129
|
-
|
130
|
-
it "should not include any ignored context parameters" do
|
131
|
-
@config.webxml.foo = "bar"
|
132
|
-
@config.webxml.ignored << "foo"
|
133
|
-
elements = expand_webxml
|
134
|
-
elements.to_a(
|
135
|
-
"context-param/param-name[text()='foo']"
|
136
|
-
).should be_empty
|
137
|
-
elements.to_a(
|
138
|
-
"context-param/param-name[text()='ignored']"
|
139
|
-
).should be_empty
|
140
|
-
elements.to_a(
|
141
|
-
"context-param/param-name[text()='jndi']"
|
142
|
-
).should be_empty
|
39
|
+
File.exist?(war_file).should == false
|
143
40
|
end
|
144
41
|
|
145
|
-
it "should
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
files = file_list(%r{WEB-INF/web.xml$})
|
151
|
-
files.should_not be_empty
|
152
|
-
File.open(files.first) {|f| f.read}.should == "Hi there"
|
153
|
-
end
|
154
|
-
|
155
|
-
it "should use a config/web.xml.erb if it exists" do
|
156
|
-
define_tasks "webxml"
|
157
|
-
mkdir_p "config"
|
158
|
-
File.open("config/web.xml.erb", "w") {|f| f << "Hi <%= webxml.public.root %>" }
|
159
|
-
Rake::Task["warble:webxml"].invoke
|
160
|
-
files = file_list(%r{WEB-INF/web.xml$})
|
161
|
-
files.should_not be_empty
|
162
|
-
File.open(files.first) {|f| f.read}.should == "Hi /"
|
163
|
-
end
|
164
|
-
|
165
|
-
it "should define a java_libs task for copying java libraries" do
|
166
|
-
define_tasks "java_libs"
|
167
|
-
Rake::Task["warble:java_libs"].invoke
|
168
|
-
file_list(%r{WEB-INF/lib/jruby-.*\.jar$}).should_not be_empty
|
169
|
-
end
|
170
|
-
|
171
|
-
it "should define an app task for copying application files" do
|
172
|
-
gems_ran = false
|
173
|
-
task "warble:gems" do
|
174
|
-
gems_ran = true
|
175
|
-
end
|
176
|
-
define_tasks "app"
|
177
|
-
Rake::Task["warble:app"].invoke
|
178
|
-
file_list(%r{WEB-INF/app$}).should_not be_empty
|
179
|
-
file_list(%r{WEB-INF/config$}).should_not be_empty
|
180
|
-
file_list(%r{WEB-INF/lib$}).should_not be_empty
|
181
|
-
gems_ran.should == true
|
182
|
-
end
|
183
|
-
|
184
|
-
it "should define a jar task for creating the .war" do
|
185
|
-
define_tasks "jar"
|
186
|
-
mkdir_p @config.staging_dir
|
187
|
-
touch "#{@config.staging_dir}/file.txt"
|
188
|
-
Rake::Task["warble:jar"].invoke
|
189
|
-
File.exist?("warbler.war").should == true
|
190
|
-
end
|
191
|
-
|
192
|
-
it "should define an exploded task for creating an exploded Rails app" do
|
193
|
-
@config.java_classes = ["Rakefile"]
|
194
|
-
@config.java_libs = []
|
195
|
-
define_tasks "webxml", "exploded", "java_classes", "gems"
|
196
|
-
Rake::Task['warble:exploded'].invoke
|
197
|
-
File.exist?("web.xml").should == true
|
198
|
-
File.exist?("sun-web.xml").should == true
|
199
|
-
File.symlink?("gems").should == true
|
200
|
-
File.symlink?("public/WEB-INF").should == true
|
201
|
-
Rake::Task['warble:clean:exploded'].invoke
|
202
|
-
end
|
203
|
-
|
204
|
-
it "should accept an autodeploy directory where the war should be created" do
|
205
|
-
define_tasks "jar"
|
206
|
-
require 'tempfile'
|
207
|
-
@config.autodeploy_dir = Dir::tmpdir
|
208
|
-
mkdir_p @config.staging_dir
|
209
|
-
touch "#{@config.staging_dir}/file.txt"
|
210
|
-
Rake::Task["warble:jar"].invoke
|
211
|
-
File.exist?(File.join("#{Dir::tmpdir}","warbler.war")).should == true
|
42
|
+
it "should define a gemjar task for storing gems in a jar file" do
|
43
|
+
silence { Rake::Task["warble:gemjar"].invoke }
|
44
|
+
File.exist?("tmp/gems.jar").should == true
|
45
|
+
@task.war.files.keys.should_not include(%r{WEB-INF\/gems})
|
46
|
+
@task.war.files.keys.should include("WEB-INF/lib/gems.jar")
|
212
47
|
end
|
213
48
|
|
214
49
|
it "should define a war task for bundling up everything" do
|
215
|
-
|
216
|
-
public_ran = false; task "warble:public" do; public_ran = true; end
|
50
|
+
files_ran = false; task "warble:files" do; files_ran = true; end
|
217
51
|
jar_ran = false; task "warble:jar" do; jar_ran = true; end
|
218
|
-
|
219
|
-
|
220
|
-
Rake::Task["warble"].invoke
|
221
|
-
app_ran.should == true
|
222
|
-
public_ran.should == true
|
52
|
+
silence { Rake::Task["warble"].invoke }
|
53
|
+
files_ran.should == true
|
223
54
|
jar_ran.should == true
|
224
|
-
webxml_ran.should == true
|
225
55
|
end
|
226
56
|
|
227
|
-
it "should
|
228
|
-
|
229
|
-
task
|
230
|
-
|
231
|
-
|
232
|
-
file_list(%r{lib/tasks/utils.rake}).should be_empty
|
57
|
+
it "should define a jar task for creating the .war" do
|
58
|
+
touch "file.txt"
|
59
|
+
@task.war.files["file.txt"] = "file.txt"
|
60
|
+
silence { Rake::Task["warble:jar"].invoke }
|
61
|
+
File.exist?("#{@config.war_name}.war").should == true
|
233
62
|
end
|
234
63
|
|
235
64
|
it "should be able to define all tasks successfully" do
|
236
65
|
Warbler::Task.new "warble", @config
|
237
66
|
end
|
238
|
-
|
239
|
-
it "should read configuration from #{Warbler::Config::FILE}" do
|
240
|
-
mkdir_p "config"
|
241
|
-
File.open(Warbler::Config::FILE, "w") do |dest|
|
242
|
-
contents =
|
243
|
-
File.open("#{Warbler::WARBLER_HOME}/generators/warble/templates/warble.rb") do |src|
|
244
|
-
src.read
|
245
|
-
end
|
246
|
-
dest << contents.sub(/# config\.war_name/, 'config.war_name'
|
247
|
-
).sub(/# config.gems << "tzinfo"/, 'config.gems = []')
|
248
|
-
end
|
249
|
-
t = Warbler::Task.new "warble"
|
250
|
-
t.config.war_name.should == "mywar"
|
251
|
-
end
|
252
|
-
|
253
|
-
it "should fail if a gem is requested that is not installed" do
|
254
|
-
@config.gems = ["nonexistent-gem"]
|
255
|
-
lambda {
|
256
|
-
Warbler::Task.new "warble", @config
|
257
|
-
}.should raise_error
|
258
|
-
end
|
259
|
-
|
260
|
-
it "should handle platform-specific gems" do
|
261
|
-
spec = mock "gem spec"
|
262
|
-
spec.stub!(:name).and_return "hpricot"
|
263
|
-
spec.stub!(:version).and_return "0.6.157"
|
264
|
-
spec.stub!(:platform).and_return "java"
|
265
|
-
spec.stub!(:original_platform).and_return "java"
|
266
|
-
spec.stub!(:loaded_from).and_return "hpricot.gemspec"
|
267
|
-
spec.stub!(:dependencies).and_return []
|
268
|
-
Gem.source_index.should_receive(:search).and_return do |gem|
|
269
|
-
gem.name.should == "hpricot"
|
270
|
-
[spec]
|
271
|
-
end
|
272
|
-
File.should_receive(:exist?).with(File.join(Gem.dir, 'cache', "hpricot-0.6.157-java.gem")).and_return true
|
273
|
-
@config.gems = ["hpricot"]
|
274
|
-
define_tasks "gems"
|
275
|
-
end
|
276
|
-
|
277
|
-
it "should allow specification of dependency by Gem::Dependency" do
|
278
|
-
spec = mock "gem spec"
|
279
|
-
spec.stub!(:name).and_return "hpricot"
|
280
|
-
spec.stub!(:version).and_return "0.6.157"
|
281
|
-
spec.stub!(:platform).and_return "java"
|
282
|
-
spec.stub!(:original_platform).and_return "java"
|
283
|
-
spec.stub!(:loaded_from).and_return "hpricot.gemspec"
|
284
|
-
spec.stub!(:dependencies).and_return []
|
285
|
-
Gem.source_index.should_receive(:search).and_return do |gem|
|
286
|
-
gem.name.should == "hpricot"
|
287
|
-
[spec]
|
288
|
-
end
|
289
|
-
File.should_receive(:exist?).with(File.join(Gem.dir, 'cache', "hpricot-0.6.157-java.gem")).and_return true
|
290
|
-
@config.gems = [Gem::Dependency.new("hpricot", "> 0.6")]
|
291
|
-
define_tasks "gems"
|
292
|
-
end
|
293
|
-
|
294
|
-
it "should define a java_classes task for copying loose java classes" do
|
295
|
-
@config.java_classes = FileList["Rakefile"]
|
296
|
-
define_tasks "java_classes"
|
297
|
-
Rake::Task["warble:java_classes"].invoke
|
298
|
-
file_list(%r{WEB-INF/classes/Rakefile$}).should_not be_empty
|
299
|
-
end
|
300
|
-
|
301
|
-
def mock_rails_module
|
302
|
-
rails = Module.new
|
303
|
-
Object.const_set("Rails", rails)
|
304
|
-
version = Module.new
|
305
|
-
rails.const_set("VERSION", version)
|
306
|
-
version.const_set("STRING", "2.1.0")
|
307
|
-
rails
|
308
|
-
end
|
309
|
-
|
310
|
-
def mock_merb_module
|
311
|
-
merb = Module.new
|
312
|
-
Object.const_set("Merb", merb)
|
313
|
-
boot_loader = Module.new
|
314
|
-
merb.const_set("BootLoader", boot_loader)
|
315
|
-
merb.const_set("VERSION", "1.0")
|
316
|
-
dependencies = Class.new do
|
317
|
-
@@dependencies = []
|
318
|
-
def self.dependencies
|
319
|
-
@@dependencies
|
320
|
-
end
|
321
|
-
def self.dependencies=(deps)
|
322
|
-
@@dependencies = deps
|
323
|
-
end
|
324
|
-
end
|
325
|
-
boot_loader.const_set("Dependencies", dependencies)
|
326
|
-
dependencies
|
327
|
-
end
|
328
|
-
|
329
|
-
it "should auto-detect a Rails application" do
|
330
|
-
task :environment do
|
331
|
-
mock_rails_module
|
332
|
-
end
|
333
|
-
@config = Warbler::Config.new
|
334
|
-
@config.webxml.booter.should == :rails
|
335
|
-
@config.gems["rails"].should == "2.1.0"
|
336
|
-
end
|
337
|
-
|
338
|
-
it "should provide Rails gems by default, unless vendor/rails is present" do
|
339
|
-
rails = nil
|
340
|
-
task :environment do
|
341
|
-
rails = mock_rails_module
|
342
|
-
end
|
343
|
-
|
344
|
-
config = Warbler::Config.new
|
345
|
-
config.gems.should have_key("rails")
|
346
|
-
|
347
|
-
mkdir_p "vendor/rails"
|
348
|
-
config = Warbler::Config.new
|
349
|
-
config.gems.should be_empty
|
350
|
-
|
351
|
-
rm_rf "vendor/rails"
|
352
|
-
rails.stub!(:vendor_rails?).and_return true
|
353
|
-
config = Warbler::Config.new
|
354
|
-
config.gems.should be_empty
|
355
|
-
end
|
356
|
-
|
357
|
-
it "should not try to autodetect frameworks when Warbler.framework_detection is false" do
|
358
|
-
begin
|
359
|
-
Warbler.framework_detection = false
|
360
|
-
task :environment
|
361
|
-
config = Warbler::Config.new
|
362
|
-
config.webxml.booter.should_not == :rails
|
363
|
-
t = Rake::Task['environment']
|
364
|
-
class << t; public :instance_variable_get; end
|
365
|
-
t.instance_variable_get("@already_invoked").should == false
|
366
|
-
ensure
|
367
|
-
Warbler.framework_detection = true
|
368
|
-
end
|
369
|
-
end
|
370
|
-
|
371
|
-
it "should auto-detect a Merb application" do
|
372
|
-
task :merb_env do
|
373
|
-
mock_merb_module
|
374
|
-
end
|
375
|
-
@config = Warbler::Config.new
|
376
|
-
@config.webxml.booter.should == :merb
|
377
|
-
@config.gems.keys.should_not include("rails")
|
378
|
-
end
|
379
|
-
|
380
|
-
it "should auto-detect a Rack application with a config.ru file" do
|
381
|
-
rackup = "run Proc.new {|env| [200, {}, ['Hello World']]}"
|
382
|
-
File.open("config.ru", "w") {|f| f << rackup }
|
383
|
-
@config = Warbler::Config.new
|
384
|
-
@config.webxml.booter.should == :rack
|
385
|
-
@config.webxml.rackup.should == rackup
|
386
|
-
end
|
387
|
-
|
388
|
-
it "should automatically add Rails.configuration.gems to the list of gems" do
|
389
|
-
task :environment do
|
390
|
-
rails = mock_rails_module
|
391
|
-
config = mock "config"
|
392
|
-
rails.stub!(:configuration).and_return(config)
|
393
|
-
gem = mock "gem"
|
394
|
-
gem.stub!(:name).and_return "hpricot"
|
395
|
-
gem.stub!(:requirement).and_return Gem::Requirement.new("=0.6")
|
396
|
-
config.stub!(:gems).and_return [gem]
|
397
|
-
end
|
398
|
-
|
399
|
-
@config = Warbler::Config.new
|
400
|
-
@config.webxml.booter.should == :rails
|
401
|
-
@config.gems.keys.should include(Gem::Dependency.new("hpricot", Gem::Requirement.new("=0.6")))
|
402
|
-
end
|
403
|
-
|
404
|
-
it "should automatically add Merb::BootLoader::Dependencies.dependencies to the list of gems" do
|
405
|
-
task :merb_env do
|
406
|
-
deps = mock_merb_module
|
407
|
-
deps.dependencies = [Gem::Dependency.new("merb-core", ">= 1.0.6.1")]
|
408
|
-
end
|
409
|
-
@config = Warbler::Config.new
|
410
|
-
@config.webxml.booter.should == :merb
|
411
|
-
@config.gems.keys.should include(Gem::Dependency.new("merb-core", ">= 1.0.6.1"))
|
412
|
-
end
|
413
|
-
|
414
|
-
it "should skip Merb development dependencies" do
|
415
|
-
task :merb_env do
|
416
|
-
deps = mock_merb_module
|
417
|
-
deps.dependencies = [Gem::Dependency.new("rake", "= #{RAKEVERSION}", :development)]
|
418
|
-
end
|
419
|
-
@config = Warbler::Config.new
|
420
|
-
define_tasks "copy_gems"
|
421
|
-
Rake.application.lookup("gem:rake-#{RAKEVERSION}").should be_nil
|
422
|
-
end
|
423
|
-
|
424
|
-
it "should warn about using Merb < 1.0" do
|
425
|
-
task :merb_env do
|
426
|
-
Object.const_set("Merb", Module.new)
|
427
|
-
end
|
428
|
-
@config = Warbler::Config.new
|
429
|
-
@config.webxml.booter.should == :merb
|
430
|
-
end
|
431
|
-
|
432
|
-
it "should set the jruby max runtimes to 1 when MT Rails is detected" do
|
433
|
-
task :environment do
|
434
|
-
rails = mock_rails_module
|
435
|
-
config = mock "config"
|
436
|
-
rails.stub!(:configuration).and_return(config)
|
437
|
-
config.stub!(:threadsafe!)
|
438
|
-
end
|
439
|
-
@config = Warbler::Config.new
|
440
|
-
@config.webxml.booter.should == :rails
|
441
|
-
@config.webxml.jruby.max.runtimes.should == 1
|
442
|
-
end
|
443
|
-
|
444
|
-
it "should skip directories that don't exist in config.dirs and print a warning" do
|
445
|
-
@config = Warbler::Config.new
|
446
|
-
@config.dirs = %w(lib notexist)
|
447
|
-
define_tasks "webinf_file"
|
448
|
-
Rake.application.lookup("#{@config.staging_dir}/WEB-INF/lib").should_not be_nil
|
449
|
-
Rake.application.lookup("#{@config.staging_dir}/WEB-INF/notexist").should be_nil
|
450
|
-
end
|
451
|
-
end
|
452
|
-
|
453
|
-
describe "The warbler.rake file" do
|
454
|
-
it "should be able to list its contents" do
|
455
|
-
output = `#{FileUtils::RUBY} -S rake -f #{Warbler::WARBLER_HOME}/tasks/warbler.rake -T`
|
456
|
-
output.should =~ /war\s/
|
457
|
-
output.should =~ /war:exploded/
|
458
|
-
output.should =~ /war:app/
|
459
|
-
output.should =~ /war:clean/
|
460
|
-
output.should =~ /war:gems/
|
461
|
-
output.should =~ /war:jar/
|
462
|
-
output.should =~ /war:java_libs/
|
463
|
-
output.should =~ /war:java_classes/
|
464
|
-
output.should =~ /war:public/
|
465
|
-
end
|
466
67
|
end
|
467
68
|
|
468
69
|
describe "Debug targets" do
|
@@ -474,11 +75,6 @@ describe "Debug targets" do
|
|
474
75
|
end
|
475
76
|
|
476
77
|
it "should print out lists of files" do
|
477
|
-
capture { Rake::Task["war:debug:public"].invoke }.should =~ /public/
|
478
|
-
capture { Rake::Task["war:debug:gems"].invoke }.should =~ /gems/
|
479
|
-
capture { Rake::Task["war:debug:java_libs"].invoke }.should =~ /java_libs/
|
480
|
-
capture { Rake::Task["war:debug:java_classes"].invoke }.should =~ /java_classes/
|
481
|
-
capture { Rake::Task["war:debug:app"].invoke }.should =~ /app/
|
482
78
|
capture { Rake::Task["war:debug:includes"].invoke }.should =~ /include/
|
483
79
|
capture { Rake::Task["war:debug:excludes"].invoke }.should =~ /exclude/
|
484
80
|
capture { Rake::Task["war:debug"].invoke }.should =~ /Config/
|