nio4r 2.7.0 → 2.7.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,93 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Released under the MIT License.
4
- # Copyright, 2012-2017, by Tony Arcieri.
5
- # Copyright, 2012, by Logan Bowers.
6
- # Copyright, 2013, by Tim Carey-Smith.
7
- # Copyright, 2017-2019, by Gregory Longtin.
8
- # Copyright, 2017, by Tiago Cardoso.
9
- # Copyright, 2019-2023, by Samuel Williams.
10
-
11
- RSpec.shared_context NIO::Selector do
12
- let(:selector) {@selector = NIO::Selector.new}
13
-
14
- after(:each) do
15
- if defined?(@selector)
16
- @selector.close
17
- end
18
- end
19
- end
20
-
21
- RSpec.shared_context "an NIO selectable" do
22
- include_context NIO::Selector
23
-
24
- it "selects readable objects" do
25
- monitor = selector.register(readable_subject, :r)
26
- ready = selector.select(1)
27
- expect(ready).to be_an Enumerable
28
- expect(ready).to include monitor
29
- end
30
-
31
- it "does not select unreadable objects" do
32
- selector.register(unreadable_subject, :r)
33
- expect(selector.select(0)).to be_nil
34
- end
35
-
36
- it "selects writable objects" do
37
- monitor = selector.register(writable_subject, :w)
38
- ready = selector.select(1)
39
- expect(ready).to be_an Enumerable
40
- expect(ready).to include monitor
41
- end
42
-
43
- it "does not select unwritable objects" do
44
- selector.register(unwritable_subject, :w)
45
- ready = selector.select(0)
46
- expect(ready).to be_nil
47
- end
48
- end
49
-
50
- RSpec.shared_context "an NIO selectable stream" do |is_tls13|
51
- include_context NIO::Selector
52
-
53
- let(:stream) { pair.first }
54
- let(:peer) { pair.last }
55
-
56
- it "selects readable when the other end closes" do
57
- monitor = selector.register(stream, :r)
58
- unless is_tls13
59
- expect(selector.select(1)).to be_nil
60
- end
61
-
62
- peer.close
63
- # Wait and give the TCP session time to close
64
- expect(selector.select(0.1)).to include monitor
65
- end
66
- end
67
-
68
- RSpec.shared_context "an NIO bidirectional stream" do
69
- include_context NIO::Selector
70
-
71
- let(:stream) {pair.first}
72
- let(:peer) {pair.last}
73
-
74
- it "selects readable and writable" do
75
- selector.register(readable_subject, :rw)
76
-
77
- selector.select(1) do |monitor|
78
- expect(monitor.readiness).to eq(:rw)
79
- end
80
-
81
- readable_subject.close
82
- end
83
-
84
- it "keeps readiness after the selectable has been closed" do
85
- selector.register(readable_subject, :rw)
86
-
87
- selector.select(1) do |monitor|
88
- expect(monitor.readiness).to eq(:rw)
89
- readable_subject.close
90
- expect(monitor.readiness).to eq(:rw)
91
- end
92
- end
93
- end