rspec_runner 0.1.4 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/rspec_runner +1 -1
- data/lib/rspec_runner/monitor.rb +6 -31
- data/lib/rspec_runner/server.rb +53 -8
- data/lib/rspec_runner/version.rb +1 -1
- data/lib/rspec_runner/watcher.rb +1 -1
- 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: 068cee9187e40f7479ace40250ecfea90a7977ba
|
4
|
+
data.tar.gz: c637235611c38bd7bdc9b817c47b11ff1c2d8368
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 76d15ffba43111a859ef7646b4d6c4e8f5ed61481764cb20602a061c054646f17637a5cb0f6208c978cb450e46b8bcba5ba70edb10f853dac143f747bba4d7f7
|
7
|
+
data.tar.gz: b7d6cecf3503bdec8bc90b357f47bfbf7f3bd5503ebdca64bbae429929ebaf12a942451b44879f0662ed1449609a12f814357d2ce745ab3674c7803478c645f8
|
data/bin/rspec_runner
CHANGED
data/lib/rspec_runner/monitor.rb
CHANGED
@@ -1,20 +1,17 @@
|
|
1
|
-
require 'open3'
|
2
1
|
require 'rspec_runner/server'
|
3
2
|
require 'rspec_runner/watcher'
|
4
3
|
|
5
4
|
module RspecRunner
|
6
5
|
class Monitor
|
7
|
-
CMD = 'bundle exec rspec_runner start'.freeze
|
8
|
-
|
9
6
|
class << self
|
10
|
-
def
|
11
|
-
start
|
7
|
+
def start
|
8
|
+
RspecRunner::Server.start
|
12
9
|
|
13
|
-
at_exit {
|
10
|
+
at_exit { stop }
|
14
11
|
|
15
|
-
watcher_thread = Watcher.
|
12
|
+
watcher_thread = Watcher.start do |changes|
|
16
13
|
puts 'Restarting...'
|
17
|
-
restart
|
14
|
+
RspecRunner::Server.restart
|
18
15
|
end
|
19
16
|
|
20
17
|
watcher_thread.join
|
@@ -23,32 +20,10 @@ module RspecRunner
|
|
23
20
|
|
24
21
|
private
|
25
22
|
|
26
|
-
def start
|
27
|
-
@pid = fork { RspecRunner::Server.run }
|
28
|
-
Process.detach(@pid) # so if the child exits, it dies
|
29
|
-
end
|
30
|
-
|
31
23
|
def stop
|
32
|
-
|
33
|
-
# TODO: try to kill without -9
|
34
|
-
send_signal('KILL')
|
35
|
-
RspecRunner::Server.stop
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
def send_signal(signal)
|
40
|
-
Process.kill(signal, @pid)
|
41
|
-
end
|
42
|
-
|
43
|
-
def die
|
44
|
-
stop
|
24
|
+
RspecRunner::Server.stop
|
45
25
|
exit 0
|
46
26
|
end
|
47
|
-
|
48
|
-
def restart
|
49
|
-
stop
|
50
|
-
start
|
51
|
-
end
|
52
27
|
end
|
53
28
|
end
|
54
29
|
end
|
data/lib/rspec_runner/server.rb
CHANGED
@@ -5,19 +5,32 @@ require 'rspec_runner/configuration'
|
|
5
5
|
module RspecRunner
|
6
6
|
class Server
|
7
7
|
class << self
|
8
|
-
def
|
9
|
-
puts '
|
8
|
+
def start
|
9
|
+
puts 'Preloading gems...'
|
10
|
+
require 'rubygems'
|
11
|
+
require 'bundler'
|
12
|
+
|
13
|
+
Bundler.load.dependencies.reject! do |d|
|
14
|
+
spec = d.to_spec
|
15
|
+
|
16
|
+
if spec.gem_dir == Dir.pwd
|
17
|
+
@gem_name = spec.name
|
18
|
+
else
|
19
|
+
spec.name == 'rspec_runner'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
if gem?
|
24
|
+
Bundler.require(:default, :development)
|
25
|
+
else
|
26
|
+
Bundler.require(:default, :test)
|
27
|
+
end
|
10
28
|
|
11
29
|
$LOAD_PATH.unshift File.expand_path("#{Dir.pwd}/spec")
|
12
|
-
require 'rspec'
|
13
|
-
require 'spec_helper.rb'
|
14
30
|
|
15
|
-
|
16
|
-
puts 'Server started!'
|
31
|
+
fork_process
|
17
32
|
|
18
33
|
at_exit { stop }
|
19
|
-
|
20
|
-
DRb.thread.join
|
21
34
|
end
|
22
35
|
|
23
36
|
def execute(path)
|
@@ -27,12 +40,44 @@ module RspecRunner
|
|
27
40
|
reset_rspec!
|
28
41
|
end
|
29
42
|
|
43
|
+
def restart
|
44
|
+
stop
|
45
|
+
fork_process
|
46
|
+
end
|
47
|
+
|
30
48
|
def stop
|
49
|
+
if @pid && @pid != 0
|
50
|
+
# TODO: try to kill without -9
|
51
|
+
send_signal('KILL')
|
52
|
+
end
|
31
53
|
File.delete(RspecRunner.configuration.uri_filepath) if File.exist?(RspecRunner.configuration.uri_filepath)
|
32
54
|
end
|
33
55
|
|
34
56
|
private
|
35
57
|
|
58
|
+
def gem?
|
59
|
+
!!@gem_name
|
60
|
+
end
|
61
|
+
|
62
|
+
def fork_process
|
63
|
+
@pid = fork do
|
64
|
+
puts 'Preloading dependencies...'
|
65
|
+
require @gem_name if gem?
|
66
|
+
require 'spec_helper.rb'
|
67
|
+
|
68
|
+
DRb.start_service(assign_uri, self)
|
69
|
+
puts 'Server started!'
|
70
|
+
|
71
|
+
DRb.thread.join
|
72
|
+
end
|
73
|
+
|
74
|
+
Process.detach(@pid) # so if the child exits, it dies
|
75
|
+
end
|
76
|
+
|
77
|
+
def send_signal(signal)
|
78
|
+
Process.kill(signal, @pid)
|
79
|
+
end
|
80
|
+
|
36
81
|
def assign_uri
|
37
82
|
socket = Socket.new(:INET, :STREAM, 0)
|
38
83
|
socket.bind(Addrinfo.tcp('127.0.0.1'.freeze, 0))
|
data/lib/rspec_runner/version.rb
CHANGED
data/lib/rspec_runner/watcher.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec_runner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- exAspArk
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|