async-rspec 1.2.0 → 1.3.0

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
  SHA256:
3
- metadata.gz: 4186b47c672f3a320cdebcccf6ba46b40457ad82683883c832b96ba4d6f11ace
4
- data.tar.gz: 5a7843539aedc0b9f66dca87106f24f9c28f831507be98755e1e839853f81b32
3
+ metadata.gz: 2cb1fb4f59a7f05ba63b18e9f2b44b07364b711422fe1870d556a4a57e6e53f9
4
+ data.tar.gz: a487cd7d0f93e0dd6dba63d2c7d53e741ab7b6db26c799586eaee886137bbfc8
5
5
  SHA512:
6
- metadata.gz: 7380969198beb4a1cd5398136bdebc9d4942103eeefed2cb1fcdad5b4c6be81592333dd20b5613711bd11a3d0d6deec9b26dd9f36d20a4ed0f6ceb36bd319076
7
- data.tar.gz: d7944d2dc3f14bf60f52d4fca2ff040d647d64cdafc2088abf65f789bf7815c55b655a7027dd012822cbcfe1f473e9f419d43730232b0cb1b0b55793f42f1759
6
+ metadata.gz: 8247782ea3f2dc73d5bd72df2a35d917240c8a5fe9c5f12785297c56f4c46ffd4be8e7be7d2637fdf31ffd3c05492b8df1b31f5e9695ccfcc1a4165d4af2ef67
7
+ data.tar.gz: 3868142cdde06ebc353e1673702e3a33e7a2be9aafe96106f13f9601f63433b9dc71a364755503d656a0e5d00cccd93dca56c6d8384313dc0943b714cf3f428f
@@ -32,13 +32,11 @@ module Async
32
32
  RSpec.shared_context Leaks do
33
33
  include Leaks
34
34
 
35
- let(:before_ios) {current_ios}
35
+ let!(:before_ios) {current_ios}
36
36
  let(:after_ios) {current_ios}
37
37
 
38
38
  # We use around(:each) because it's the highest priority.
39
39
  around(:each) do |example|
40
- before_ios
41
-
42
40
  example.run.tap do
43
41
  expect(after_ios).to be == before_ios
44
42
  end
@@ -23,31 +23,32 @@ require 'async/reactor'
23
23
 
24
24
  module Async
25
25
  module RSpec
26
- class Reactor
27
- def self.current_ios(gc: GC.start)
28
- all_ios = ObjectSpace.each_object(IO).to_a.sort_by(&:object_id)
29
-
30
- # We are not interested in ios that have been closed already:
31
- return all_ios.reject{|io| io.closed?}
32
- end
33
- end
34
-
35
- RSpec.shared_context Reactor do
36
- let(:reactor) {Async::Task.current.reactor}
37
-
38
- include_context Async::RSpec::Leaks
39
-
40
- def run_reactor(example)
26
+ module Reactor
27
+ def run_reactor(example, duration = nil)
41
28
  result = nil
42
29
 
30
+ duration ||= example.metadata[:timeout] || 60
31
+
43
32
  Async::Reactor.run do |task|
44
- result = example.run
33
+ task.timeout(duration) do
34
+ result = example.run
35
+
36
+ task.children.each(&:wait)
37
+ end
45
38
 
46
39
  task.reactor.stop if result.is_a? Exception
47
40
  end
48
41
 
49
42
  return result
50
43
  end
44
+ end
45
+
46
+ RSpec.shared_context Reactor do
47
+ include Reactor
48
+
49
+ let(:reactor) {Async::Task.current.reactor}
50
+
51
+ include_context Async::RSpec::Leaks
51
52
 
52
53
  around(:each) do |example|
53
54
  run_reactor(example)
@@ -20,6 +20,6 @@
20
20
 
21
21
  module Async
22
22
  module RSpec
23
- VERSION = "1.2.0"
23
+ VERSION = "1.3.0"
24
24
  end
25
25
  end
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.2.0
4
+ version: 1.3.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-02-01 00:00:00.000000000 Z
11
+ date: 2018-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -119,7 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
119
119
  version: '0'
120
120
  requirements: []
121
121
  rubyforge_project:
122
- rubygems_version: 2.7.2
122
+ rubygems_version: 2.7.6
123
123
  signing_key:
124
124
  specification_version: 4
125
125
  summary: Helpers for writing specs against the async gem.