jettywrapper 2.0.0 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 90d0380f37306e0ca328c5a86d1dd304c7141e65
4
- data.tar.gz: 8ee2ed933249ff1a268575048a1d920040566e0e
3
+ metadata.gz: bd615b5894ae53105f6abfebb4631fb96d99530e
4
+ data.tar.gz: 67aa692a2180259b925218c854701a6077200e92
5
5
  SHA512:
6
- metadata.gz: a6c80ca97aa9f89f0c76882557f957596735b2f48dd923960a8e5afc68ed47ecf1b1072385a2a56a1e4038d3f1437dbe37262301b352d3470fc5dcbcf944393a
7
- data.tar.gz: 8d82e591a1cd4d1a70ad37f449e88ad55dcd79744815b23f457b2d525da5e246b56af77ddc517b450a7f63a1901420c6ae1fe0756ee4a5f76f12bbafd731b71f
6
+ metadata.gz: c1689a3e0d63505018f1824196872b179a83110adf2bb328e5e439d48f3eb60d3b9d7103fe876acd1e7ea53e3fb128160695111a7dae46a2ef641a42f59d4566
7
+ data.tar.gz: 65aa972099f95f6afb84101f425b7b1d0c1554f0b94687623e5616f1668f887b551f9f6cf41a4b22c77ee4af1693d8197a26cac6a75569e174510d5313715c06
@@ -5,11 +5,13 @@ matrix:
5
5
  - rvm: 2.1
6
6
  gemfile: gemfiles/rails4.1.gemfile
7
7
  - rvm: 2.1
8
- gemfile: gemfiles/rails4.2.beta.gemfile
8
+ gemfile: gemfiles/rails4.2.gemfile
9
9
  - rvm: 2.0
10
- gemfile: gemfiles/rails4.1.gemfile
10
+ gemfile: gemfiles/rails4.2.gemfile
11
11
  - rvm: 1.9.3
12
12
  gemfile: gemfiles/rails4.1.gemfile
13
+ - rvm: jruby-19mode
14
+ gemfile: gemfiles/rails4.2.gemfile
13
15
 
14
16
  notifications:
15
17
  irc: "irc.freenode.org#projecthydra"
data/Gemfile CHANGED
@@ -2,6 +2,4 @@ source "http://rubygems.org"
2
2
 
3
3
  gemspec path: File.expand_path('..', __FILE__)
4
4
 
5
- gem 'rcov', :platform => :mri_18
6
- gem 'simplecov', :platform => :mri_19
7
- gem 'simplecov-rcov', :platform => :mri_19
5
+ gem 'simplecov'
@@ -7,4 +7,4 @@ if File.exists?(file)
7
7
  instance_eval File.read(file)
8
8
  end
9
9
 
10
- gem 'activesupport', '~> 4.2.0.beta2'
10
+ gem 'activesupport', '~> 4.2.0'
@@ -16,20 +16,19 @@ Gem::Specification.new do |s|
16
16
  s.test_files = `git ls-files -- {spec}/*`.split("\n")
17
17
  s.require_paths = ["lib"]
18
18
  s.license = 'APACHE2'
19
-
19
+
20
20
  s.required_rubygems_version = ">= 1.3.6"
21
-
21
+
22
22
  s.add_dependency "logger"
23
23
  s.add_dependency "childprocess"
24
24
  s.add_dependency "i18n"
25
25
  s.add_dependency "activesupport", ">=3.0.0"
26
-
27
- s.add_development_dependency "rspec", '~> 2.99'
26
+ s.add_dependency 'rubyzip'
27
+
28
+ s.add_development_dependency "rspec", '~> 3.2'
28
29
  s.add_development_dependency "rspec-its"
29
30
  s.add_development_dependency 'rake'
30
-
31
- s.add_development_dependency 'yard'#, '0.6.5' # Yard > 0.6.5 won't generate docs.
32
- # I don't know why & don't have time to
33
- # debug it right now
31
+
32
+ s.add_development_dependency 'yard'
34
33
  end
35
34
 
@@ -9,6 +9,8 @@ require 'active_support/core_ext/hash'
9
9
  require 'erb'
10
10
  require 'yaml'
11
11
  require 'logger'
12
+ require 'open-uri'
13
+ require 'zip'
12
14
 
13
15
  Dir[File.expand_path(File.join(File.dirname(__FILE__),"tasks/*.rake"))].each { |ext| load ext } if defined?(Rake)
14
16
 
@@ -32,6 +34,7 @@ class Jettywrapper
32
34
  self.base_path = self.class.app_root
33
35
  end
34
36
 
37
+
35
38
  # Methods inside of the class << self block can be called directly on Jettywrapper, as class methods.
36
39
  # Methods outside the class << self block must be called on Jettywrapper.instance, as instance methods.
37
40
  class << self
@@ -64,24 +67,43 @@ class Jettywrapper
64
67
  self.url = url if url
65
68
  logger.info "Downloading jetty at #{self.url} ..."
66
69
  FileUtils.mkdir tmp_dir unless File.exists? tmp_dir
67
- system "curl -L #{self.url} -o #{zip_file}"
68
- abort "Unable to download jetty from #{self.url}" unless $?.success?
70
+
71
+ begin
72
+ open(self.url) do |io|
73
+ IO.copy_stream(io,zip_file)
74
+ end
75
+ rescue Exception => e
76
+ abort "Unable to download jetty from #{self.url} #{e.message}"
77
+ end
69
78
  end
70
79
 
71
80
  def unzip
72
81
  download unless File.exists? zip_file
73
82
  logger.info "Unpacking #{zip_file}..."
74
83
  tmp_save_dir = File.join tmp_dir, 'jetty_generator'
75
- system "unzip -d #{tmp_save_dir} -qo #{zip_file}"
76
- abort "Unable to unzip #{zip_file} into tmp_save_dir/" unless $?.success?
84
+ begin
85
+ Zip::File.open(zip_file) do |zip_file|
86
+ # Handle entries one by one
87
+ zip_file.each do |entry|
88
+ dest_file = File.join(tmp_save_dir,entry.name)
89
+ FileUtils.remove_entry(dest_file,true)
90
+ entry.extract(dest_file)
91
+ end
92
+ end
93
+ rescue Exception => e
94
+ abort "Unable to unzip #{zip_file} into tmp_save_dir/ #{e.message}"
95
+ end
77
96
 
78
97
  # Remove the old jetty directory if it exists
79
- system "rm -r #{jetty_dir}" if File.directory?(jetty_dir)
98
+ FileUtils.remove_dir(jetty_dir,true)
80
99
 
81
100
  # Move the expanded zip file into the final destination.
82
101
  expanded_dir = expanded_zip_dir(tmp_save_dir)
83
- system "mv #{expanded_dir} #{jetty_dir}"
84
- abort "Unable to move #{expanded_dir} into #{jetty_dir}/" unless $?.success?
102
+ begin
103
+ FileUtils.mv(expanded_dir, jetty_dir)
104
+ rescue Exception => e
105
+ abort "Unable to move #{expanded_dir} into #{jetty_dir}/ #{e.message}"
106
+ end
85
107
  end
86
108
 
87
109
  def expanded_zip_dir(tmp_save_dir)
@@ -91,7 +113,7 @@ class Jettywrapper
91
113
  end
92
114
 
93
115
  def clean
94
- system "rm -rf #{jetty_dir}"
116
+ FileUtils.remove_dir(jetty_dir,true)
95
117
  unzip
96
118
  end
97
119
 
@@ -1,3 +1,3 @@
1
1
  class Jettywrapper
2
- VERSION = "2.0.0"
2
+ VERSION = "2.0.2"
3
3
  end
@@ -26,12 +26,12 @@ module Hydra
26
26
  ts.start
27
27
  ts.logger.debug "Jetty started from rspec at #{ts.pid}"
28
28
  pid_from_file = File.open( ts.pid_path ) { |f| f.gets.to_i }
29
- ts.pid.should eql(pid_from_file)
29
+ expect(ts.pid).to eql(pid_from_file)
30
30
 
31
31
  # Can we connect to solr?
32
32
  require 'net/http'
33
33
  response = Net::HTTP.get_response(URI.parse("http://localhost:#{jetty_params[:jetty_port]}/solr/"))
34
- response.code.should eql("200")
34
+ expect(response.code).to eql("200")
35
35
  ts.stop
36
36
 
37
37
  end
@@ -50,8 +50,8 @@ module Hydra
50
50
  ts.start
51
51
  ts.logger.debug "Jetty started from rspec at #{ts.pid}"
52
52
  response = Net::HTTP.get_response(URI.parse("http://localhost:#{jetty_params[:jetty_port]}/solr/"))
53
- response.code.should eql("200")
54
- lambda { ts.start }.should raise_exception(/Server is already running/)
53
+ expect(response.code).to eql("200")
54
+ expect { ts.start }.to raise_exception(/Server is already running/)
55
55
  ts.stop
56
56
  end
57
57
 
@@ -64,11 +64,11 @@ module Hydra
64
64
  @s.close
65
65
  end
66
66
  it "can check to see whether a port is already in use" do
67
- Jettywrapper.is_port_in_use?(TEST_JETTY_PORTS.last).should eql(true)
67
+ expect(Jettywrapper.is_port_in_use?(TEST_JETTY_PORTS.last)).to eql(true)
68
68
  end
69
69
  end
70
70
  it "should be false when nothing is running" do
71
- Jettywrapper.is_port_in_use?(TEST_JETTY_PORTS.last).should eql(false)
71
+ expect(Jettywrapper.is_port_in_use?(TEST_JETTY_PORTS.last)).to eql(false)
72
72
  end
73
73
  end
74
74
 
@@ -80,9 +80,9 @@ module Hydra
80
80
  }
81
81
  ts = Jettywrapper.configure(jetty_params)
82
82
  ts.stop
83
- ts.pid_file?.should eql(false)
83
+ expect(ts.pid_file?).to eql(false)
84
84
  ts.start
85
- lambda{ ts.start }.should raise_exception
85
+ expect{ ts.start }.to raise_exception
86
86
  ts.stop
87
87
  end
88
88
 
@@ -96,8 +96,8 @@ module Hydra
96
96
  begin
97
97
  ts = Jettywrapper.configure(jetty_params)
98
98
  ts.stop
99
- ts.pid_file?.should eql(false)
100
- lambda{ ts.start }.should raise_exception
99
+ expect(ts.pid_file?).to eql(false)
100
+ expect{ ts.start }.to raise_exception
101
101
  ts.stop
102
102
  ensure
103
103
  socket.close
@@ -21,27 +21,27 @@ require 'fileutils'
21
21
 
22
22
  before do
23
23
  Jettywrapper.reset_config
24
+ FileUtils.rm "tmp/v8.1.1.zip", force: true
24
25
  end
25
26
 
26
27
  context "downloading" do
27
28
  context "with default file" do
28
29
  it "should download the zip file" do
29
- FileUtils.rm "tmp/v8.1.1.zip", force: true
30
- Jettywrapper.should_receive(:system).with('curl -L https://github.com/projecthydra/hydra-jetty/archive/v8.1.1.zip -o tmp/v8.1.1.zip').and_return(system ('true'))
30
+ expect(Jettywrapper).to receive(:open).with('https://github.com/projecthydra/hydra-jetty/archive/v8.1.1.zip').and_return(system ('true'))
31
31
  Jettywrapper.download
32
32
  end
33
33
  end
34
34
 
35
35
  context "specifying the file" do
36
36
  it "should download the zip file" do
37
- Jettywrapper.should_receive(:system).with('curl -L http://example.co/file.zip -o tmp/file.zip').and_return(system ('true'))
37
+ expect(Jettywrapper).to receive(:open).with('http://example.co/file.zip').and_return(system ('true'))
38
38
  Jettywrapper.download('http://example.co/file.zip')
39
- Jettywrapper.url.should == 'http://example.co/file.zip'
39
+ expect(Jettywrapper.url).to eq('http://example.co/file.zip')
40
40
  end
41
41
  end
42
42
  context "specifying the version" do
43
43
  it "should download the zip file" do
44
- Jettywrapper.should_receive(:system).with('curl -L https://github.com/projecthydra/hydra-jetty/archive/v9.9.9.zip -o tmp/v9.9.9.zip').and_return(system ('true'))
44
+ expect(Jettywrapper).to receive(:open).with('https://github.com/projecthydra/hydra-jetty/archive/v9.9.9.zip').and_return(system ('true'))
45
45
  Jettywrapper.hydra_jetty_version = 'v9.9.9'
46
46
  Jettywrapper.download
47
47
  end
@@ -54,11 +54,11 @@ require 'fileutils'
54
54
  end
55
55
  context "with default file" do
56
56
  it "should download the zip file" do
57
- File.should_receive(:exists?).and_return(true)
58
- Jettywrapper.should_receive(:expanded_zip_dir).and_return('tmp/jetty_generator/hydra-jetty-v8.1.1')
59
- Jettywrapper.should_receive(:system).with('unzip -d tmp/jetty_generator -qo tmp/v8.1.1.zip').and_return(system ('true'))
60
- Jettywrapper.should_receive(:system).with('rm -r jetty').and_return(system ('true'))
61
- Jettywrapper.should_receive(:system).with('mv tmp/jetty_generator/hydra-jetty-v8.1.1 jetty').and_return(system ('true'))
57
+ expect(File).to receive(:exists?).and_return(true)
58
+ expect(Jettywrapper).to receive(:expanded_zip_dir).and_return('tmp/jetty_generator/interal_dir')
59
+ expect(Zip::File).to receive(:open).with('tmp/v8.1.1.zip').and_return(true)
60
+ expect(FileUtils).to receive(:remove_dir).with('jetty',true).and_return(true)
61
+ expect(FileUtils).to receive(:mv).with('tmp/jetty_generator/interal_dir','jetty').and_return(true)
62
62
  Jettywrapper.unzip
63
63
  end
64
64
  end
@@ -68,11 +68,11 @@ require 'fileutils'
68
68
  Jettywrapper.url = 'http://example.co/file.zip'
69
69
  end
70
70
  it "should download the zip file" do
71
- File.should_receive(:exists?).and_return(true)
72
- Jettywrapper.should_receive(:expanded_zip_dir).and_return('tmp/jetty_generator/interal_dir')
73
- Jettywrapper.should_receive(:system).with('unzip -d tmp/jetty_generator -qo tmp/file.zip').and_return(system ('true'))
74
- Jettywrapper.should_receive(:system).with('rm -r jetty').and_return(system ('true'))
75
- Jettywrapper.should_receive(:system).with('mv tmp/jetty_generator/interal_dir jetty').and_return(system ('true'))
71
+ expect(File).to receive(:exists?).and_return(true)
72
+ expect(Jettywrapper).to receive(:expanded_zip_dir).and_return('tmp/jetty_generator/interal_dir')
73
+ expect(Zip::File).to receive(:open).with('tmp/file.zip').and_return(true)
74
+ expect(FileUtils).to receive(:remove_dir).with('jetty',true).and_return(true)
75
+ expect(FileUtils).to receive(:mv).with('tmp/jetty_generator/interal_dir','jetty').and_return(true)
76
76
  Jettywrapper.unzip
77
77
  end
78
78
  end
@@ -187,6 +187,7 @@ require 'fileutils'
187
187
  it "should be the Rails environment" do
188
188
  Rails = double(env: 'test')
189
189
  expect(Jettywrapper.env).to eq "test"
190
+ Rails = nil
190
191
  end
191
192
 
192
193
  it "should use the ENV['RAILS_ENV']" do
@@ -210,58 +211,58 @@ require 'fileutils'
210
211
  before do
211
212
  end
212
213
  it "loads the application jetty.yml first" do
213
- IO.should_receive(:read).with('./config/jetty.yml').and_return("default:\n")
214
+ expect(IO).to receive(:read).with('./config/jetty.yml').and_return("default:\n")
214
215
  config = Jettywrapper.load_config
215
216
  end
216
217
 
217
218
  it "loads the application jetty.yml using erb parsing" do
218
- IO.should_receive(:read).with('./config/jetty.yml').and_return("default:\n a: <%= 123 %>")
219
+ expect(IO).to receive(:read).with('./config/jetty.yml').and_return("default:\n a: <%= 123 %>")
219
220
  config = Jettywrapper.load_config
220
221
  config[:a] == 123
221
222
  end
222
223
 
223
224
  it "falls back on the distributed jetty.yml" do
224
- File.should_receive(:exists?).with('./config/jetty.yml').and_return(false)
225
- IO.should_receive(:read).with { |value| value =~ /jetty.yml/ }.and_return("default:\n")
225
+ expect(File).to receive(:exists?).with('./config/jetty.yml').and_return(false)
226
+ expect(IO).to receive(:read).with(/jetty.yml/).and_return("default:\n")
226
227
  config = Jettywrapper.load_config
227
228
  end
228
229
 
229
230
  it "supports per-environment configuration" do
230
231
  ENV['environment'] = 'test'
231
- IO.should_receive(:read).with('./config/jetty.yml').and_return("default:\n a: 1\ntest:\n a: 2")
232
+ expect(IO).to receive(:read).with('./config/jetty.yml').and_return("default:\n a: 1\ntest:\n a: 2")
232
233
  config = Jettywrapper.load_config
233
- config[:a].should == 2
234
+ expect(config[:a]).to eq(2)
234
235
  end
235
236
 
236
237
  it "should take the env as an argument to load_config and the env should be sticky" do
237
- IO.should_receive(:read).with('./config/jetty.yml').and_return("default:\n a: 1\nfoo:\n a: 2")
238
+ expect(IO).to receive(:read).with('./config/jetty.yml').and_return("default:\n a: 1\nfoo:\n a: 2")
238
239
  config = Jettywrapper.load_config('foo')
239
- config[:a].should == 2
240
+ expect(config[:a]).to eq(2)
240
241
  expect(Jettywrapper.env).to eq 'foo'
241
242
  end
242
243
 
243
244
  it "falls back on a 'default' environment configuration" do
244
245
  ENV['environment'] = 'test'
245
- IO.should_receive(:read).with('./config/jetty.yml').and_return("default:\n a: 1")
246
+ expect(IO).to receive(:read).with('./config/jetty.yml').and_return("default:\n a: 1")
246
247
  config = Jettywrapper.load_config
247
- config[:a].should == 1
248
+ expect(config[:a]).to eq(1)
248
249
  end
249
250
  end
250
251
 
251
252
  context "instantiation" do
252
253
  it "can be instantiated" do
253
254
  ts = Jettywrapper.instance
254
- ts.class.should eql(Jettywrapper)
255
+ expect(ts.class).to eql(Jettywrapper)
255
256
  end
256
257
 
257
258
  it "can be configured with a params hash" do
258
259
  ts = Jettywrapper.configure(@jetty_params)
259
- ts.quiet.should == false
260
- ts.jetty_home.should == "/path/to/jetty"
261
- ts.port.should == @jetty_params[:jetty_port]
262
- ts.solr_home.should == '/path/to/solr'
263
- ts.startup_wait.should == 0
264
- ts.jetty_opts.should == @jetty_params[:jetty_opts]
260
+ expect(ts.quiet).to eq(false)
261
+ expect(ts.jetty_home).to eq("/path/to/jetty")
262
+ expect(ts.port).to eq(@jetty_params[:jetty_port])
263
+ expect(ts.solr_home).to eq('/path/to/solr')
264
+ expect(ts.startup_wait).to eq(0)
265
+ expect(ts.jetty_opts).to eq(@jetty_params[:jetty_opts])
265
266
  end
266
267
 
267
268
  it "should override nil params with defaults" do
@@ -275,28 +276,28 @@ require 'fileutils'
275
276
  }
276
277
 
277
278
  ts = Jettywrapper.configure(jetty_params)
278
- ts.quiet.should == true
279
- ts.jetty_home.should == "/path/to/jetty"
280
- ts.port.should == 8888
281
- ts.solr_home.should == File.join(ts.jetty_home, "solr")
282
- ts.startup_wait.should == 5
283
- ts.jetty_opts.should == []
279
+ expect(ts.quiet).to eq(true)
280
+ expect(ts.jetty_home).to eq("/path/to/jetty")
281
+ expect(ts.port).to eq(8888)
282
+ expect(ts.solr_home).to eq(File.join(ts.jetty_home, "solr"))
283
+ expect(ts.startup_wait).to eq(5)
284
+ expect(ts.jetty_opts).to eq([])
284
285
  end
285
286
 
286
287
  it "passes all the expected values to jetty during startup" do
287
288
  ts = Jettywrapper.configure(@jetty_params)
288
289
  command = ts.jetty_command
289
- command.should include("-Dsolr.solr.home=#{@jetty_params[:solr_home]}")
290
- command.should include("-Djetty.port=#{@jetty_params[:jetty_port]}")
291
- command.should include("-Xmx256m")
292
- command.should include("start.jar")
293
- command.slice(command.index('start.jar')+1, 2).should == @jetty_params[:jetty_opts]
290
+ expect(command).to include("-Dsolr.solr.home=#{@jetty_params[:solr_home]}")
291
+ expect(command).to include("-Djetty.port=#{@jetty_params[:jetty_port]}")
292
+ expect(command).to include("-Xmx256m")
293
+ expect(command).to include("start.jar")
294
+ expect(command.slice(command.index('start.jar')+1, 2)).to eq(@jetty_params[:jetty_opts])
294
295
  end
295
296
 
296
297
  it "escapes the :solr_home parameter" do
297
298
  ts = Jettywrapper.configure(@jetty_params.merge(:solr_home => '/path with spaces/to/solr'))
298
299
  command = ts.jetty_command
299
- command.should include("-Dsolr.solr.home=/path\\ with\\ spaces/to/solr")
300
+ expect(command).to include("-Dsolr.solr.home=/path\\ with\\ spaces/to/solr")
300
301
  end
301
302
 
302
303
  it "has a pid if it has been started" do
@@ -304,10 +305,10 @@ require 'fileutils'
304
305
  :jetty_home => '/tmp'
305
306
  }
306
307
  ts = Jettywrapper.configure(jetty_params)
307
- Jettywrapper.any_instance.stub(:process).and_return(double('proc', :start => nil, :pid=>5454))
308
+ allow_any_instance_of(Jettywrapper).to receive(:process).and_return(double('proc', :start => nil, :pid=>5454))
308
309
  ts.stop
309
310
  ts.start
310
- ts.pid.should eql(5454)
311
+ expect(ts.pid).to eql(5454)
311
312
  ts.stop
312
313
  end
313
314
 
@@ -317,37 +318,37 @@ require 'fileutils'
317
318
  }
318
319
  ts = Jettywrapper.configure(jetty_params)
319
320
  ts.stop
320
- Jettywrapper.any_instance.stub(:process).and_return(double('proc', :start => nil, :pid=>2323))
321
+ allow_any_instance_of(Jettywrapper).to receive(:process).and_return(double('proc', :start => nil, :pid=>2323))
321
322
  swp = Jettywrapper.start(jetty_params)
322
- swp.pid.should eql(2323)
323
- swp.pid_file.should eql("_tmp_test.pid")
323
+ expect(swp.pid).to eql(2323)
324
+ expect(swp.pid_file).to eql("_tmp_test.pid")
324
325
  swp.stop
325
326
  end
326
327
 
327
328
  it "can get the status for a given jetty instance" do
328
329
  # Don't actually start jetty, just fake it
329
- Jettywrapper.any_instance.stub(:process).and_return(double('proc', :start => nil, :pid=>12345))
330
+ allow_any_instance_of(Jettywrapper).to receive(:process).and_return(double('proc', :start => nil, :pid=>12345))
330
331
 
331
332
  jetty_params = {
332
333
  :jetty_home => File.expand_path("#{File.dirname(__FILE__)}/../../jetty")
333
334
  }
334
335
  Jettywrapper.stop(jetty_params)
335
- Jettywrapper.is_jetty_running?(jetty_params).should eql(false)
336
+ expect(Jettywrapper.is_jetty_running?(jetty_params)).to eql(false)
336
337
  Jettywrapper.start(jetty_params)
337
- Jettywrapper.is_jetty_running?(jetty_params).should eql(true)
338
+ expect(Jettywrapper.is_jetty_running?(jetty_params)).to eql(true)
338
339
  Jettywrapper.stop(jetty_params)
339
340
  end
340
341
 
341
342
  it "can get the pid for a given jetty instance" do
342
343
  # Don't actually start jetty, just fake it
343
- Jettywrapper.any_instance.stub(:process).and_return(double('proc', :start => nil, :pid=>54321))
344
+ allow_any_instance_of(Jettywrapper).to receive(:process).and_return(double('proc', :start => nil, :pid=>54321))
344
345
  jetty_params = {
345
346
  :jetty_home => File.expand_path("#{File.dirname(__FILE__)}/../../jetty")
346
347
  }
347
348
  Jettywrapper.stop(jetty_params)
348
- Jettywrapper.pid(jetty_params).should eql(nil)
349
+ expect(Jettywrapper.pid(jetty_params)).to eql(nil)
349
350
  Jettywrapper.start(jetty_params)
350
- Jettywrapper.pid(jetty_params).should eql(54321)
351
+ expect(Jettywrapper.pid(jetty_params)).to eql(54321)
351
352
  Jettywrapper.stop(jetty_params)
352
353
  end
353
354
 
@@ -355,12 +356,12 @@ require 'fileutils'
355
356
  jetty_params = {
356
357
  :jetty_home => '/tmp', :jetty_port => 8777
357
358
  }
358
- Jettywrapper.any_instance.stub(:process).and_return(double('proc', :start => nil, :pid=>2323))
359
+ allow_any_instance_of(Jettywrapper).to receive(:process).and_return(double('proc', :start => nil, :pid=>2323))
359
360
  swp = Jettywrapper.start(jetty_params)
360
- (File.file? swp.pid_path).should eql(true)
361
+ expect(File.file? swp.pid_path).to eql(true)
361
362
 
362
363
  swp = Jettywrapper.stop(jetty_params)
363
- (File.file? swp.pid_path).should eql(false)
364
+ expect(File.file? swp.pid_path).to eql(false)
364
365
  end
365
366
 
366
367
  describe "creates a pid file" do
@@ -368,20 +369,20 @@ require 'fileutils'
368
369
  describe "when the environment isn't set" do
369
370
  before { ENV['environment'] = nil }
370
371
  it "should have the path and env in the name" do
371
- ts.pid_file.should eql("_path_to_jetty_development.pid")
372
+ expect(ts.pid_file).to eql("_path_to_jetty_development.pid")
372
373
  end
373
374
  end
374
375
  describe "when the environment is set" do
375
376
  before { ENV['environment'] = 'test' }
376
377
  it "should have the path and env in the name" do
377
- ts.pid_file.should eql("_path_to_jetty_test.pid")
378
+ expect(ts.pid_file).to eql("_path_to_jetty_test.pid")
378
379
  end
379
380
  end
380
381
  end
381
382
 
382
383
  it "knows where its pid file should be written" do
383
384
  ts = Jettywrapper.configure(@jetty_params)
384
- ts.pid_dir.should eql(File.expand_path("#{ts.base_path}/tmp/pids"))
385
+ expect(ts.pid_dir).to eql(File.expand_path("#{ts.base_path}/tmp/pids"))
385
386
  end
386
387
 
387
388
  it "writes a pid to a file when it is started" do
@@ -389,14 +390,14 @@ require 'fileutils'
389
390
  :jetty_home => '/tmp'
390
391
  }
391
392
  ts = Jettywrapper.configure(jetty_params)
392
- Jettywrapper.any_instance.stub(:process).and_return(double('proc', :start => nil, :pid=>2222))
393
+ allow_any_instance_of(Jettywrapper).to receive(:process).and_return(double('proc', :start => nil, :pid=>2222))
393
394
  ts.stop
394
- ts.pid_file?.should eql(false)
395
+ expect(ts.pid_file?).to eql(false)
395
396
  ts.start
396
- ts.pid.should eql(2222)
397
- ts.pid_file?.should eql(true)
397
+ expect(ts.pid).to eql(2222)
398
+ expect(ts.pid_file?).to eql(true)
398
399
  pid_from_file = File.open( ts.pid_path ) { |f| f.gets.to_i }
399
- pid_from_file.should eql(2222)
400
+ expect(pid_from_file).to eql(2222)
400
401
  end
401
402
 
402
403
  end # end of instantiation context
@@ -404,38 +405,38 @@ require 'fileutils'
404
405
  context "logging" do
405
406
  it "has a logger" do
406
407
  ts = Jettywrapper.configure(@jetty_params)
407
- ts.logger.should be_kind_of(Logger)
408
+ expect(ts.logger).to be_kind_of(Logger)
408
409
  end
409
410
 
410
411
  end # end of logging context
411
412
 
412
413
  context "wrapping a task" do
413
414
  it "wraps another method" do
414
- Jettywrapper.any_instance.stub(:start).and_return(true)
415
- Jettywrapper.any_instance.stub(:stop).and_return(true)
415
+ allow_any_instance_of(Jettywrapper).to receive(:start).and_return(true)
416
+ allow_any_instance_of(Jettywrapper).to receive(:stop).and_return(true)
416
417
  error = Jettywrapper.wrap(@jetty_params) do
417
418
  end
418
- error.should eql(false)
419
+ expect(error).to eql(false)
419
420
  end
420
421
 
421
422
  it "configures itself correctly when invoked via the wrap method" do
422
- Jettywrapper.any_instance.stub(:start).and_return(true)
423
- Jettywrapper.any_instance.stub(:stop).and_return(true)
423
+ allow_any_instance_of(Jettywrapper).to receive(:start).and_return(true)
424
+ allow_any_instance_of(Jettywrapper).to receive(:stop).and_return(true)
424
425
  error = Jettywrapper.wrap(@jetty_params) do
425
426
  ts = Jettywrapper.instance
426
- ts.quiet.should == @jetty_params[:quiet]
427
- ts.jetty_home.should == "/path/to/jetty"
428
- ts.port.should == @jetty_params[:jetty_port]
429
- ts.solr_home.should == "/path/to/solr"
430
- ts.startup_wait.should == 0
427
+ expect(ts.quiet).to eq(@jetty_params[:quiet])
428
+ expect(ts.jetty_home).to eq("/path/to/jetty")
429
+ expect(ts.port).to eq(@jetty_params[:jetty_port])
430
+ expect(ts.solr_home).to eq("/path/to/solr")
431
+ expect(ts.startup_wait).to eq(0)
431
432
  end
432
- error.should eql(false)
433
+ expect(error).to eql(false)
433
434
  end
434
435
 
435
436
  it "captures any errors produced" do
436
- Jettywrapper.any_instance.stub(:start).and_return(true)
437
- Jettywrapper.any_instance.stub(:stop).and_return(true)
438
- Jettywrapper.instance.logger.should_receive(:error).with("*** Error starting jetty: this is an expected error message")
437
+ allow_any_instance_of(Jettywrapper).to receive(:start).and_return(true)
438
+ allow_any_instance_of(Jettywrapper).to receive(:stop).and_return(true)
439
+ expect(Jettywrapper.instance.logger).to receive(:error).with("*** Error starting jetty: this is an expected error message")
439
440
  expect { error = Jettywrapper.wrap(@jetty_params) do
440
441
  raise "this is an expected error message"
441
442
  end }.to raise_error "this is an expected error message"
@@ -447,15 +448,15 @@ require 'fileutils'
447
448
  it "inherits the current stderr/stdout in 'loud' mode" do
448
449
  ts = Jettywrapper.configure(@jetty_params.merge(:quiet => false))
449
450
  process = ts.process
450
- process.io.stderr.should == $stderr
451
- process.io.stdout.should == $stdout
451
+ expect(process.io.stderr).to eq($stderr)
452
+ expect(process.io.stdout).to eq($stdout)
452
453
  end
453
454
 
454
455
  it "redirect stderr/stdout to a log file in quiet mode" do
455
456
  ts = Jettywrapper.configure(@jetty_params.merge(:quiet => true))
456
457
  process = ts.process
457
- process.io.stderr.should_not == $stderr
458
- process.io.stdout.should_not == $stdout
458
+ expect(process.io.stderr).not_to eq($stderr)
459
+ expect(process.io.stdout).not_to eq($stdout)
459
460
  end
460
461
  end
461
462
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jettywrapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Beer
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-01-16 00:00:00.000000000 Z
13
+ date: 2015-02-09 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: logger
@@ -68,20 +68,34 @@ dependencies:
68
68
  - - ">="
69
69
  - !ruby/object:Gem::Version
70
70
  version: 3.0.0
71
+ - !ruby/object:Gem::Dependency
72
+ name: rubyzip
73
+ requirement: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ type: :runtime
79
+ prerelease: false
80
+ version_requirements: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
71
85
  - !ruby/object:Gem::Dependency
72
86
  name: rspec
73
87
  requirement: !ruby/object:Gem::Requirement
74
88
  requirements:
75
89
  - - "~>"
76
90
  - !ruby/object:Gem::Version
77
- version: '2.99'
91
+ version: '3.2'
78
92
  type: :development
79
93
  prerelease: false
80
94
  version_requirements: !ruby/object:Gem::Requirement
81
95
  requirements:
82
96
  - - "~>"
83
97
  - !ruby/object:Gem::Version
84
- version: '2.99'
98
+ version: '3.2'
85
99
  - !ruby/object:Gem::Dependency
86
100
  name: rspec-its
87
101
  requirement: !ruby/object:Gem::Requirement
@@ -145,7 +159,7 @@ files:
145
159
  - TODO.txt
146
160
  - config/jetty.yml
147
161
  - gemfiles/rails4.1.gemfile
148
- - gemfiles/rails4.2.beta.gemfile
162
+ - gemfiles/rails4.2.gemfile
149
163
  - jettywrapper.gemspec
150
164
  - lib/jettywrapper.rb
151
165
  - lib/jettywrapper/version.rb
@@ -174,8 +188,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
174
188
  version: 1.3.6
175
189
  requirements: []
176
190
  rubyforge_project:
177
- rubygems_version: 2.4.3
191
+ rubygems_version: 2.2.2
178
192
  signing_key:
179
193
  specification_version: 4
180
194
  summary: Convenience tasks for working with jetty from within a ruby project.
181
195
  test_files: []
196
+ has_rdoc: