guard-rails 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/Gemfile.lock +15 -15
- data/README.md +1 -0
- data/VERSION +1 -1
- data/lib/guard/rails.rb +3 -2
- data/lib/guard/rails/runner.rb +142 -129
- data/spec/lib/guard/rails/runner_spec.rb +131 -6
- data/spec/lib/guard/rails_spec.rb +5 -6
- data/spec/spec_helper.rb +9 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: badcb2d7fa378fb0f9fc7bc4a4922642f6d1b24b
|
4
|
+
data.tar.gz: 80d9c099b2b8b7824cf3bfa186f4dd1960f9e9d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 364a7e4234fa9efae4af2dcb8319dc2ea712db73d46e0b1492e4486c0b536f04979bb92cc8f2e0a8583bae0640f2a7ce67e64fc69ef36574037c04519a17bc34
|
7
|
+
data.tar.gz: 84c3dde82a373dd602a5aeead8a8f4f45debbcaf0ae5cbd404e0ea7b3aa13b5632642246856bed09d7ab9ca19a3ac5b178b517ef0bf1d86e57de8b191b2b1436
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
guard-rails (0.6.
|
4
|
+
guard-rails (0.6.1)
|
5
5
|
guard (~> 2.0)
|
6
6
|
|
7
7
|
GEM
|
@@ -9,16 +9,16 @@ GEM
|
|
9
9
|
specs:
|
10
10
|
celluloid (0.16.0)
|
11
11
|
timers (~> 4.0.0)
|
12
|
-
codeclimate-test-reporter (0.4.
|
12
|
+
codeclimate-test-reporter (0.4.1)
|
13
13
|
simplecov (>= 0.7.1, < 1.0.0)
|
14
14
|
coderay (1.1.0)
|
15
15
|
diff-lcs (1.2.5)
|
16
16
|
docile (1.1.5)
|
17
|
-
fakefs (0.
|
18
|
-
ffi (1.9.
|
19
|
-
ffi (1.9.
|
17
|
+
fakefs (0.6.0)
|
18
|
+
ffi (1.9.6)
|
19
|
+
ffi (1.9.6-java)
|
20
20
|
formatador (0.2.5)
|
21
|
-
guard (2.
|
21
|
+
guard (2.7.0)
|
22
22
|
formatador (>= 0.2.4)
|
23
23
|
listen (~> 2.7)
|
24
24
|
lumberjack (~> 1.0)
|
@@ -32,9 +32,9 @@ GEM
|
|
32
32
|
rspec (>= 2.14, < 4.0)
|
33
33
|
hitimes (1.2.2)
|
34
34
|
hitimes (1.2.2-java)
|
35
|
-
libnotify (0.8.
|
35
|
+
libnotify (0.8.4)
|
36
36
|
ffi (>= 1.0.11)
|
37
|
-
listen (2.7.
|
37
|
+
listen (2.7.11)
|
38
38
|
celluloid (>= 0.15.2)
|
39
39
|
rb-fsevent (>= 0.9.3)
|
40
40
|
rb-inotify (>= 0.9)
|
@@ -59,23 +59,23 @@ GEM
|
|
59
59
|
rspec-core (~> 3.1.0)
|
60
60
|
rspec-expectations (~> 3.1.0)
|
61
61
|
rspec-mocks (~> 3.1.0)
|
62
|
-
rspec-core (3.1.
|
62
|
+
rspec-core (3.1.7)
|
63
63
|
rspec-support (~> 3.1.0)
|
64
|
-
rspec-expectations (3.1.
|
64
|
+
rspec-expectations (3.1.2)
|
65
65
|
diff-lcs (>= 1.2.0, < 2.0)
|
66
66
|
rspec-support (~> 3.1.0)
|
67
|
-
rspec-mocks (3.1.
|
67
|
+
rspec-mocks (3.1.3)
|
68
68
|
rspec-support (~> 3.1.0)
|
69
|
-
rspec-support (3.1.
|
70
|
-
simplecov (0.9.
|
69
|
+
rspec-support (3.1.2)
|
70
|
+
simplecov (0.9.1)
|
71
71
|
docile (~> 1.1.0)
|
72
|
-
multi_json
|
72
|
+
multi_json (~> 1.0)
|
73
73
|
simplecov-html (~> 0.8.0)
|
74
74
|
simplecov-html (0.8.0)
|
75
75
|
slop (3.6.0)
|
76
76
|
spoon (0.0.4)
|
77
77
|
ffi
|
78
|
-
terminal-notifier-guard (1.
|
78
|
+
terminal-notifier-guard (1.6.1)
|
79
79
|
thor (0.19.1)
|
80
80
|
timers (4.0.1)
|
81
81
|
hitimes
|
data/README.md
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.6.
|
1
|
+
0.6.1
|
data/lib/guard/rails.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
require 'guard'
|
2
2
|
require 'guard/plugin'
|
3
|
-
require 'guard/rails/runner'
|
4
3
|
require 'rbconfig'
|
5
4
|
|
6
5
|
module Guard
|
7
6
|
class Rails < Plugin
|
7
|
+
require 'guard/rails/runner'
|
8
|
+
|
8
9
|
# Use gem `version` to support versioning
|
9
10
|
# is_versioned
|
10
11
|
|
@@ -29,7 +30,7 @@ module Guard
|
|
29
30
|
super
|
30
31
|
@options = DEFAULT_OPTIONS.merge(options)
|
31
32
|
|
32
|
-
@runner =
|
33
|
+
@runner = Runner.new(@options)
|
33
34
|
end
|
34
35
|
|
35
36
|
def start
|
data/lib/guard/rails/runner.rb
CHANGED
@@ -1,173 +1,186 @@
|
|
1
1
|
require 'fileutils'
|
2
2
|
|
3
3
|
module Guard
|
4
|
-
class
|
5
|
-
|
4
|
+
class Rails
|
5
|
+
class Runner
|
6
|
+
MAX_WAIT_COUNT = 10
|
6
7
|
|
7
|
-
|
8
|
+
attr_reader :options
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
def initialize(options)
|
11
|
+
@options = options
|
12
|
+
@root = options[:root] ? File.expand_path(options[:root]) : Dir.pwd
|
13
|
+
end
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
15
|
+
def start
|
16
|
+
kill_unmanaged_pid! if options[:force_run]
|
17
|
+
run_rails_command!
|
18
|
+
wait_for_pid
|
19
|
+
end
|
19
20
|
|
20
|
-
|
21
|
-
|
22
|
-
pid = File.read(pid_file).strip.to_i
|
23
|
-
sig_sent = kill_process("INT", pid)
|
24
|
-
wait_for_no_pid if sig_sent
|
21
|
+
def stop
|
22
|
+
return unless has_pid?
|
25
23
|
|
26
|
-
|
27
|
-
|
24
|
+
if (pid = read_pid)
|
25
|
+
sig_sent = kill_process("INT", pid)
|
26
|
+
wait_for_no_pid if sig_sent
|
27
|
+
|
28
|
+
# If you lost your pid_file, you are already died.
|
29
|
+
kill_process("KILL", pid)
|
30
|
+
end
|
28
31
|
remove_pid_file_and_wait_for_no_pid
|
29
32
|
end
|
30
|
-
end
|
31
33
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
def build_command
|
38
|
-
command = build_cli_command if options[:CLI]
|
39
|
-
command ||= build_zeus_command if options[:zeus]
|
40
|
-
command ||= build_rails_command
|
41
|
-
"sh -c 'cd \"#{@root}\" && #{command} &'"
|
42
|
-
end
|
34
|
+
def restart
|
35
|
+
stop
|
36
|
+
start
|
37
|
+
end
|
43
38
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
39
|
+
def build_command
|
40
|
+
command = build_cli_command if options[:CLI]
|
41
|
+
command ||= build_zeus_command if options[:zeus]
|
42
|
+
command ||= build_rails_command
|
43
|
+
"sh -c 'cd \"#{@root}\" && #{command} &'"
|
44
|
+
end
|
50
45
|
|
51
|
-
|
52
|
-
|
46
|
+
def environment
|
47
|
+
rails_env = if options[:zeus]
|
48
|
+
nil
|
49
|
+
else
|
50
|
+
options[:environment]
|
51
|
+
end
|
53
52
|
|
54
|
-
|
55
|
-
|
56
|
-
end
|
53
|
+
{ "RAILS_ENV" => rails_env }
|
54
|
+
end
|
57
55
|
|
58
|
-
|
59
|
-
|
60
|
-
|
56
|
+
def pid_file
|
57
|
+
@pid_file ||= File.expand_path(options[:pid_file] || File.join(@root, "tmp/pids/#{options[:environment]}.pid"))
|
58
|
+
end
|
61
59
|
|
62
|
-
|
63
|
-
|
64
|
-
|
60
|
+
def pid
|
61
|
+
has_pid? ? read_pid : nil
|
62
|
+
end
|
65
63
|
|
66
|
-
|
64
|
+
def sleep_time
|
65
|
+
options[:timeout].to_f / MAX_WAIT_COUNT.to_f
|
66
|
+
end
|
67
67
|
|
68
|
-
|
69
|
-
def build_options
|
70
|
-
rails_options = [
|
71
|
-
options[:daemon] ? '-d' : nil,
|
72
|
-
options[:debugger] ? '-u' : nil,
|
73
|
-
'-e', options[:environment],
|
74
|
-
'--pid', "\"#{pid_file}\"",
|
75
|
-
'-p', options[:port],
|
76
|
-
options[:server],
|
77
|
-
]
|
68
|
+
private
|
78
69
|
|
79
|
-
|
80
|
-
|
70
|
+
# command builders
|
71
|
+
def build_options
|
72
|
+
rails_options = [
|
73
|
+
options[:daemon] ? '-d' : nil,
|
74
|
+
options[:debugger] ? '-u' : nil,
|
75
|
+
'-e', options[:environment],
|
76
|
+
'--pid', "\"#{pid_file}\"",
|
77
|
+
'-p', options[:port],
|
78
|
+
options[:server],
|
79
|
+
]
|
81
80
|
|
82
|
-
|
83
|
-
|
84
|
-
end
|
81
|
+
rails_options.join(' ')
|
82
|
+
end
|
85
83
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
]
|
90
|
-
"zeus #{zeus_options.join(' ')} #{build_options}"
|
91
|
-
end
|
84
|
+
def build_cli_command
|
85
|
+
"#{options[:CLI]} --pid \"#{pid_file}\""
|
86
|
+
end
|
92
87
|
|
93
|
-
|
94
|
-
|
95
|
-
|
88
|
+
def build_zeus_command
|
89
|
+
zeus_options = [
|
90
|
+
options[:zeus_plan] || 'server',
|
91
|
+
]
|
92
|
+
"zeus #{zeus_options.join(' ')} #{build_options}"
|
93
|
+
end
|
96
94
|
|
97
|
-
|
98
|
-
|
99
|
-
::Bundler.with_clean_env { yield }
|
100
|
-
else
|
101
|
-
yield
|
95
|
+
def build_rails_command
|
96
|
+
"rails server #{build_options}"
|
102
97
|
end
|
103
|
-
end
|
104
98
|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
99
|
+
def without_bundler_env
|
100
|
+
if defined?(::Bundler)
|
101
|
+
::Bundler.with_clean_env { yield }
|
102
|
+
else
|
103
|
+
yield
|
104
|
+
end
|
110
105
|
end
|
111
|
-
end
|
112
106
|
|
113
|
-
|
114
|
-
|
115
|
-
|
107
|
+
def run_rails_command!
|
108
|
+
if options[:CLI] || options[:zeus]
|
109
|
+
without_bundler_env { system(environment, build_command) }
|
110
|
+
else
|
111
|
+
system(environment, build_command)
|
112
|
+
end
|
113
|
+
end
|
116
114
|
|
117
|
-
|
118
|
-
|
119
|
-
|
115
|
+
def has_pid?
|
116
|
+
File.file?(pid_file)
|
117
|
+
end
|
120
118
|
|
121
|
-
|
122
|
-
|
123
|
-
kill_process("KILL", pid)
|
124
|
-
remove_pid_file_and_wait_for_no_pid
|
119
|
+
def wait_for_pid_action
|
120
|
+
sleep sleep_time
|
125
121
|
end
|
126
|
-
end
|
127
122
|
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
return line.split("\s")[1]
|
123
|
+
def kill_unmanaged_pid!
|
124
|
+
if pid = unmanaged_pid
|
125
|
+
kill_process("KILL", pid)
|
126
|
+
remove_pid_file_and_wait_for_no_pid
|
133
127
|
end
|
134
|
-
|
135
|
-
|
136
|
-
|
128
|
+
end
|
129
|
+
|
130
|
+
def unmanaged_pid
|
131
|
+
file_list = `lsof -n -i TCP:#{options[:port]}`
|
132
|
+
file_list.each_line { |line|
|
133
|
+
if line["*:#{options[:port]} "]
|
134
|
+
return line.split("\s")[1].to_i
|
135
|
+
end
|
136
|
+
}
|
137
|
+
nil
|
138
|
+
end
|
137
139
|
|
138
|
-
|
140
|
+
private
|
139
141
|
|
140
|
-
|
141
|
-
|
142
|
-
|
142
|
+
def wait_for_pid
|
143
|
+
wait_for_pid_loop { has_pid? }
|
144
|
+
end
|
143
145
|
|
144
|
-
|
145
|
-
|
146
|
-
|
146
|
+
def wait_for_no_pid
|
147
|
+
wait_for_pid_loop { !has_pid? }
|
148
|
+
end
|
147
149
|
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
150
|
+
def remove_pid_file_and_wait_for_no_pid
|
151
|
+
wait_for_pid_loop do
|
152
|
+
FileUtils.rm pid_file, :force => true
|
153
|
+
!has_pid?
|
154
|
+
end
|
152
155
|
end
|
153
|
-
end
|
154
156
|
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
157
|
+
def wait_for_pid_loop
|
158
|
+
count = 0
|
159
|
+
while !yield && count < MAX_WAIT_COUNT
|
160
|
+
wait_for_pid_action
|
161
|
+
count += 1
|
162
|
+
end
|
163
|
+
!(count == MAX_WAIT_COUNT)
|
164
|
+
end
|
165
|
+
|
166
|
+
def kill_process(signal, pid)
|
167
|
+
begin
|
168
|
+
Process.kill(signal, pid)
|
169
|
+
true
|
170
|
+
rescue Errno::EPERM
|
171
|
+
UI.info "[Guard::Rails::Error] Don't have permission to KILL!"
|
172
|
+
false
|
173
|
+
rescue Errno::EINVAL, ArgumentError, Errno::ESRCH, RangeError
|
174
|
+
false
|
175
|
+
end
|
160
176
|
end
|
161
|
-
!(count == MAX_WAIT_COUNT)
|
162
|
-
end
|
163
177
|
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
rescue Errno::EINVAL, Errno::ESRCH, RangeError
|
169
|
-
false
|
178
|
+
def read_pid
|
179
|
+
Integer(File.read(pid_file))
|
180
|
+
rescue ArgumentError
|
181
|
+
nil
|
170
182
|
end
|
183
|
+
|
171
184
|
end
|
172
185
|
end
|
173
186
|
end
|
@@ -1,9 +1,8 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require 'guard/rails/runner'
|
3
2
|
require 'fakefs/spec_helpers'
|
4
3
|
|
5
|
-
describe Guard::
|
6
|
-
let(:runner) { Guard::
|
4
|
+
describe Guard::Rails::Runner do
|
5
|
+
let(:runner) { Guard::Rails::Runner.new(options) }
|
7
6
|
let(:environment) { 'development' }
|
8
7
|
let(:port) { 3000 }
|
9
8
|
|
@@ -207,7 +206,7 @@ describe Guard::RailsRunner do
|
|
207
206
|
end
|
208
207
|
end
|
209
208
|
|
210
|
-
context 'when guard-rails is
|
209
|
+
context 'when guard-rails is inside of bundler' do
|
211
210
|
before do
|
212
211
|
ENV['BUNDLE_GEMFILE'] = 'Gemfile'
|
213
212
|
end
|
@@ -231,6 +230,12 @@ describe Guard::RailsRunner do
|
|
231
230
|
context 'when guard-rails is outside of bundler' do
|
232
231
|
before do
|
233
232
|
ENV['BUNDLE_GEMFILE'] = nil
|
233
|
+
BundlerClass = Bundler
|
234
|
+
Object.send(:remove_const, :Bundler)
|
235
|
+
end
|
236
|
+
after do
|
237
|
+
Bundler = BundlerClass
|
238
|
+
Object.send(:remove_const, :BundlerClass)
|
234
239
|
end
|
235
240
|
|
236
241
|
context 'with default env' do
|
@@ -288,7 +293,7 @@ describe Guard::RailsRunner do
|
|
288
293
|
before do
|
289
294
|
pid_stub.returns(false)
|
290
295
|
kill_expectation.never
|
291
|
-
mock(runner).wait_for_pid_action.times(Guard::
|
296
|
+
mock(runner).wait_for_pid_action.times(Guard::Rails::Runner::MAX_WAIT_COUNT)
|
292
297
|
end
|
293
298
|
|
294
299
|
it "doesn't start" do
|
@@ -297,12 +302,132 @@ describe Guard::RailsRunner do
|
|
297
302
|
end
|
298
303
|
end
|
299
304
|
|
305
|
+
describe '#stop' do
|
306
|
+
include FakeFS::SpecHelpers
|
307
|
+
|
308
|
+
it 'stops' do
|
309
|
+
expect(runner.stop)
|
310
|
+
end
|
311
|
+
|
312
|
+
context 'when pid exists' do
|
313
|
+
let(:pid) { 12345 }
|
314
|
+
|
315
|
+
before do
|
316
|
+
FileUtils.mkdir_p File.split(runner.pid_file).first
|
317
|
+
File.open(runner.pid_file, 'w') { |f| f.print pid }
|
318
|
+
end
|
319
|
+
|
320
|
+
it 'removes the pid file' do
|
321
|
+
runner.stop
|
322
|
+
expect(File.exists?(runner.pid_file)).to be false
|
323
|
+
end
|
324
|
+
|
325
|
+
it 'kills the process with INT' do
|
326
|
+
mock(runner).kill_process.with("INT", pid).returns { true }
|
327
|
+
mock(runner).kill_process.with("KILL", pid).once
|
328
|
+
runner.stop
|
329
|
+
end
|
330
|
+
|
331
|
+
it 'kills the process with KILL when INT not work' do
|
332
|
+
mock(runner).kill_process.with("INT", pid).returns { false }
|
333
|
+
mock(runner).kill_process.with("KILL", pid).once
|
334
|
+
runner.stop
|
335
|
+
end
|
336
|
+
end
|
337
|
+
|
338
|
+
context "when pid file doesn't exist" do
|
339
|
+
it 'does nothing' do
|
340
|
+
runner.stop
|
341
|
+
mock(runner).kill_process.never
|
342
|
+
end
|
343
|
+
end
|
344
|
+
|
345
|
+
context "when pid file is empty" do
|
346
|
+
before do
|
347
|
+
FileUtils.mkdir_p File.split(runner.pid_file).first
|
348
|
+
File.open(runner.pid_file, 'w') { |f| f.print "" }
|
349
|
+
end
|
350
|
+
|
351
|
+
it 'does nothing' do
|
352
|
+
mock(runner).kill_process.never
|
353
|
+
runner.stop
|
354
|
+
end
|
355
|
+
|
356
|
+
it 'removes the pid file' do
|
357
|
+
runner.stop
|
358
|
+
expect(File.exists?(runner.pid_file)).to be false
|
359
|
+
end
|
360
|
+
|
361
|
+
end
|
362
|
+
end
|
363
|
+
|
364
|
+
describe '#restart' do
|
365
|
+
it 'calls stop and start' do
|
366
|
+
mock(runner).stop.once
|
367
|
+
mock(runner).start.once
|
368
|
+
runner.restart
|
369
|
+
end
|
370
|
+
end
|
371
|
+
|
372
|
+
describe '#kill_unmanaged_pid!' do
|
373
|
+
let(:pid) { 12345 }
|
374
|
+
|
375
|
+
it 'kill processes if any' do
|
376
|
+
mock(runner).unmanaged_pid.returns { pid }
|
377
|
+
mock(runner).kill_process.with("KILL", pid).once
|
378
|
+
runner.send(:kill_unmanaged_pid!)
|
379
|
+
end
|
380
|
+
|
381
|
+
it 'does nothing if none' do
|
382
|
+
mock(runner).unmanaged_pid.returns { nil }
|
383
|
+
mock(runner).kill_process.with("KILL", pid).never
|
384
|
+
runner.send(:kill_unmanaged_pid!)
|
385
|
+
end
|
386
|
+
end
|
387
|
+
|
388
|
+
describe '#unmanaged_pid' do
|
389
|
+
let(:pid) { 12345 }
|
390
|
+
|
391
|
+
it 'returns pid if any' do
|
392
|
+
mock(runner, :'`').with(anything).returns {
|
393
|
+
"ruby #{pid} ranmocy 12u IPv4 0x9c30720e04d31a0f 0t0 TCP *:#{port} (LISTEN)"
|
394
|
+
}
|
395
|
+
expect(runner.send(:unmanaged_pid)).to eq pid
|
396
|
+
end
|
397
|
+
|
398
|
+
it 'returns nil if none' do
|
399
|
+
mock(runner, :'`').with(anything).returns { "\n" }
|
400
|
+
expect(runner.send(:unmanaged_pid)).to be nil
|
401
|
+
end
|
402
|
+
end
|
403
|
+
|
404
|
+
describe '#kill_process' do
|
405
|
+
let(:signal) { 'INT' }
|
406
|
+
let(:fake_signal) { 'INT0' }
|
407
|
+
let(:pid) { 12345 }
|
408
|
+
|
409
|
+
it 'returns true if killed' do
|
410
|
+
mock(Process).kill(signal, pid) { 0 }
|
411
|
+
expect(runner.send(:kill_process, signal, pid)).to be true
|
412
|
+
end
|
413
|
+
|
414
|
+
it 'returns false if signal is wrong' do
|
415
|
+
expect(runner.send(:kill_process, fake_signal, pid)).to be false
|
416
|
+
end
|
417
|
+
|
418
|
+
it 'returns false if no permission to kill' do
|
419
|
+
mock(Process).kill(signal, pid) { raise Errno::EPERM }
|
420
|
+
mock(Guard::UI).info("[Guard::Rails::Error] Don't have permission to KILL!")
|
421
|
+
expect(runner.send(:kill_process, signal, pid)).to be false
|
422
|
+
end
|
423
|
+
end
|
424
|
+
|
300
425
|
describe '#sleep_time' do
|
301
426
|
let(:timeout) { 30 }
|
302
427
|
let(:options) { default_options.merge(:timeout => timeout) }
|
303
428
|
|
304
429
|
it "adjusts the sleep time as necessary" do
|
305
|
-
expect(runner.sleep_time).to eq (timeout.to_f / Guard::
|
430
|
+
expect(runner.sleep_time).to eq (timeout.to_f / Guard::Rails::Runner::MAX_WAIT_COUNT.to_f)
|
306
431
|
end
|
307
432
|
end
|
308
433
|
end
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require 'guard/rails'
|
3
2
|
|
4
3
|
describe Guard::Rails do
|
5
4
|
let(:guard) { Guard::Rails.new(options) }
|
@@ -39,14 +38,14 @@ describe Guard::Rails do
|
|
39
38
|
let(:pid) { '12345' }
|
40
39
|
|
41
40
|
before do
|
42
|
-
any_instance_of(Guard::
|
41
|
+
any_instance_of(Guard::Rails::Runner, pid: pid)
|
43
42
|
end
|
44
43
|
|
45
44
|
context 'at start' do
|
46
45
|
before do
|
47
46
|
mock(Guard::UI).info.with('Starting Rails...')
|
48
47
|
mock(Guard::Notifier).notify.with(/Rails starting/, hash_including(:image => :pending))
|
49
|
-
any_instance_of(Guard::
|
48
|
+
any_instance_of(Guard::Rails::Runner, restart: true)
|
50
49
|
end
|
51
50
|
|
52
51
|
it "starts and shows the pid file" do
|
@@ -59,14 +58,14 @@ describe Guard::Rails do
|
|
59
58
|
|
60
59
|
context "after start" do
|
61
60
|
before do
|
62
|
-
any_instance_of(Guard::
|
61
|
+
any_instance_of(Guard::Rails::Runner, pid: pid)
|
63
62
|
mock(Guard::UI).info.with('Restarting Rails...')
|
64
63
|
mock(Guard::Notifier).notify.with(/Rails restarting/, hash_including(:image => :pending))
|
65
64
|
end
|
66
65
|
|
67
66
|
context "with pid file" do
|
68
67
|
before do
|
69
|
-
any_instance_of(Guard::
|
68
|
+
any_instance_of(Guard::Rails::Runner, restart: true)
|
70
69
|
end
|
71
70
|
|
72
71
|
it "restarts and shows the pid file" do
|
@@ -79,7 +78,7 @@ describe Guard::Rails do
|
|
79
78
|
|
80
79
|
context "without pid file" do
|
81
80
|
before do
|
82
|
-
any_instance_of(Guard::
|
81
|
+
any_instance_of(Guard::Rails::Runner, restart: false)
|
83
82
|
end
|
84
83
|
|
85
84
|
it "restarts and shows the pid file" do
|
data/spec/spec_helper.rb
CHANGED
@@ -1,5 +1,12 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
if ENV['CI']
|
2
|
+
require "codeclimate-test-reporter"
|
3
|
+
CodeClimate::TestReporter.start
|
4
|
+
else
|
5
|
+
require 'simplecov'
|
6
|
+
SimpleCov.start
|
7
|
+
end
|
8
|
+
|
9
|
+
require 'guard/rails'
|
3
10
|
|
4
11
|
RSpec.configure do |c|
|
5
12
|
c.mock_with :rr
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: guard-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Bintz
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-11-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: guard
|