rmuh 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/.rubocop.yml +5 -0
- data/.travis.yml +1 -0
- data/README.md +14 -0
- data/examples/basic_parsing.rb +1 -2
- data/examples/basic_serverstats.rb +1 -1
- data/examples/serverstats_advanced.rb +1 -1
- data/examples/serverstats_cache.rb +1 -1
- data/examples/uolog_parsing.rb +2 -3
- data/examples/uorpt_parsing.rb +1 -2
- data/lib/rmuh/rpt.rb +4 -0
- data/lib/rmuh/rpt/log/formatters/base.rb +18 -0
- data/lib/rmuh/rpt/log/formatters/unitedoperationslog.rb +51 -0
- data/lib/rmuh/rpt/log/formatters/unitedoperationsrpt.rb +118 -0
- data/lib/rmuh/rpt/log/parsers/unitedoperationslog.rb +13 -2
- data/lib/rmuh/rpt/log/util/unitedoperations.rb +13 -11
- data/lib/rmuh/rpt/log/util/unitedoperationslog.rb +11 -3
- data/lib/rmuh/version.rb +1 -1
- data/rmuh.gemspec +3 -3
- data/spec/functional/examples_spec.rb +1 -1
- data/spec/unit/rmuh/rpt/log/formatters/base_spec.rb +42 -0
- data/spec/unit/rmuh/rpt/log/formatters/unitedoperationslog_spec.rb +198 -0
- data/spec/unit/rmuh/rpt/log/formatters/unitedoperationsrpt_spec.rb +757 -0
- data/spec/unit/rmuh/rpt/log/parsers/unitedoperationslog_spec.rb +43 -25
- data/spec/unit/rmuh/rpt/log/parsers/unitedoperationsrpt_spec.rb +2 -2
- data/spec/unit/rmuh/rpt/log/util/unitedoperations_spec.rb +13 -13
- data/spec/unit/rmuh/rpt/log/util/unitedoperationslog_spec.rb +59 -29
- data/spec/unit/rmuh/rpt_spec.rb +6 -6
- data/spec/unit/rmuh/serverstats/base.rb +10 -9
- metadata +59 -55
@@ -65,12 +65,12 @@ describe RMuh::RPT::Log::Parsers::UnitedOperationsLog do
|
|
65
65
|
|
66
66
|
it 'should not include chat by default' do
|
67
67
|
u = uolog.instance_variable_get(:@include_chat)
|
68
|
-
expect(u).to
|
68
|
+
expect(u).to be_falsey
|
69
69
|
end
|
70
70
|
|
71
71
|
it 'should convert to zulu by default' do
|
72
72
|
u = uolog.instance_variable_get(:@to_zulu)
|
73
|
-
expect(u).to
|
73
|
+
expect(u).to be_truthy
|
74
74
|
end
|
75
75
|
|
76
76
|
it 'should use the UO timezone by default' do
|
@@ -193,7 +193,7 @@ describe RMuh::RPT::Log::Parsers::UnitedOperationsLog do
|
|
193
193
|
it 'should set date as today if line (0400-2359) and now same range ' do
|
194
194
|
tz = uolog.instance_variable_get(:@timezone)
|
195
195
|
l = yday_line.dup
|
196
|
-
uolog.
|
196
|
+
allow(uolog).to receive(:date_of_line_based_on_now).and_return(tz.now)
|
197
197
|
uolog.send(:when_am_i!, l)
|
198
198
|
expect(l[:year]).to eql tz.now.year
|
199
199
|
expect(l[:month]).to eql tz.now.month
|
@@ -204,7 +204,8 @@ describe RMuh::RPT::Log::Parsers::UnitedOperationsLog do
|
|
204
204
|
d = RMuh::RPT::Log::Util::UnitedOperationsLog::ONE_DAY
|
205
205
|
tz = uolog.instance_variable_get(:@timezone)
|
206
206
|
l = yday_line.dup
|
207
|
-
uolog.
|
207
|
+
allow(uolog).to receive(:date_of_line_based_on_now)
|
208
|
+
.and_return(tz.now - d)
|
208
209
|
uolog.send(:when_am_i!, l)
|
209
210
|
expect(l[:year]).to eql((tz.now - d).year)
|
210
211
|
expect(l[:month]).to eql((tz.now - d).month)
|
@@ -237,22 +238,39 @@ describe RMuh::RPT::Log::Parsers::UnitedOperationsLog do
|
|
237
238
|
it 'should call where_am_i! and set the year/month/day' do
|
238
239
|
l = { hour: 4, min: 0, sec: 0 }
|
239
240
|
x = uolog.send(:line_modifiers, l)
|
240
|
-
expect(x.key?(:year)).to
|
241
|
-
expect(x.key?(:month)).to
|
242
|
-
expect(x.key?(:day)).to
|
241
|
+
expect(x.key?(:year)).to be_truthy
|
242
|
+
expect(x.key?(:month)).to be_truthy
|
243
|
+
expect(x.key?(:day)).to be_truthy
|
243
244
|
end
|
244
245
|
|
245
246
|
it 'sould call zulu! and set the time to zulu' do
|
246
247
|
l = { hour: 4, min: 0, sec: 0 }
|
247
248
|
x = uolog.send(:line_modifiers, l)
|
248
|
-
expect(x.key?(:iso8601)).to
|
249
|
-
expect(x.key?(:dtg)).to
|
249
|
+
expect(x.key?(:iso8601)).to be_truthy
|
250
|
+
expect(x.key?(:dtg)).to be_truthy
|
250
251
|
end
|
251
252
|
|
252
253
|
it 'should call add_guid! and add the event_guid' do
|
253
254
|
l = { hour: 4, min: 0, sec: 0 }
|
254
255
|
x = uolog.send(:line_modifiers, l)
|
255
|
-
expect(x.key?(:event_guid)).to
|
256
|
+
expect(x.key?(:event_guid)).to be_truthy
|
257
|
+
end
|
258
|
+
|
259
|
+
context 'when a user join event' do
|
260
|
+
it 'should call strip_port!' do
|
261
|
+
l = { hour: 4, min: 0, sec: 0, type: :connect, net: '127.0.0.1:443' }
|
262
|
+
x = uolog.send(:line_modifiers, l)
|
263
|
+
expect(x.key?(:ipaddr)).to be_truthy
|
264
|
+
expect(x.key?(:net)).to be_falsey
|
265
|
+
end
|
266
|
+
end
|
267
|
+
|
268
|
+
context 'when not a user joint event' do
|
269
|
+
it 'should not call strip_port!' do
|
270
|
+
l = { hour: 4, min: 0, sec: 0, type: :x, net: '127.0.0.1:443' }
|
271
|
+
x = uolog.send(:line_modifiers, l)
|
272
|
+
expect(x.key?(:net)).to be_truthy
|
273
|
+
end
|
256
274
|
end
|
257
275
|
end
|
258
276
|
|
@@ -307,23 +325,23 @@ describe RMuh::RPT::Log::Parsers::UnitedOperationsLog do
|
|
307
325
|
u = RMuh::RPT::Log::Parsers::UnitedOperationsLog.new
|
308
326
|
expect(
|
309
327
|
u.send(:regex_matches, StringIO.new(chat_line)).empty?
|
310
|
-
).to
|
328
|
+
).to be_truthy
|
311
329
|
end
|
312
330
|
|
313
331
|
it 'should compact the Array' do
|
314
332
|
l = StringIO.new("Something1\nSomething2\n")
|
315
333
|
x = uolog.send(:regex_matches, l)
|
316
|
-
expect(x.include?(nil)).to
|
334
|
+
expect(x.include?(nil)).to be_falsey
|
317
335
|
end
|
318
336
|
|
319
337
|
it 'should call #line_modifiers' do
|
320
338
|
x = uolog.send(:regex_matches, StringIO.new(guid_line))
|
321
|
-
expect(x[0].key?(:year)).to
|
322
|
-
expect(x[0].key?(:month)).to
|
323
|
-
expect(x[0].key?(:day)).to
|
324
|
-
expect(x[0].key?(:iso8601)).to
|
325
|
-
expect(x[0].key?(:dtg)).to
|
326
|
-
expect(x[0].key?(:event_guid)).to
|
339
|
+
expect(x[0].key?(:year)).to be_truthy
|
340
|
+
expect(x[0].key?(:month)).to be_truthy
|
341
|
+
expect(x[0].key?(:day)).to be_truthy
|
342
|
+
expect(x[0].key?(:iso8601)).to be_truthy
|
343
|
+
expect(x[0].key?(:dtg)).to be_truthy
|
344
|
+
expect(x[0].key?(:event_guid)).to be_truthy
|
327
345
|
end
|
328
346
|
end
|
329
347
|
|
@@ -379,13 +397,13 @@ describe RMuh::RPT::Log::Parsers::UnitedOperationsLog do
|
|
379
397
|
|
380
398
|
it 'should call #regex_matches' do
|
381
399
|
x = uolog.parse(StringIO.new(guid_line))
|
382
|
-
expect(x[0].key?(:type)).to
|
383
|
-
expect(x[0].key?(:year)).to
|
384
|
-
expect(x[0].key?(:month)).to
|
385
|
-
expect(x[0].key?(:day)).to
|
386
|
-
expect(x[0].key?(:iso8601)).to
|
387
|
-
expect(x[0].key?(:dtg)).to
|
388
|
-
expect(x[0].key?(:event_guid)).to
|
400
|
+
expect(x[0].key?(:type)).to be_truthy
|
401
|
+
expect(x[0].key?(:year)).to be_truthy
|
402
|
+
expect(x[0].key?(:month)).to be_truthy
|
403
|
+
expect(x[0].key?(:day)).to be_truthy
|
404
|
+
expect(x[0].key?(:iso8601)).to be_truthy
|
405
|
+
expect(x[0].key?(:dtg)).to be_truthy
|
406
|
+
expect(x[0].key?(:event_guid)).to be_truthy
|
389
407
|
end
|
390
408
|
end
|
391
409
|
end
|
@@ -140,7 +140,7 @@ describe RMuh::RPT::Log::Parsers::UnitedOperationsRPT do
|
|
140
140
|
end
|
141
141
|
|
142
142
|
it 'should set @to_zulu to true if nothing provided' do
|
143
|
-
expect(uorpt.instance_variable_get(:@to_zulu)).to
|
143
|
+
expect(uorpt.instance_variable_get(:@to_zulu)).to be_truthy
|
144
144
|
end
|
145
145
|
|
146
146
|
it 'should set @timezone to America/Los_Angeles if nothing provided' do
|
@@ -243,7 +243,7 @@ describe RMuh::RPT::Log::Parsers::UnitedOperationsRPT do
|
|
243
243
|
it 'should return an Array of hashes if a line matches' do
|
244
244
|
x = uorpt.parse(loglines)
|
245
245
|
expect(x).to be_an_instance_of Array
|
246
|
-
expect(x.empty?).to
|
246
|
+
expect(x.empty?).to be_falsey
|
247
247
|
x.each { |y| expect(y).to be_an_instance_of Hash }
|
248
248
|
end
|
249
249
|
end
|
@@ -9,7 +9,7 @@ describe RMuh::RPT::Log::Util::UnitedOperations do
|
|
9
9
|
@uo_util.extend(RMuh::RPT::Log::Util::UnitedOperations)
|
10
10
|
@mi = Regexp.new(
|
11
11
|
'(?<year>\d+)/(?<month>\d+)/(?<day>\d+)'\
|
12
|
-
'\s(?<hour>\d+):(?<min>\d+):(?<sec>\d+)'
|
12
|
+
'\s(?<hour>\d+):(?<min>\d+):(?<sec>\d+)\s(?<player_num>\d+)'
|
13
13
|
)
|
14
14
|
@mf = Regexp.new(
|
15
15
|
'(?<server_time>[0-9.]+)\s(?<damage>[0-9.]+)\s(?<distance>[0-9.]+)'
|
@@ -44,7 +44,7 @@ describe RMuh::RPT::Log::Util::UnitedOperations do
|
|
44
44
|
t.strftime('%Y-%m-%dT%H:%M:%SZ')
|
45
45
|
end
|
46
46
|
let(:zulued) do
|
47
|
-
ml = @uo_util.m_to_h(@mi.match('2013/12/31 16:00:00'))
|
47
|
+
ml = @uo_util.m_to_h(@mi.match('2013/12/31 16:00:00 0'))
|
48
48
|
@uo_util.zulu!(ml, uo_tz)
|
49
49
|
end
|
50
50
|
|
@@ -57,7 +57,7 @@ describe RMuh::RPT::Log::Util::UnitedOperations do
|
|
57
57
|
end
|
58
58
|
|
59
59
|
it 'should return a Hash' do
|
60
|
-
ml = @uo_util.m_to_h(@mi.match('2013/12/31 16:00:00'))
|
60
|
+
ml = @uo_util.m_to_h(@mi.match('2013/12/31 16:00:00 0'))
|
61
61
|
mr = @uo_util.zulu!(ml, uo_tz)
|
62
62
|
expect(mr).to be_an_instance_of Hash
|
63
63
|
end
|
@@ -165,42 +165,42 @@ describe RMuh::RPT::Log::Util::UnitedOperations do
|
|
165
165
|
it 'should properly set the :event_guid for killed' do
|
166
166
|
x = @uo_util.add_guid!(spec_killed_line)
|
167
167
|
y = spec_guid_reference_implementation(spec_killed_line)
|
168
|
-
expect(x.key?(:event_guid)).to
|
168
|
+
expect(x.key?(:event_guid)).to be_truthy
|
169
169
|
expect(x[:event_guid]).to eql y[:event_guid]
|
170
170
|
end
|
171
171
|
|
172
172
|
it 'should properly set the :event_guid for died' do
|
173
173
|
x = @uo_util.add_guid!(spec_died_line)
|
174
174
|
y = spec_guid_reference_implementation(spec_died_line)
|
175
|
-
expect(x.key?(:event_guid)).to
|
175
|
+
expect(x.key?(:event_guid)).to be_truthy
|
176
176
|
expect(y[:event_guid]).to eql y[:event_guid]
|
177
177
|
end
|
178
178
|
|
179
179
|
it 'should properly set the :event_guid for wounded' do
|
180
180
|
x = @uo_util.add_guid!(spec_wounded_line)
|
181
181
|
y = spec_guid_reference_implementation(spec_wounded_line)
|
182
|
-
expect(x.key?(:event_guid)).to
|
182
|
+
expect(x.key?(:event_guid)).to be_truthy
|
183
183
|
expect(x[:event_guid]).to eql y[:event_guid]
|
184
184
|
end
|
185
185
|
|
186
186
|
it 'should properly set the :event_guid for announcements' do
|
187
187
|
x = @uo_util.add_guid!(spec_announcement_line)
|
188
188
|
y = spec_guid_reference_implementation(spec_announcement_line)
|
189
|
-
expect(x.key?(:event_guid)).to
|
189
|
+
expect(x.key?(:event_guid)).to be_truthy
|
190
190
|
expect(x[:event_guid]).to eql y[:event_guid]
|
191
191
|
end
|
192
192
|
|
193
193
|
it 'should properly set the :event_guid for beguid' do
|
194
194
|
x = @uo_util.add_guid!(spec_beguid_line)
|
195
195
|
y = spec_guid_reference_implementation(spec_beguid_line)
|
196
|
-
expect(x.key?(:event_guid)).to
|
196
|
+
expect(x.key?(:event_guid)).to be_truthy
|
197
197
|
expect(x[:event_guid]).to eql y[:event_guid]
|
198
198
|
end
|
199
199
|
|
200
200
|
it 'should properly set the :event_guid for chat' do
|
201
201
|
x = @uo_util.add_guid!(spec_chat_line)
|
202
202
|
y = spec_guid_reference_implementation(spec_chat_line)
|
203
|
-
expect(x.key?(:event_guid)).to
|
203
|
+
expect(x.key?(:event_guid)).to be_truthy
|
204
204
|
expect(x[:event_guid]).to eql y[:event_guid]
|
205
205
|
end
|
206
206
|
end
|
@@ -270,8 +270,8 @@ describe RMuh::RPT::Log::Util::UnitedOperations do
|
|
270
270
|
end
|
271
271
|
|
272
272
|
it 'should convert the correct values to Fixnum' do
|
273
|
-
md = @mi.match('2014/02/09 14:44:44')
|
274
|
-
%w( year month day hour min sec ).each do |m|
|
273
|
+
md = @mi.match('2014/02/09 14:44:44 0')
|
274
|
+
%w( year month day hour min sec player_num ).each do |m|
|
275
275
|
x = @uo_util.__line_modifiers(md, m)
|
276
276
|
expect(x).to be_an_instance_of Fixnum
|
277
277
|
expect(x).to eql md[m].to_i
|
@@ -315,7 +315,7 @@ describe RMuh::RPT::Log::Util::UnitedOperations do
|
|
315
315
|
end
|
316
316
|
|
317
317
|
it 'should properly convert the correct values to int' do
|
318
|
-
md = @mi.match('2014/02/09 14:44:44')
|
318
|
+
md = @mi.match('2014/02/09 14:44:44 0')
|
319
319
|
h = @uo_util.m_to_h(md)
|
320
320
|
[:year, :month, :day, :hour, :min, :sec].each do |m|
|
321
321
|
expect(h[m]).to be_an_instance_of Fixnum
|
@@ -346,7 +346,7 @@ describe RMuh::RPT::Log::Util::UnitedOperations do
|
|
346
346
|
md = @ma.match('None."')
|
347
347
|
h = @uo_util.m_to_h(md)
|
348
348
|
expect(h[:nearby_players]).to be_an_instance_of Array
|
349
|
-
expect(h[:nearby_players].empty?).to
|
349
|
+
expect(h[:nearby_players].empty?).to be_truthy
|
350
350
|
end
|
351
351
|
end
|
352
352
|
|
@@ -6,56 +6,53 @@ describe RMuh::RPT::Log::Util::UnitedOperationsLog do
|
|
6
6
|
@uo_util.extend(RMuh::RPT::Log::Util::UnitedOperationsLog)
|
7
7
|
end
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
expect(
|
12
|
-
RMuh::RPT::Log::Util::UnitedOperationsLog::ONE_DAY
|
13
|
-
).to be_an_instance_of Fixnum
|
14
|
-
end
|
9
|
+
describe '::ONE_DAY' do
|
10
|
+
subject { RMuh::RPT::Log::Util::UnitedOperationsLog::ONE_DAY }
|
15
11
|
|
16
|
-
it
|
17
|
-
|
18
|
-
|
12
|
+
it { should be_an_instance_of Fixnum }
|
13
|
+
|
14
|
+
it { should eql 86_400 }
|
19
15
|
end
|
20
16
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
).to be_an_instance_of String
|
26
|
-
end
|
17
|
+
describe '::TIME_SHORT' do
|
18
|
+
subject { RMuh::RPT::Log::Util::UnitedOperationsLog::TIME_SHORT }
|
19
|
+
|
20
|
+
it { should be_an_instance_of String }
|
27
21
|
end
|
28
22
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
23
|
+
describe '::TIME' do
|
24
|
+
subject { RMuh::RPT::Log::Util::UnitedOperationsLog::TIME }
|
25
|
+
|
26
|
+
it { should be_an_instance_of String }
|
27
|
+
end
|
28
|
+
|
29
|
+
describe '::GUID' do
|
30
|
+
subject { RMuh::RPT::Log::Util::UnitedOperationsLog::GUID }
|
31
|
+
|
32
|
+
it { should be_an_instance_of Regexp }
|
35
33
|
|
36
34
|
it 'should match an example line' do
|
37
35
|
l = ' 4:01:02 BattlEye Server: Verified GUID ' \
|
38
36
|
'(04de012b0f882b9ff2e43564c8c09361) of player #0 nametag47'
|
39
|
-
m =
|
37
|
+
m = subject.match(l)
|
40
38
|
expect(m).to_not be_nil
|
41
39
|
expect(m['hour']).to eql '4'
|
42
40
|
expect(m['min']).to eql '01'
|
43
41
|
expect(m['sec']).to eql '02'
|
44
42
|
expect(m['player_beguid']).to eql '04de012b0f882b9ff2e43564c8c09361'
|
45
43
|
expect(m['player']).to eql 'nametag47'
|
44
|
+
expect(m['player_num']).to eql '0'
|
46
45
|
end
|
47
46
|
end
|
48
47
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
).to be_an_instance_of Regexp
|
54
|
-
end
|
48
|
+
describe '::CHAT' do
|
49
|
+
subject { RMuh::RPT::Log::Util::UnitedOperationsLog::CHAT }
|
50
|
+
|
51
|
+
it { should be_an_instance_of Regexp }
|
55
52
|
|
56
53
|
it 'should match an example line' do
|
57
54
|
l = ' 5:48:01 BattlEye Server: (Side) Xcenocide: Admin back'
|
58
|
-
m =
|
55
|
+
m = subject.match(l)
|
59
56
|
expect(m['hour']).to eql '5'
|
60
57
|
expect(m['min']).to eql '48'
|
61
58
|
expect(m['sec']).to eql '01'
|
@@ -64,4 +61,37 @@ describe RMuh::RPT::Log::Util::UnitedOperationsLog do
|
|
64
61
|
expect(m['message']).to eql 'Admin back'
|
65
62
|
end
|
66
63
|
end
|
64
|
+
|
65
|
+
describe '::JOINED' do
|
66
|
+
subject { RMuh::RPT::Log::Util::UnitedOperationsLog::JOINED }
|
67
|
+
|
68
|
+
it { should be_an_instance_of Regexp }
|
69
|
+
|
70
|
+
it 'should match an example line' do
|
71
|
+
l = ' 4:01:09 BattlEye Server: Player #0 Delta38 ' \
|
72
|
+
'(127.0.0.1:65007) connected'
|
73
|
+
m = subject.match(l)
|
74
|
+
expect(m['hour']).to eql '4'
|
75
|
+
expect(m['min']).to eql '01'
|
76
|
+
expect(m['sec']).to eql '09'
|
77
|
+
expect(m['player']).to eql 'Delta38'
|
78
|
+
expect(m['player_num']).to eql '0'
|
79
|
+
expect(m['net']).to eql '127.0.0.1:65007'
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
describe '::LEFT' do
|
84
|
+
subject { RMuh::RPT::Log::Util::UnitedOperationsLog::LEFT }
|
85
|
+
|
86
|
+
it { should be_an_instance_of Regexp }
|
87
|
+
|
88
|
+
it 'should match an example line' do
|
89
|
+
l = ' 5:05:53 Player MPWR disconnected.'
|
90
|
+
m = subject.match(l)
|
91
|
+
expect(m['hour']).to eql '5'
|
92
|
+
expect(m['min']).to eql '05'
|
93
|
+
expect(m['sec']).to eql '53'
|
94
|
+
expect(m['player']).to eq 'MPWR'
|
95
|
+
end
|
96
|
+
end
|
67
97
|
end
|
data/spec/unit/rmuh/rpt_spec.rb
CHANGED
@@ -3,31 +3,31 @@
|
|
3
3
|
describe RMuh do
|
4
4
|
context '::VERSION_MAJ' do
|
5
5
|
it 'should have a major version that is an integer' do
|
6
|
-
expect(RMuh::VERSION_MAJ.is_a?(Integer)).to
|
6
|
+
expect(RMuh::VERSION_MAJ.is_a?(Integer)).to be_truthy
|
7
7
|
end
|
8
8
|
|
9
9
|
it 'should have a major version that is a positive number' do
|
10
|
-
expect(RMuh::VERSION_MAJ > -1).to
|
10
|
+
expect(RMuh::VERSION_MAJ > -1).to be_truthy
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
14
|
context '::VERSION_MIN' do
|
15
15
|
it 'should have a minor version that is an integer' do
|
16
|
-
expect(RMuh::VERSION_MIN.is_a?(Integer)).to
|
16
|
+
expect(RMuh::VERSION_MIN.is_a?(Integer)).to be_truthy
|
17
17
|
end
|
18
18
|
|
19
19
|
it 'should have a minor version that is a positive integer' do
|
20
|
-
expect(RMuh::VERSION_MIN > -1).to
|
20
|
+
expect(RMuh::VERSION_MIN > -1).to be_truthy
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
24
|
context '::VERSION_REV' do
|
25
25
|
it 'should have a revision number that is an integer' do
|
26
|
-
expect(RMuh::VERSION_REV.is_a?(Integer)).to
|
26
|
+
expect(RMuh::VERSION_REV.is_a?(Integer)).to be_truthy
|
27
27
|
end
|
28
28
|
|
29
29
|
it 'should have a revision number that is a positive integer' do
|
30
|
-
expect(RMuh::VERSION_REV > -1).to
|
30
|
+
expect(RMuh::VERSION_REV > -1).to be_truthy
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
@@ -37,15 +37,15 @@ shared_examples 'RMuh::ServerStats::Base' do
|
|
37
37
|
it 'should set the default port if not provided' do
|
38
38
|
h = srv_hash.dup
|
39
39
|
RMuh::ServerStats::Base.validate_opts(h)
|
40
|
-
expect(h.key?(:port)).to
|
40
|
+
expect(h.key?(:port)).to be_truthy
|
41
41
|
expect(h[:port]).to eql RMuh::ServerStats::Base::DEFAULT_PORT
|
42
42
|
end
|
43
43
|
|
44
44
|
it 'should set the auto_cache key to true if not provided' do
|
45
45
|
h = srv_hash.dup
|
46
46
|
RMuh::ServerStats::Base.validate_opts(h)
|
47
|
-
expect(h.key?(:auto_cache)).to
|
48
|
-
expect(h[:auto_cache]).to
|
47
|
+
expect(h.key?(:auto_cache)).to be_truthy
|
48
|
+
expect(h[:auto_cache]).to be_truthy
|
49
49
|
end
|
50
50
|
|
51
51
|
it 'should return nil' do
|
@@ -122,7 +122,8 @@ shared_examples 'RMuh::ServerStats::Base' do
|
|
122
122
|
|
123
123
|
context '#sync' do
|
124
124
|
before do
|
125
|
-
GamespyQuery::Socket.
|
125
|
+
allow_any_instance_of(GamespyQuery::Socket).to receive(:sync)
|
126
|
+
.and_return(one: 1)
|
126
127
|
end
|
127
128
|
let(:b) { RMuh::ServerStats::Base.new(host: '127.0.0.1') }
|
128
129
|
|
@@ -149,7 +150,7 @@ shared_examples 'RMuh::ServerStats::Base' do
|
|
149
150
|
|
150
151
|
it 'should return the return value from the #sync method if cache true' do
|
151
152
|
n = RMuh::ServerStats::Base.new(host: '127.0.0.1', cache: false)
|
152
|
-
n.
|
153
|
+
allow(n).to receive(:sync).and_return(one: 'two')
|
153
154
|
expect(n.send(:remote_stats)).to eql(one: 'two')
|
154
155
|
end
|
155
156
|
end
|
@@ -158,8 +159,8 @@ shared_examples 'RMuh::ServerStats::Base' do
|
|
158
159
|
before(:each) do
|
159
160
|
@b = RMuh::ServerStats::Base.new(host: '127.0.0.1')
|
160
161
|
@bf = RMuh::ServerStats::Base.new(host: '127.0.0.1', cache: false)
|
161
|
-
@b.
|
162
|
-
@bf.
|
162
|
+
allow(@b).to receive(:sync).and_return(one: 'two')
|
163
|
+
allow(@bf).to receive(:sync).and_return(one: 'two')
|
163
164
|
end
|
164
165
|
|
165
166
|
it 'should take no args' do
|
@@ -181,8 +182,8 @@ shared_examples 'RMuh::ServerStats::Base' do
|
|
181
182
|
before(:each) do
|
182
183
|
@b = RMuh::ServerStats::Base.new(host: '127.0.0.1')
|
183
184
|
@bf = RMuh::ServerStats::Base.new(host: '127.0.0.1', cache: false)
|
184
|
-
@b.
|
185
|
-
@bf.
|
185
|
+
allow(@b).to receive(:sync).and_return(one: 'two')
|
186
|
+
allow(@bf).to receive(:sync).and_return(one: 'two')
|
186
187
|
@b.update_cache
|
187
188
|
end
|
188
189
|
|