|
72 | 72 | expect(subject.format_count(1000000, custom_units)).to be == "1000.0K" |
73 | 73 | end |
74 | 74 |
|
75 | | - it "handles empty units array" do |
76 | | - expect(subject.format_count(1000, [])).to be == "1000.0" |
77 | | - end |
78 | | - |
79 | | - it "handles single nil unit" do |
80 | | - expect(subject.format_count(1000, [nil])).to be == "1000.0" |
81 | | - end |
| 75 | + it "handles empty units array" do |
| 76 | + expect(subject.format_count(1000, [])).to be == "1000" |
82 | 77 | end |
| 78 | + |
| 79 | + it "handles single nil unit" do |
| 80 | + expect(subject.format_count(1000, [nil])).to be == "1000" |
| 81 | + end end |
83 | 82 | end |
84 | 83 |
|
85 | 84 | with "#format_ratio" do |
86 | 85 | it "formats ratios with appropriate units" do |
87 | | - expect(subject.format_ratio(23, 3420)).to be == "23.0/3.42K" |
88 | | - expect(subject.format_ratio(2, 3420)).to be == "2.0/3.42K" |
| 86 | + expect(subject.format_ratio(23, 3420)).to be == "23/3.42K" |
| 87 | + expect(subject.format_ratio(2, 3420)).to be == "2/3.42K" |
89 | 88 | end |
90 | 89 |
|
91 | 90 | it "handles large ratios" do |
92 | 91 | expect(subject.format_ratio(1500000, 2340000000)).to be == "1.5M/2.34B" |
93 | 92 | end |
94 | 93 |
|
95 | 94 | it "handles small ratios" do |
96 | | - expect(subject.format_ratio(5, 100)).to be == "5.0/100.0" |
| 95 | + expect(subject.format_ratio(5, 100)).to be == "5/100" |
97 | 96 | end |
98 | 97 |
|
99 | 98 | it "handles zero values" do |
100 | | - expect(subject.format_ratio(0, 1000)).to be == "0.0/1.0K" |
101 | | - expect(subject.format_ratio(100, 0)).to be == "100.0/0.0" |
| 99 | + expect(subject.format_ratio(0, 1000)).to be == "0/1.0K" |
| 100 | + expect(subject.format_ratio(100, 0)).to be == "100/0" |
102 | 101 | end |
103 | 102 | end |
104 | 103 |
|
|
118 | 117 | with "#format_statistics" do |
119 | 118 | it "formats single values" do |
120 | 119 | result = subject.format_statistics(connections: 23) |
121 | | - expect(result).to be == "CONNECTIONS=23.0" |
| 120 | + expect(result).to be == "CONNECTIONS=23" |
122 | 121 | end |
123 | 122 |
|
124 | 123 | it "formats ratios from arrays" do |
125 | 124 | result = subject.format_statistics(c: [23, 3420]) |
126 | | - expect(result).to be == "C=23.0/3.42K" |
| 125 | + expect(result).to be == "C=23/3.42K" |
127 | 126 | end |
128 | 127 |
|
129 | 128 | it "formats multiple statistics" do |
130 | 129 | result = subject.format_statistics( |
131 | 130 | c: [23, 3420], |
132 | 131 | r: [2, 3420] |
133 | 132 | ) |
134 | | - expect(result).to be == "C=23.0/3.42K R=2.0/3.42K" |
| 133 | + expect(result).to be == "C=23/3.42K R=2/3.42K" |
135 | 134 | end |
136 | 135 |
|
137 | 136 | it "handles mixed statistic types" do |
|
140 | 139 | active: 5, |
141 | 140 | load: 0.273 |
142 | 141 | ) |
143 | | - expect(result).to be == "CONNECTIONS=23.0/3.42K ACTIVE=5.0 LOAD=0.27" |
| 142 | + expect(result).to be == "CONNECTIONS=23/3.42K ACTIVE=5 LOAD=0.27" |
144 | 143 | end |
145 | 144 |
|
146 | 145 | it "handles arrays with more than 2 elements" do |
|
158 | 157 | :symbol_key => 100, |
159 | 158 | "string_key" => 200 |
160 | 159 | ) |
161 | | - expect(result).to be == "SYMBOL_KEY=100.0 STRING_KEY=200.0" |
| 160 | + expect(result).to be == "SYMBOL_KEY=100 STRING_KEY=200" |
162 | 161 | end |
163 | 162 | end |
164 | 163 |
|
|
175 | 174 | r: [active_count, request_count] |
176 | 175 | ) |
177 | 176 |
|
178 | | - expect(statistics).to be == "C=23.0/3.42K R=2.0/3.42K" |
| 177 | + expect(statistics).to be == "C=23/3.42K R=2/3.42K" |
179 | 178 | end |
180 | 179 |
|
181 | 180 | it "formats process title information" do |
|
192 | 191 | ) |
193 | 192 |
|
194 | 193 | process_title = "#{service_name} (#{stats} L=#{formatted_load})" |
195 | | - expect(process_title).to be == "web-server (C=23.0/3.42K R=2.0/3.42K L=0.27)" |
| 194 | + expect(process_title).to be == "web-server (C=23/3.42K R=2/3.42K L=0.27)" |
196 | 195 | end |
197 | 196 | end |
198 | 197 | end |
0 commit comments