File tree Expand file tree Collapse file tree 1 file changed +66
-0
lines changed Expand file tree Collapse file tree 1 file changed +66
-0
lines changed Original file line number Diff line number Diff line change
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2025, by Samuel Williams.
5
+
6
+ require "async/container/statistics"
7
+
8
+ describe Async ::Container ::Statistics do
9
+ let ( :statistics ) { subject . new }
10
+
11
+ with "#spawn!" do
12
+ it "can count spawns" do
13
+ expect ( statistics . spawns ) . to be == 0
14
+
15
+ statistics . spawn!
16
+
17
+ expect ( statistics . spawns ) . to be == 1
18
+ end
19
+ end
20
+
21
+ with "#restart!" do
22
+ it "can count restarts" do
23
+ expect ( statistics . restarts ) . to be == 0
24
+
25
+ statistics . restart!
26
+
27
+ expect ( statistics . restarts ) . to be == 1
28
+ end
29
+ end
30
+
31
+ with "#failure!" do
32
+ it "can count failures" do
33
+ expect ( statistics . failures ) . to be == 0
34
+
35
+ statistics . failure!
36
+
37
+ expect ( statistics . failures ) . to be == 1
38
+ end
39
+ end
40
+
41
+ with "#failed?" do
42
+ it "can check for failures" do
43
+ expect ( statistics ) . not . to be ( :failed? )
44
+
45
+ statistics . failure!
46
+
47
+ expect ( statistics ) . to be ( :failed? )
48
+ end
49
+ end
50
+
51
+ with "#<<" do
52
+ it "can append statistics" do
53
+ other = subject . new
54
+
55
+ other . spawn!
56
+ other . restart!
57
+ other . failure!
58
+
59
+ statistics << other
60
+
61
+ expect ( statistics . spawns ) . to be == 1
62
+ expect ( statistics . restarts ) . to be == 1
63
+ expect ( statistics . failures ) . to be == 1
64
+ end
65
+ end
66
+ end
You can’t perform that action at this time.
0 commit comments