async-rspec 1.4.0 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/async-rspec.gemspec +1 -1
- data/lib/async/rspec/reactor.rb +41 -10
- data/lib/async/rspec/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4662aa08daa03184f72a9447f5c7d8567bd35f89692695f71febab03d4897297
|
4
|
+
data.tar.gz: d68401193d009f2fb6147e325628f65b76e53e2e921946464cfc1fe63985e9fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ca947cc355d74542beec3b42de5e1c12dda183ff82cf119dc5537e6069842ede90995beafd2d597ecfd8e92cf4919237098ec187a50fd5ae5fa9bbdb59ccd7c
|
7
|
+
data.tar.gz: afd1957e91eab763e8ed16fe5a53820ebb88b6263d5bffcab789bce9d229be04e2e1e31f2346b751e99b8c8017ec668b3d8a5ad0ec5dee4287ce3c1d34050930
|
data/async-rspec.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.add_dependency "rspec", "~> 3.0"
|
20
20
|
|
21
21
|
# Since we test the shared contexts, we need some bits of async:
|
22
|
-
spec.add_development_dependency "async"
|
22
|
+
spec.add_development_dependency "async", "~> 1.8"
|
23
23
|
spec.add_development_dependency "ruby-prof"
|
24
24
|
|
25
25
|
spec.add_development_dependency "bundler", "~> 1.13"
|
data/lib/async/rspec/reactor.rb
CHANGED
@@ -19,24 +19,49 @@
|
|
19
19
|
# THE SOFTWARE.
|
20
20
|
|
21
21
|
require_relative 'leaks'
|
22
|
+
|
22
23
|
require 'async/reactor'
|
24
|
+
require 'async/debug/selector'
|
23
25
|
|
24
26
|
module Async
|
25
27
|
module RSpec
|
26
28
|
module Reactor
|
27
|
-
def
|
29
|
+
def run_example(reactor, example, duration)
|
28
30
|
result = nil
|
29
31
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
task.
|
32
|
+
reactor.run do |task|
|
33
|
+
task.annotate(self.class)
|
34
|
+
|
35
|
+
reactor = task.reactor
|
36
|
+
timer = nil
|
37
|
+
|
38
|
+
if duration
|
39
|
+
timer = reactor.async do |task|
|
40
|
+
task.annotate("timer task duration=#{duration}")
|
41
|
+
task.sleep(duration)
|
42
|
+
|
43
|
+
buffer = StringIO.new
|
44
|
+
reactor.print_hierarchy(buffer)
|
45
|
+
|
46
|
+
reactor.stop
|
47
|
+
|
48
|
+
raise TimeoutError, "run time exceeded duration #{duration}s:\r\n#{buffer.string}"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
task.async do |spec_task|
|
53
|
+
spec_task.annotate("example runner")
|
54
|
+
|
34
55
|
result = example.run
|
35
56
|
|
36
|
-
|
37
|
-
|
57
|
+
if result.is_a? Exception
|
58
|
+
reactor.stop
|
59
|
+
else
|
60
|
+
spec_task.children.each(&:wait)
|
61
|
+
end
|
62
|
+
end.wait
|
38
63
|
|
39
|
-
|
64
|
+
timer.stop if timer
|
40
65
|
end
|
41
66
|
|
42
67
|
return result
|
@@ -46,12 +71,18 @@ module Async
|
|
46
71
|
RSpec.shared_context Reactor do
|
47
72
|
include Reactor
|
48
73
|
|
49
|
-
let(:reactor) {Async::
|
74
|
+
let(:reactor) {Async::Reactor.new(selector: Async::Debug::Selector.new)}
|
50
75
|
|
51
76
|
include_context Async::RSpec::Leaks
|
52
77
|
|
53
78
|
around(:each) do |example|
|
54
|
-
|
79
|
+
duration = example.metadata.fetch(:timeout, 60)
|
80
|
+
|
81
|
+
begin
|
82
|
+
run_example(reactor, example, duration)
|
83
|
+
ensure
|
84
|
+
reactor.close
|
85
|
+
end
|
55
86
|
end
|
56
87
|
end
|
57
88
|
end
|
data/lib/async/rspec/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: async-rspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-04-
|
11
|
+
date: 2018-04-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -28,16 +28,16 @@ dependencies:
|
|
28
28
|
name: async
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '1.8'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '1.8'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: ruby-prof
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|