guard-rack 1.3.1 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +7 -0
- data/.rspec +3 -0
- data/.rubocop.yml +21 -0
- data/.travis.yml +3 -0
- data/CHANGELOG.md +39 -0
- data/Gemfile +20 -0
- data/Guardfile +5 -0
- data/Rakefile +27 -0
- data/guard-rack.gemspec +30 -0
- data/lib/guard/rack/runner.rb +48 -55
- data/lib/guard/rack/version.rb +1 -2
- data/lib/guard/rack.rb +14 -15
- data/lib/guard-rack.rb +0 -1
- data/spec/lib/guard/integration.ru +11 -0
- data/spec/lib/guard/integration_spec.rb +22 -0
- data/spec/lib/guard/rack_spec.rb +91 -0
- data/spec/lib/guard/runner_spec.rb +188 -0
- data/spec/spec_helper.rb +9 -0
- metadata +62 -108
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9f3f1d76fdf26523714559cae171ecc150b07934
|
4
|
+
data.tar.gz: aee5f7a2b2bc99858dd5c3af575c9fc0273aeee1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e63feae80068915a758a197805175537081922c869d3fc32871de6cb34c9874ced743e53f4c5febba1940296f95cdab8160f9922b57c4d4c91222b24d986b16f
|
7
|
+
data.tar.gz: f6485324937d2abd86589ef9d0092b98af7415b19fbab5253a05399e793f6d417decedfdad65f9d029674737d7b9acdb928d4824249597b147687b7478b5f6d8
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
AllCops:
|
2
|
+
Excludes:
|
3
|
+
- vendor/**
|
4
|
+
- bin/**
|
5
|
+
|
6
|
+
LineLength:
|
7
|
+
Enabled: false
|
8
|
+
|
9
|
+
MethodLength:
|
10
|
+
Enabled: false
|
11
|
+
|
12
|
+
ClassLength:
|
13
|
+
Enabled: false
|
14
|
+
|
15
|
+
Documentation:
|
16
|
+
# don't require classes to be documented
|
17
|
+
Enabled: false
|
18
|
+
|
19
|
+
Encoding:
|
20
|
+
# no need to always specify encoding
|
21
|
+
Enabled: false
|
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
1.4.0 (1/28/2014)
|
2
|
+
=================
|
3
|
+
|
4
|
+
* Ruby 1.8.7 and 1.9.2 are no longer supported - [@dblock](https://github.com/dblock).
|
5
|
+
* Implemented Rubocop, Ruby linter - [@dblock](https://github.com/dblock).
|
6
|
+
* [#13](https://github.com/dblock/guard-rack/pull/13): Fix: do not lock a specific version of Rack - [@Nerian](https://github.com/Nerian).
|
7
|
+
|
8
|
+
1.3.1 (1/16/2013)
|
9
|
+
=================
|
10
|
+
|
11
|
+
* [#12](https://github.com/dblock/guard-rack/issues/12): Fix: could not load 'guard/rack', added missing `ffi` into Gemfile - [@dblock](https://github.com/dblock).
|
12
|
+
|
13
|
+
1.3 (1/15/2013)
|
14
|
+
===============
|
15
|
+
|
16
|
+
* [#11](https://github.com/dblock/guard-rack/pull/11): Use [spoon](https://github.com/headius/spoon) instead of `system()`, removes the need for `.pid` files - [@viking](https://github.com/viking), [@dblock](https://github.com/dblock).
|
17
|
+
|
18
|
+
1.2.2 (12/19/2012)
|
19
|
+
==================
|
20
|
+
|
21
|
+
* [#10](https://github.com/dblock/guard-rack/pull/10): Added ability to specify rackup config - [@kgfullerton](https://github.com/kgfullerton).
|
22
|
+
|
23
|
+
1.2.1 (6/31/2012)
|
24
|
+
=================
|
25
|
+
|
26
|
+
* [#9](https://github.com/dblock/guard-rack/pull/3): Added ability to specify server - [@rubycut](https://github.com/rubycut).
|
27
|
+
|
28
|
+
1.1 (06/06/2012)
|
29
|
+
================
|
30
|
+
|
31
|
+
* Now requires Guard 1.1.
|
32
|
+
* [#3](https://github.com/dblock/guard-rack/pull/3): Changed kill signal from `KILL` to `INT` - [@tombh](https://github.com/tombh).
|
33
|
+
* [#4](https://github.com/dblock/guard-rack/pull/4): Changed deprecated `run_on_change` to `run_on_changes` - [@tombh](https://github.com/tombh).
|
34
|
+
|
35
|
+
1.0 (02/27/2012)
|
36
|
+
================
|
37
|
+
|
38
|
+
* Initial public release - [@dblock](https://github.com/dblock).
|
39
|
+
|
data/Gemfile
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
|
3
|
+
gem "guard"
|
4
|
+
gem "ffi"
|
5
|
+
gem "spoon"
|
6
|
+
|
7
|
+
group :development, :test do
|
8
|
+
gem "rake"
|
9
|
+
gem "bundler"
|
10
|
+
gem "rspec"
|
11
|
+
gem "guard-rspec"
|
12
|
+
gem "fakefs"
|
13
|
+
gem "mocha"
|
14
|
+
gem "rack"
|
15
|
+
gem 'growl'
|
16
|
+
gem 'rb-inotify', require: false
|
17
|
+
gem 'rb-fsevent', require: false
|
18
|
+
gem 'rb-fchange', require: false
|
19
|
+
gem 'rubocop'
|
20
|
+
end
|
data/Guardfile
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler/gem_tasks'
|
3
|
+
|
4
|
+
require File.expand_path('../lib/guard/rack/version', __FILE__)
|
5
|
+
|
6
|
+
begin
|
7
|
+
Bundler.setup(:default, :development)
|
8
|
+
rescue Bundler::BundlerError => e
|
9
|
+
$stderr.puts e.message
|
10
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
11
|
+
exit e.status_code
|
12
|
+
end
|
13
|
+
|
14
|
+
require 'rake'
|
15
|
+
require 'rspec/core'
|
16
|
+
require 'rspec/core/rake_task'
|
17
|
+
|
18
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
19
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
20
|
+
end
|
21
|
+
|
22
|
+
require 'rainbow/ext/string' unless String.respond_to?(:color)
|
23
|
+
require 'rubocop/rake_task'
|
24
|
+
Rubocop::RakeTask.new(:rubocop)
|
25
|
+
|
26
|
+
task default: [:rubocop, :spec]
|
27
|
+
|
data/guard-rack.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/guard/rack/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Daniel Doubrovkine"]
|
6
|
+
|
7
|
+
gem.email = ["dblock@dblock.org"]
|
8
|
+
gem.description = "Automatically reloads your Rack based app on file change using Guard."
|
9
|
+
gem.homepage = "https://github.com/dblock/guard-rack"
|
10
|
+
gem.summary = gem.description
|
11
|
+
gem.license = 'MIT'
|
12
|
+
|
13
|
+
gem.name = "guard-rack"
|
14
|
+
gem.require_paths = ["lib"]
|
15
|
+
gem.files = `git ls-files`.split("\n")
|
16
|
+
gem.version = Guard::RackVersion::VERSION
|
17
|
+
|
18
|
+
gem.add_dependency "guard"
|
19
|
+
gem.add_dependency "ffi"
|
20
|
+
gem.add_dependency "spoon"
|
21
|
+
gem.add_dependency "rb-inotify"
|
22
|
+
gem.add_dependency "libnotify"
|
23
|
+
|
24
|
+
gem.add_development_dependency "rake"
|
25
|
+
gem.add_development_dependency "bundler"
|
26
|
+
gem.add_development_dependency "rspec"
|
27
|
+
gem.add_development_dependency "fakefs"
|
28
|
+
gem.add_development_dependency "mocha"
|
29
|
+
gem.add_development_dependency "rack"
|
30
|
+
end
|
data/lib/guard/rack/runner.rb
CHANGED
@@ -4,7 +4,6 @@ require 'spoon'
|
|
4
4
|
|
5
5
|
module Guard
|
6
6
|
class RackRunner
|
7
|
-
|
8
7
|
attr_reader :options, :pid
|
9
8
|
|
10
9
|
def initialize(options)
|
@@ -32,75 +31,69 @@ module Guard
|
|
32
31
|
end
|
33
32
|
|
34
33
|
def restart
|
35
|
-
stop
|
34
|
+
stop && start
|
36
35
|
end
|
37
36
|
|
38
37
|
private
|
39
38
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
39
|
+
def build_rack_command
|
40
|
+
command = %w{rackup}
|
41
|
+
command.push(
|
42
|
+
options[:config],
|
43
|
+
'--env', options[:environment].to_s,
|
44
|
+
'--port', options[:port].to_s
|
45
|
+
)
|
47
46
|
|
48
|
-
|
49
|
-
|
50
|
-
|
47
|
+
command << '--daemonize' if options[:daemon]
|
48
|
+
command << '--debug' if options[:debugger]
|
49
|
+
command.push('--server', options[:server].to_s) if options[:server]
|
51
50
|
|
52
|
-
|
53
|
-
|
51
|
+
command
|
52
|
+
end
|
54
53
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
end
|
67
|
-
rescue Timeout::Error
|
68
|
-
UI.debug("Couldn't kill Rack with INT, switching to TERM")
|
69
|
-
force = true
|
54
|
+
def kill(pid, force = false)
|
55
|
+
result = -1
|
56
|
+
|
57
|
+
UI.debug("Trying to kill Rack (PID #{pid})...")
|
58
|
+
unless force
|
59
|
+
Process.kill('INT', pid)
|
60
|
+
begin
|
61
|
+
Timeout.timeout(options[:timeout]) do
|
62
|
+
_, status = Process.wait2(pid)
|
63
|
+
result = status.exitstatus
|
64
|
+
UI.debug("Killed Rack (Exit status: #{result})")
|
70
65
|
end
|
66
|
+
rescue Timeout::Error
|
67
|
+
UI.debug("Couldn't kill Rack with INT, switching to TERM")
|
68
|
+
force = true
|
71
69
|
end
|
70
|
+
end
|
72
71
|
|
73
|
-
|
74
|
-
Process.kill("TERM", pid)
|
75
|
-
end
|
72
|
+
Process.kill('TERM', pid) if force
|
76
73
|
|
77
|
-
|
78
|
-
|
74
|
+
result
|
75
|
+
end
|
79
76
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
77
|
+
def run_rack_command!
|
78
|
+
command = build_rack_command
|
79
|
+
UI.debug("Running Rack with command: #{command.inspect}")
|
80
|
+
spawn(*command)
|
81
|
+
end
|
85
82
|
|
86
|
-
|
87
|
-
|
88
|
-
|
83
|
+
def spawn(* args)
|
84
|
+
Spoon.spawnp(* args)
|
85
|
+
end
|
89
86
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
end
|
87
|
+
def kill_unmanaged_pid!
|
88
|
+
pid = unmanaged_pid
|
89
|
+
kill(pid, true) if pid
|
90
|
+
end
|
95
91
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
return line.split("\s")[1].to_i
|
100
|
-
end
|
101
|
-
}
|
102
|
-
nil
|
92
|
+
def unmanaged_pid
|
93
|
+
%x{lsof -n -i TCP:#{options[:port]}}.each_line do |line|
|
94
|
+
return line.split("\s")[1].to_i if line["*:#{options[:port]} "]
|
103
95
|
end
|
104
|
-
|
96
|
+
nil
|
97
|
+
end
|
105
98
|
end
|
106
99
|
end
|
data/lib/guard/rack/version.rb
CHANGED
data/lib/guard/rack.rb
CHANGED
@@ -8,13 +8,13 @@ module Guard
|
|
8
8
|
attr_reader :options, :runner
|
9
9
|
|
10
10
|
DEFAULT_OPTIONS = {
|
11
|
-
:
|
12
|
-
:
|
13
|
-
:
|
14
|
-
:
|
15
|
-
:
|
16
|
-
:
|
17
|
-
:
|
11
|
+
port: 9292,
|
12
|
+
environment: 'development',
|
13
|
+
start_on_start: true,
|
14
|
+
force_run: false,
|
15
|
+
timeout: 20,
|
16
|
+
debugger: false,
|
17
|
+
config: 'config.ru'
|
18
18
|
}
|
19
19
|
|
20
20
|
def initialize(watchers = [], options = {})
|
@@ -24,25 +24,25 @@ module Guard
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def start
|
27
|
-
server = options[:server] ? "#{options[:server]} and " :
|
27
|
+
server = options[:server] ? "#{options[:server]} and " : ''
|
28
28
|
UI.info "Guard::Rack will now restart your app on port #{options[:port]} using #{server}#{options[:environment]} environment."
|
29
29
|
reload if options[:start_on_start]
|
30
30
|
end
|
31
31
|
|
32
32
|
def reload
|
33
|
-
UI.info
|
34
|
-
Notifier.notify("Rack restarting on port #{options[:port]} in #{options[:environment]} environment...", :
|
33
|
+
UI.info 'Restarting Rack...'
|
34
|
+
Notifier.notify("Rack restarting on port #{options[:port]} in #{options[:environment]} environment...", title: 'Restarting Rack...', image: :pending)
|
35
35
|
if runner.restart
|
36
36
|
UI.info "Rack restarted, pid #{runner.pid}"
|
37
|
-
Notifier.notify("Rack restarted on port #{options[:port]}.", :
|
37
|
+
Notifier.notify("Rack restarted on port #{options[:port]}.", title: 'Rack restarted!', image: :success)
|
38
38
|
else
|
39
|
-
UI.info
|
40
|
-
Notifier.notify(
|
39
|
+
UI.info 'Rack NOT restarted, check your log files.'
|
40
|
+
Notifier.notify('Rack NOT restarted, check your log files.', title: 'Rack NOT restarted!', image: :failed)
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
44
|
def stop
|
45
|
-
Notifier.notify(
|
45
|
+
Notifier.notify('Until next time...', title: 'Rack shutting down.', image: :pending)
|
46
46
|
runner.stop
|
47
47
|
end
|
48
48
|
|
@@ -51,4 +51,3 @@ module Guard
|
|
51
51
|
end
|
52
52
|
end
|
53
53
|
end
|
54
|
-
|
data/lib/guard-rack.rb
CHANGED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'guard/rack/runner'
|
3
|
+
|
4
|
+
describe 'Integration' do
|
5
|
+
let(:runner) { Guard::RackRunner.new(options) }
|
6
|
+
let(:options) { { environment: 'development', port: 3000, config: 'spec/lib/guard/integration.ru' } }
|
7
|
+
|
8
|
+
describe '#start' do
|
9
|
+
context 'run' do
|
10
|
+
it 'should run' do
|
11
|
+
runner.start.should be_true
|
12
|
+
pid = runner.pid
|
13
|
+
pid.should_not be_nil
|
14
|
+
Process.getpgid(pid).should be > 0
|
15
|
+
runner.stop
|
16
|
+
expect do
|
17
|
+
Process.getpgid(pid)
|
18
|
+
end.to raise_error Errno::ESRCH
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'guard/rack'
|
3
|
+
|
4
|
+
describe Guard::Rack do
|
5
|
+
let(:guard) { Guard::Rack.new(watchers, options) }
|
6
|
+
let(:watchers) { [] }
|
7
|
+
let(:options) { {} }
|
8
|
+
|
9
|
+
describe '#initialize' do
|
10
|
+
it 'should initialize with options' do
|
11
|
+
guard
|
12
|
+
|
13
|
+
guard.runner.options[:port].should == 9292
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '#start' do
|
18
|
+
let(:ui_expectation) { Guard::UI.expects(:info).with(regexp_matches(/#{Guard::Rack::DEFAULT_OPTIONS[:port]}/)) }
|
19
|
+
|
20
|
+
context 'start on start' do
|
21
|
+
it 'should show the right message and run startup' do
|
22
|
+
guard.expects(:reload).once
|
23
|
+
ui_expectation
|
24
|
+
guard.start
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context 'no start on start' do
|
29
|
+
let(:options) { { start_on_start: false } }
|
30
|
+
|
31
|
+
it 'should show the right message and not run startup' do
|
32
|
+
guard.expects(:reload).never
|
33
|
+
ui_expectation
|
34
|
+
guard.start
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe '#reload' do
|
40
|
+
let(:pid) { '12345' }
|
41
|
+
|
42
|
+
before do
|
43
|
+
Guard::UI.expects(:info).with('Restarting Rack...')
|
44
|
+
Guard::Notifier.expects(:notify).with(regexp_matches(/Rack restarting/), has_entry(image: :pending))
|
45
|
+
Guard::RackRunner.any_instance.stubs(:pid).returns(pid)
|
46
|
+
end
|
47
|
+
|
48
|
+
let(:runner_stub) { Guard::RackRunner.any_instance.stubs(:restart) }
|
49
|
+
|
50
|
+
context 'with pid file' do
|
51
|
+
before do
|
52
|
+
runner_stub.returns(true)
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'should restart and show the pid file' do
|
56
|
+
Guard::UI.expects(:info).with(regexp_matches(/#{pid}/))
|
57
|
+
Guard::Notifier.expects(:notify).with(regexp_matches(/Rack restarted/), has_entry(image: :success))
|
58
|
+
|
59
|
+
guard.reload
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
context 'no pid file' do
|
64
|
+
before do
|
65
|
+
runner_stub.returns(false)
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'should restart and show the pid file' do
|
69
|
+
Guard::UI.expects(:info).with(regexp_matches(/#{pid}/)).never
|
70
|
+
Guard::UI.expects(:info).with(regexp_matches(/Rack NOT restarted/))
|
71
|
+
Guard::Notifier.expects(:notify).with(regexp_matches(/Rack NOT restarted/), has_entry(image: :failed))
|
72
|
+
|
73
|
+
guard.reload
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe '#stop' do
|
79
|
+
it 'should stop correctly' do
|
80
|
+
Guard::Notifier.expects(:notify).with('Until next time...', anything)
|
81
|
+
guard.stop
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
describe '#run_on_changes' do
|
86
|
+
it 'should reload on change' do
|
87
|
+
guard.expects(:reload).once
|
88
|
+
guard.run_on_changes([])
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,188 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'guard/rack/runner'
|
3
|
+
|
4
|
+
describe Guard::RackRunner do
|
5
|
+
let(:runner) { Guard::RackRunner.new(options) }
|
6
|
+
let(:environment) { 'development' }
|
7
|
+
let(:port) { 3000 }
|
8
|
+
|
9
|
+
let(:default_options) { { environment: environment, port: port, config: 'config.ru' } }
|
10
|
+
let(:options) { default_options }
|
11
|
+
|
12
|
+
before do
|
13
|
+
Guard::UI.stubs(:debug)
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '#pid' do
|
17
|
+
context 'after running' do
|
18
|
+
let(:pid) { 1234 }
|
19
|
+
|
20
|
+
before do
|
21
|
+
runner.stubs(:spawn).returns(pid)
|
22
|
+
runner.start
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should not be nil' do
|
26
|
+
runner.pid.should == pid
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context 'before running' do
|
31
|
+
it 'should return nil' do
|
32
|
+
runner.pid.should be_nil
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe '#build_rack_command' do
|
38
|
+
context 'no daemon' do
|
39
|
+
it 'should not have a daemon switch' do
|
40
|
+
runner.send(:build_rack_command).should_not include('--daemonize')
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context 'daemon' do
|
45
|
+
let(:options) { default_options.merge(daemon: true) }
|
46
|
+
|
47
|
+
it 'should have a daemon switch' do
|
48
|
+
runner.send(:build_rack_command).should include('--daemonize')
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
context 'debugger' do
|
53
|
+
let(:options) { default_options.merge(debugger: true) }
|
54
|
+
|
55
|
+
it 'should have a debugger switch' do
|
56
|
+
runner.send(:build_rack_command).should include('--debug')
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
context 'server' do
|
61
|
+
let(:options) { default_options.merge(server: 'thin') }
|
62
|
+
|
63
|
+
it 'should honour server switch' do
|
64
|
+
command = runner.send(:build_rack_command)
|
65
|
+
index = command.index('--server')
|
66
|
+
index.should be >= 0
|
67
|
+
command[index + 1].should == 'thin'
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
context 'config file' do
|
72
|
+
context 'default' do
|
73
|
+
it 'should default to config.ru' do
|
74
|
+
runner.send(:build_rack_command).should include('config.ru')
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
context 'custom' do
|
79
|
+
let(:options) { default_options.merge(config: 'config2.ru') }
|
80
|
+
it 'should honour config option' do
|
81
|
+
default_options.merge(config: 'config2.ru')
|
82
|
+
runner.send(:build_rack_command).should include('config2.ru')
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
describe '#start' do
|
89
|
+
let(:unmanaged_pid) { 4567 }
|
90
|
+
let(:pid) { 1234 }
|
91
|
+
let(:kill_expectation) { Process.expects(:kill).with('TERM', unmanaged_pid) }
|
92
|
+
|
93
|
+
before do
|
94
|
+
runner.expects(:spawn).once.returns(pid)
|
95
|
+
runner.stubs(:unmanaged_pid).returns(unmanaged_pid)
|
96
|
+
end
|
97
|
+
|
98
|
+
context 'do not force run' do
|
99
|
+
before do
|
100
|
+
kill_expectation.never
|
101
|
+
end
|
102
|
+
|
103
|
+
it 'should act properly' do
|
104
|
+
runner.start.should be_true
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
context 'force run' do
|
109
|
+
let(:options) { default_options.merge(force_run: true) }
|
110
|
+
|
111
|
+
before do
|
112
|
+
kill_expectation.once
|
113
|
+
Process.expects(:wait2).never # don't wait on non-child processes
|
114
|
+
end
|
115
|
+
|
116
|
+
it 'should act properly' do
|
117
|
+
runner.start.should be_true
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
describe '#stop' do
|
123
|
+
|
124
|
+
context 'pid exists' do
|
125
|
+
let(:pid) { 12_345 }
|
126
|
+
let(:status_stub) { stub('process exit status') }
|
127
|
+
let(:wait_stub) { Process.stubs(:wait2) }
|
128
|
+
|
129
|
+
before do
|
130
|
+
runner.stubs(:spawn).returns(pid)
|
131
|
+
runner.start
|
132
|
+
|
133
|
+
Process.expects(:kill).with('INT', pid)
|
134
|
+
end
|
135
|
+
|
136
|
+
context 'rackup returns successful exit status' do
|
137
|
+
before do
|
138
|
+
wait_stub.returns([pid, status_stub])
|
139
|
+
status_stub.stubs(:exitstatus).returns(0)
|
140
|
+
end
|
141
|
+
|
142
|
+
it 'should return true' do
|
143
|
+
runner.stop.should be_true
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
context 'rackup returns unsuccessful exit status' do
|
148
|
+
before do
|
149
|
+
Guard::UI.stubs(:info)
|
150
|
+
wait_stub.returns([pid, status_stub])
|
151
|
+
status_stub.stubs(:exitstatus).returns(1)
|
152
|
+
end
|
153
|
+
|
154
|
+
it 'should return false' do
|
155
|
+
runner.stop.should be_false
|
156
|
+
end
|
157
|
+
|
158
|
+
it 'should send some kind of message to UI.info' do
|
159
|
+
Guard::UI.expects(:info).with(regexp_matches(/.+/))
|
160
|
+
runner.stop
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
context 'kill times out' do
|
165
|
+
before do
|
166
|
+
Guard::UI.stubs(:info)
|
167
|
+
wait_stub.raises(Timeout::Error)
|
168
|
+
Process.expects(:kill).with('TERM', pid)
|
169
|
+
end
|
170
|
+
|
171
|
+
it 'should return false' do
|
172
|
+
runner.stop.should be_false
|
173
|
+
end
|
174
|
+
|
175
|
+
it 'should send some kind of message to UI.info' do
|
176
|
+
Guard::UI.expects(:info).with(regexp_matches(/.+/))
|
177
|
+
runner.stop
|
178
|
+
end
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
context 'pid does not exist' do
|
183
|
+
it 'should return true' do
|
184
|
+
runner.stop.should be_true
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
188
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
CHANGED
@@ -1,265 +1,219 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: guard-rack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
5
|
-
prerelease:
|
4
|
+
version: 1.4.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Daniel Doubrovkine
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-01-28 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: guard
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
|
-
version: '
|
19
|
+
version: '0'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - '>='
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version: '
|
26
|
+
version: '0'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: ffi
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - '>='
|
36
32
|
- !ruby/object:Gem::Version
|
37
|
-
version:
|
33
|
+
version: '0'
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - '>='
|
44
39
|
- !ruby/object:Gem::Version
|
45
|
-
version:
|
40
|
+
version: '0'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: spoon
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - '>='
|
52
46
|
- !ruby/object:Gem::Version
|
53
|
-
version: 0
|
47
|
+
version: '0'
|
54
48
|
type: :runtime
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - '>='
|
60
53
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0
|
54
|
+
version: '0'
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: rb-inotify
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
|
-
- -
|
59
|
+
- - '>='
|
68
60
|
- !ruby/object:Gem::Version
|
69
|
-
version: 0
|
61
|
+
version: '0'
|
70
62
|
type: :runtime
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
|
-
- -
|
66
|
+
- - '>='
|
76
67
|
- !ruby/object:Gem::Version
|
77
|
-
version: 0
|
68
|
+
version: '0'
|
78
69
|
- !ruby/object:Gem::Dependency
|
79
70
|
name: libnotify
|
80
71
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
72
|
requirements:
|
83
|
-
- -
|
73
|
+
- - '>='
|
84
74
|
- !ruby/object:Gem::Version
|
85
|
-
version: 0
|
75
|
+
version: '0'
|
86
76
|
type: :runtime
|
87
77
|
prerelease: false
|
88
78
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
79
|
requirements:
|
91
|
-
- -
|
80
|
+
- - '>='
|
92
81
|
- !ruby/object:Gem::Version
|
93
|
-
version: 0
|
82
|
+
version: '0'
|
94
83
|
- !ruby/object:Gem::Dependency
|
95
84
|
name: rake
|
96
85
|
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
86
|
requirements:
|
99
|
-
- -
|
87
|
+
- - '>='
|
100
88
|
- !ruby/object:Gem::Version
|
101
89
|
version: '0'
|
102
90
|
type: :development
|
103
91
|
prerelease: false
|
104
92
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
93
|
requirements:
|
107
|
-
- -
|
94
|
+
- - '>='
|
108
95
|
- !ruby/object:Gem::Version
|
109
96
|
version: '0'
|
110
97
|
- !ruby/object:Gem::Dependency
|
111
98
|
name: bundler
|
112
99
|
requirement: !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
100
|
requirements:
|
115
|
-
- -
|
101
|
+
- - '>='
|
116
102
|
- !ruby/object:Gem::Version
|
117
|
-
version: '
|
103
|
+
version: '0'
|
118
104
|
type: :development
|
119
105
|
prerelease: false
|
120
106
|
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
none: false
|
122
107
|
requirements:
|
123
|
-
- -
|
108
|
+
- - '>='
|
124
109
|
- !ruby/object:Gem::Version
|
125
|
-
version: '
|
110
|
+
version: '0'
|
126
111
|
- !ruby/object:Gem::Dependency
|
127
112
|
name: rspec
|
128
113
|
requirement: !ruby/object:Gem::Requirement
|
129
|
-
none: false
|
130
|
-
requirements:
|
131
|
-
- - ~>
|
132
|
-
- !ruby/object:Gem::Version
|
133
|
-
version: '2.6'
|
134
|
-
type: :development
|
135
|
-
prerelease: false
|
136
|
-
version_requirements: !ruby/object:Gem::Requirement
|
137
|
-
none: false
|
138
|
-
requirements:
|
139
|
-
- - ~>
|
140
|
-
- !ruby/object:Gem::Version
|
141
|
-
version: '2.6'
|
142
|
-
- !ruby/object:Gem::Dependency
|
143
|
-
name: jeweler
|
144
|
-
requirement: !ruby/object:Gem::Requirement
|
145
|
-
none: false
|
146
|
-
requirements:
|
147
|
-
- - ~>
|
148
|
-
- !ruby/object:Gem::Version
|
149
|
-
version: '1.6'
|
150
|
-
type: :development
|
151
|
-
prerelease: false
|
152
|
-
version_requirements: !ruby/object:Gem::Requirement
|
153
|
-
none: false
|
154
114
|
requirements:
|
155
|
-
- -
|
156
|
-
- !ruby/object:Gem::Version
|
157
|
-
version: '1.6'
|
158
|
-
- !ruby/object:Gem::Dependency
|
159
|
-
name: guard-rspec
|
160
|
-
requirement: !ruby/object:Gem::Requirement
|
161
|
-
none: false
|
162
|
-
requirements:
|
163
|
-
- - ! '>='
|
115
|
+
- - '>='
|
164
116
|
- !ruby/object:Gem::Version
|
165
117
|
version: '0'
|
166
118
|
type: :development
|
167
119
|
prerelease: false
|
168
120
|
version_requirements: !ruby/object:Gem::Requirement
|
169
|
-
none: false
|
170
121
|
requirements:
|
171
|
-
- -
|
122
|
+
- - '>='
|
172
123
|
- !ruby/object:Gem::Version
|
173
124
|
version: '0'
|
174
125
|
- !ruby/object:Gem::Dependency
|
175
126
|
name: fakefs
|
176
127
|
requirement: !ruby/object:Gem::Requirement
|
177
|
-
none: false
|
178
128
|
requirements:
|
179
|
-
- -
|
129
|
+
- - '>='
|
180
130
|
- !ruby/object:Gem::Version
|
181
131
|
version: '0'
|
182
132
|
type: :development
|
183
133
|
prerelease: false
|
184
134
|
version_requirements: !ruby/object:Gem::Requirement
|
185
|
-
none: false
|
186
135
|
requirements:
|
187
|
-
- -
|
136
|
+
- - '>='
|
188
137
|
- !ruby/object:Gem::Version
|
189
138
|
version: '0'
|
190
139
|
- !ruby/object:Gem::Dependency
|
191
140
|
name: mocha
|
192
141
|
requirement: !ruby/object:Gem::Requirement
|
193
|
-
none: false
|
194
142
|
requirements:
|
195
|
-
- -
|
143
|
+
- - '>='
|
196
144
|
- !ruby/object:Gem::Version
|
197
145
|
version: '0'
|
198
146
|
type: :development
|
199
147
|
prerelease: false
|
200
148
|
version_requirements: !ruby/object:Gem::Requirement
|
201
|
-
none: false
|
202
149
|
requirements:
|
203
|
-
- -
|
150
|
+
- - '>='
|
204
151
|
- !ruby/object:Gem::Version
|
205
152
|
version: '0'
|
206
153
|
- !ruby/object:Gem::Dependency
|
207
154
|
name: rack
|
208
155
|
requirement: !ruby/object:Gem::Requirement
|
209
|
-
none: false
|
210
156
|
requirements:
|
211
|
-
- -
|
157
|
+
- - '>='
|
212
158
|
- !ruby/object:Gem::Version
|
213
159
|
version: '0'
|
214
160
|
type: :development
|
215
161
|
prerelease: false
|
216
162
|
version_requirements: !ruby/object:Gem::Requirement
|
217
|
-
none: false
|
218
163
|
requirements:
|
219
|
-
- -
|
164
|
+
- - '>='
|
220
165
|
- !ruby/object:Gem::Version
|
221
166
|
version: '0'
|
222
|
-
description:
|
223
|
-
email:
|
167
|
+
description: Automatically reloads your Rack based app on file change using Guard.
|
168
|
+
email:
|
169
|
+
- dblock@dblock.org
|
224
170
|
executables: []
|
225
171
|
extensions: []
|
226
|
-
extra_rdoc_files:
|
172
|
+
extra_rdoc_files: []
|
173
|
+
files:
|
174
|
+
- .gitignore
|
175
|
+
- .rspec
|
176
|
+
- .rubocop.yml
|
177
|
+
- .travis.yml
|
178
|
+
- CHANGELOG.md
|
179
|
+
- Gemfile
|
180
|
+
- Guardfile
|
227
181
|
- LICENSE.md
|
228
182
|
- README.md
|
229
|
-
|
183
|
+
- Rakefile
|
184
|
+
- guard-rack.gemspec
|
230
185
|
- lib/guard-rack.rb
|
231
186
|
- lib/guard/rack.rb
|
232
187
|
- lib/guard/rack/runner.rb
|
233
188
|
- lib/guard/rack/templates/Guardfile
|
234
189
|
- lib/guard/rack/version.rb
|
235
|
-
-
|
236
|
-
-
|
237
|
-
|
190
|
+
- spec/lib/guard/integration.ru
|
191
|
+
- spec/lib/guard/integration_spec.rb
|
192
|
+
- spec/lib/guard/rack_spec.rb
|
193
|
+
- spec/lib/guard/runner_spec.rb
|
194
|
+
- spec/spec_helper.rb
|
195
|
+
homepage: https://github.com/dblock/guard-rack
|
238
196
|
licenses:
|
239
197
|
- MIT
|
198
|
+
metadata: {}
|
240
199
|
post_install_message:
|
241
200
|
rdoc_options: []
|
242
201
|
require_paths:
|
243
202
|
- lib
|
244
203
|
required_ruby_version: !ruby/object:Gem::Requirement
|
245
|
-
none: false
|
246
204
|
requirements:
|
247
|
-
- -
|
205
|
+
- - '>='
|
248
206
|
- !ruby/object:Gem::Version
|
249
207
|
version: '0'
|
250
|
-
segments:
|
251
|
-
- 0
|
252
|
-
hash: 169278257
|
253
208
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
254
|
-
none: false
|
255
209
|
requirements:
|
256
|
-
- -
|
210
|
+
- - '>='
|
257
211
|
- !ruby/object:Gem::Version
|
258
212
|
version: '0'
|
259
213
|
requirements: []
|
260
214
|
rubyforge_project:
|
261
|
-
rubygems_version:
|
215
|
+
rubygems_version: 2.0.14
|
262
216
|
signing_key:
|
263
|
-
specification_version:
|
264
|
-
summary:
|
217
|
+
specification_version: 4
|
218
|
+
summary: Automatically reloads your Rack based app on file change using Guard.
|
265
219
|
test_files: []
|