jettywrapper 1.5.1 → 1.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jettywrapper.rb +3 -1
- data/lib/jettywrapper/version.rb +1 -1
- data/spec/lib/jettywrapper_spec.rb +22 -14
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3a613e5aa0a63b38a1e25e7d87e1230b12615893
|
4
|
+
data.tar.gz: 1e9c07594df4c1cbbaf652d38eda69b8e4ce4104
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff59581c3305d9f8a77198c58ac79c3d9653a37ac2945cdce5bc751084cde6298cb4d120b13c1ba66be7798499f0ffd55eee14dc2a131f31cae3215581f1256b
|
7
|
+
data.tar.gz: 62878ce4da7dfd256133f8aa5e5c0f5e38f565deef13fca8f7262f729f906c36b25ac2ff1705c7cec31f288559040586b4eb2c7c90a40ce4ceafa83d4b200dd5
|
data/lib/jettywrapper.rb
CHANGED
@@ -98,6 +98,7 @@ class Jettywrapper
|
|
98
98
|
|
99
99
|
def reset_config
|
100
100
|
@app_root = nil
|
101
|
+
@env = nil
|
101
102
|
@url = nil
|
102
103
|
@hydra_jetty_version = nil
|
103
104
|
end
|
@@ -110,10 +111,11 @@ class Jettywrapper
|
|
110
111
|
end
|
111
112
|
|
112
113
|
def env
|
113
|
-
defined?(Rails) ? Rails.env : ENV['environment']
|
114
|
+
@env ||= defined?(Rails) ? Rails.env : ENV['environment'] || 'development'
|
114
115
|
end
|
115
116
|
|
116
117
|
def load_config(config_name = env)
|
118
|
+
@env = config_name
|
117
119
|
jetty_file = "#{app_root}/config/jetty.yml"
|
118
120
|
|
119
121
|
unless File.exists?(jetty_file)
|
data/lib/jettywrapper/version.rb
CHANGED
@@ -18,11 +18,11 @@ require 'rubygems'
|
|
18
18
|
Jettywrapper.logger.level=3
|
19
19
|
end
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
end
|
21
|
+
before do
|
22
|
+
Jettywrapper.reset_config
|
23
|
+
end
|
25
24
|
|
25
|
+
context "downloading" do
|
26
26
|
context "with default file" do
|
27
27
|
it "should download the zip file" do
|
28
28
|
Jettywrapper.should_receive(:system).with('curl -L https://github.com/projecthydra/hydra-jetty/archive/v7.0.0.zip -o tmp/v7.0.0.zip').and_return(system ('true'))
|
@@ -122,7 +122,6 @@ require 'rubygems'
|
|
122
122
|
subject {Jettywrapper}
|
123
123
|
context "When rails is present" do
|
124
124
|
before do
|
125
|
-
Jettywrapper.reset_config
|
126
125
|
class Rails
|
127
126
|
def self.root
|
128
127
|
'rails_root'
|
@@ -131,7 +130,6 @@ require 'rubygems'
|
|
131
130
|
end
|
132
131
|
after do
|
133
132
|
Object.send(:remove_const, :Rails)
|
134
|
-
Jettywrapper.reset_config
|
135
133
|
end
|
136
134
|
its(:app_root) {should == 'rails_root'}
|
137
135
|
end
|
@@ -141,7 +139,6 @@ require 'rubygems'
|
|
141
139
|
end
|
142
140
|
after do
|
143
141
|
Object.send(:remove_const, :APP_ROOT)
|
144
|
-
Jettywrapper.reset_config
|
145
142
|
end
|
146
143
|
its(:app_root) {should == 'custom_root'}
|
147
144
|
end
|
@@ -151,6 +148,8 @@ require 'rubygems'
|
|
151
148
|
end
|
152
149
|
|
153
150
|
context "config" do
|
151
|
+
before do
|
152
|
+
end
|
154
153
|
it "loads the application jetty.yml first" do
|
155
154
|
IO.should_receive(:read).with('./config/jetty.yml').and_return("default:\n")
|
156
155
|
config = Jettywrapper.load_config
|
@@ -175,10 +174,11 @@ require 'rubygems'
|
|
175
174
|
config[:a].should == 2
|
176
175
|
end
|
177
176
|
|
178
|
-
it "should take the env as an argument to load_config" do
|
177
|
+
it "should take the env as an argument to load_config and the env should be sticky" do
|
179
178
|
IO.should_receive(:read).with('./config/jetty.yml').and_return("default:\n a: 1\nfoo:\n a: 2")
|
180
179
|
config = Jettywrapper.load_config('foo')
|
181
180
|
config[:a].should == 2
|
181
|
+
expect(Jettywrapper.env).to eq 'foo'
|
182
182
|
end
|
183
183
|
|
184
184
|
it "falls back on a 'default' environment configuration" do
|
@@ -265,9 +265,6 @@ require 'rubygems'
|
|
265
265
|
swp.stop
|
266
266
|
end
|
267
267
|
|
268
|
-
it "checks to see if its pid files are stale"
|
269
|
-
|
270
|
-
# return true if it's running, otherwise return false
|
271
268
|
it "can get the status for a given jetty instance" do
|
272
269
|
# Don't actually start jetty, just fake it
|
273
270
|
Jettywrapper.any_instance.stub(:process).and_return(double('proc', :start => nil, :pid=>12345))
|
@@ -307,9 +304,20 @@ require 'rubygems'
|
|
307
304
|
(File.file? swp.pid_path).should eql(false)
|
308
305
|
end
|
309
306
|
|
310
|
-
|
311
|
-
ts
|
312
|
-
|
307
|
+
describe "creates a pid file" do
|
308
|
+
let(:ts) { Jettywrapper.configure(@jetty_params) }
|
309
|
+
describe "when the environment isn't set" do
|
310
|
+
before { ENV['environment'] = nil }
|
311
|
+
it "should have the path and env in the name" do
|
312
|
+
ts.pid_file.should eql("_path_to_jetty_development.pid")
|
313
|
+
end
|
314
|
+
end
|
315
|
+
describe "when the environment is set" do
|
316
|
+
before { ENV['environment'] = 'test' }
|
317
|
+
it "should have the path and env in the name" do
|
318
|
+
ts.pid_file.should eql("_path_to_jetty_test.pid")
|
319
|
+
end
|
320
|
+
end
|
313
321
|
end
|
314
322
|
|
315
323
|
it "knows where its pid file should be written" do
|