rmuh 0.2.1 → 0.2.2

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.
@@ -11,56 +11,60 @@ describe RMuh::RPT::Log::Util::UnitedOperationsLog do
11
11
 
12
12
  context '::ONE_DAY' do
13
13
  it 'should be an instance of Fixnum' do
14
- RMuh::RPT::Log::Util::UnitedOperationsLog::ONE_DAY
15
- .should be_an_instance_of Fixnum
14
+ expect(
15
+ RMuh::RPT::Log::Util::UnitedOperationsLog::ONE_DAY
16
+ ).to be_an_instance_of Fixnum
16
17
  end
17
18
 
18
19
  it 'should be 24 hours in seconds' do
19
- RMuh::RPT::Log::Util::UnitedOperationsLog::ONE_DAY.should eql 86_400
20
+ expect(RMuh::RPT::Log::Util::UnitedOperationsLog::ONE_DAY).to eql 86_400
20
21
  end
21
22
  end
22
23
 
23
24
  context '::TIME' do
24
25
  it 'should be an instance of String' do
25
- RMuh::RPT::Log::Util::UnitedOperationsLog::TIME
26
- .should be_an_instance_of String
26
+ expect(
27
+ RMuh::RPT::Log::Util::UnitedOperationsLog::TIME
28
+ ).to be_an_instance_of String
27
29
  end
28
30
  end
29
31
 
30
32
  context '::GUID' do
31
33
  it 'should be an instance of Regexp' do
32
- RMuh::RPT::Log::Util::UnitedOperationsLog::GUID
33
- .should be_an_instance_of Regexp
34
+ expect(
35
+ RMuh::RPT::Log::Util::UnitedOperationsLog::GUID
36
+ ).to be_an_instance_of Regexp
34
37
  end
35
38
 
36
39
  it 'should match an example line' do
37
40
  l = ' 4:01:02 BattlEye Server: Verified GUID ' \
38
41
  '(04de012b0f882b9ff2e43564c8c09361) of player #0 nametag47'
39
42
  m = RMuh::RPT::Log::Util::UnitedOperationsLog::GUID.match(l)
40
- m.should_not be_nil
41
- m['hour'].should eql '4'
42
- m['min'].should eql '01'
43
- m['sec'].should eql '02'
44
- m['player_beguid'].should eql '04de012b0f882b9ff2e43564c8c09361'
45
- m['player'].should eql 'nametag47'
43
+ expect(m).to_not be_nil
44
+ expect(m['hour']).to eql '4'
45
+ expect(m['min']).to eql '01'
46
+ expect(m['sec']).to eql '02'
47
+ expect(m['player_beguid']).to eql '04de012b0f882b9ff2e43564c8c09361'
48
+ expect(m['player']).to eql 'nametag47'
46
49
  end
47
50
  end
48
51
 
49
52
  context '::CHAT' do
50
53
  it 'should be an instance of Regexp' do
51
- RMuh::RPT::Log::Util::UnitedOperationsLog::CHAT
52
- .should be_an_instance_of Regexp
54
+ expect(
55
+ RMuh::RPT::Log::Util::UnitedOperationsLog::CHAT
56
+ ).to be_an_instance_of Regexp
53
57
  end
54
58
 
55
59
  it 'should match an example line' do
56
60
  l = ' 5:48:01 BattlEye Server: (Side) Xcenocide: Admin back'
57
61
  m = RMuh::RPT::Log::Util::UnitedOperationsLog::CHAT.match(l)
58
- m['hour'].should eql '5'
59
- m['min'].should eql '48'
60
- m['sec'].should eql '01'
61
- m['channel'].should eql 'Side'
62
- m['player'].should eql 'Xcenocide'
63
- m['message'].should eql 'Admin back'
62
+ expect(m['hour']).to eql '5'
63
+ expect(m['min']).to eql '48'
64
+ expect(m['sec']).to eql '01'
65
+ expect(m['channel']).to eql 'Side'
66
+ expect(m['player']).to eql 'Xcenocide'
67
+ expect(m['message']).to eql 'Admin back'
64
68
  end
65
69
  end
66
70
  end
@@ -6,15 +6,17 @@ require File.join(repo_root, 'lib/rmuh/rpt/log/util/unitedoperationsrpt')
6
6
  describe RMuh::RPT::Log::Util::UnitedOperationsRPT do
7
7
  context '::DTR' do
8
8
  it 'should be an instance of String' do
9
- RMuh::RPT::Log::Util::UnitedOperationsRPT::DTR
10
- .should be_an_instance_of String
9
+ expect(
10
+ RMuh::RPT::Log::Util::UnitedOperationsRPT::DTR
11
+ ).to be_an_instance_of String
11
12
  end
12
13
  end
13
14
 
14
15
  context '::KILLED' do
15
16
  it 'should be an instance of Regexp' do
16
- RMuh::RPT::Log::Util::UnitedOperationsRPT::KILLED
17
- .should be_an_instance_of Regexp
17
+ expect(
18
+ RMuh::RPT::Log::Util::UnitedOperationsRPT::KILLED
19
+ ).to be_an_instance_of Regexp
18
20
  end
19
21
 
20
22
  it 'should match an example line' do
@@ -24,31 +26,32 @@ describe RMuh::RPT::Log::Util::UnitedOperationsRPT do
24
26
  '[6498.62,6916.71,0.0204163] (GRID 0649806916). Distance between: ' \
25
27
  '71.1653 meters. Near players (100m): None."'
26
28
  m = RMuh::RPT::Log::Util::UnitedOperationsRPT::KILLED.match(l)
27
- m.should_not be_nil
28
- m['year'].should eql '2014'
29
- m['month'].should eql '02'
30
- m['day'].should eql '16'
31
- m['hour'].should eql '4'
32
- m['min'].should eql '11'
33
- m['sec'].should eql '42'
34
- m['server_time'].should eql '69.85'
35
- m['victim'].should eql 'Olli'
36
- m['victim_team'].should eql 'CIV'
37
- m['offender'].should eql 'Yevgeniy Nikolayev'
38
- m['offender_team'].should eql 'EAST'
39
- m['victim_position'].should eql '6553.55,6961.92,0.0015564'
40
- m['victim_grid'].should eql '0655306961'
41
- m['offender_position'].should eql '6498.62,6916.71,0.0204163'
42
- m['offender_grid'].should eql '0649806916'
43
- m['distance'].should eql '71.1653'
44
- m['nearby_players'].should eql 'None.'
29
+ expect(m).to_not be_nil
30
+ expect(m['year']).to eql '2014'
31
+ expect(m['month']).to eql '02'
32
+ expect(m['day']).to eql '16'
33
+ expect(m['hour']).to eql '4'
34
+ expect(m['min']).to eql '11'
35
+ expect(m['sec']).to eql '42'
36
+ expect(m['server_time']).to eql '69.85'
37
+ expect(m['victim']).to eql 'Olli'
38
+ expect(m['victim_team']).to eql 'CIV'
39
+ expect(m['offender']).to eql 'Yevgeniy Nikolayev'
40
+ expect(m['offender_team']).to eql 'EAST'
41
+ expect(m['victim_position']).to eql '6553.55,6961.92,0.0015564'
42
+ expect(m['victim_grid']).to eql '0655306961'
43
+ expect(m['offender_position']).to eql '6498.62,6916.71,0.0204163'
44
+ expect(m['offender_grid']).to eql '0649806916'
45
+ expect(m['distance']).to eql '71.1653'
46
+ expect(m['nearby_players']).to eql 'None.'
45
47
  end
46
48
  end
47
49
 
48
50
  context '::DIED' do
49
51
  it 'should be an instance of Regexp' do
50
- RMuh::RPT::Log::Util::UnitedOperationsRPT::DIED
51
- .should be_an_instance_of Regexp
52
+ expect(
53
+ RMuh::RPT::Log::Util::UnitedOperationsRPT::DIED
54
+ ).to be_an_instance_of Regexp
52
55
  end
53
56
 
54
57
  it 'should match an example line' do
@@ -56,67 +59,69 @@ describe RMuh::RPT::Log::Util::UnitedOperationsRPT do
56
59
  '[4602.18,7490.26,2.2435] (GRID 0460207490). Near players (100m): ' \
57
60
  '["Olli","nametag47","Villanyi"]"'
58
61
  m = RMuh::RPT::Log::Util::UnitedOperationsRPT::DIED.match(l)
59
- m.should_not be_nil
60
- m['year'].should eql '2014'
61
- m['month'].should eql '02'
62
- m['day'].should eql '16'
63
- m['hour'].should eql '5'
64
- m['min'].should eql '15'
65
- m['sec'].should eql '06'
66
- m['server_time'].should eql '3683.58'
67
- m['victim'].should eql 'Appe96'
68
- m['victim_position'].should eql '4602.18,7490.26,2.2435'
69
- m['victim_grid'].should eql '0460207490'
70
- m['nearby_players'].should eql '["Olli","nametag47","Villanyi"]'
62
+ expect(m).to_not be_nil
63
+ expect(m['year']).to eql '2014'
64
+ expect(m['month']).to eql '02'
65
+ expect(m['day']).to eql '16'
66
+ expect(m['hour']).to eql '5'
67
+ expect(m['min']).to eql '15'
68
+ expect(m['sec']).to eql '06'
69
+ expect(m['server_time']).to eql '3683.58'
70
+ expect(m['victim']).to eql 'Appe96'
71
+ expect(m['victim_position']).to eql '4602.18,7490.26,2.2435'
72
+ expect(m['victim_grid']).to eql '0460207490'
73
+ expect(m['nearby_players']).to eql '["Olli","nametag47","Villanyi"]'
71
74
  end
72
75
  end
73
76
 
74
77
  context '::WOUNDED' do
75
78
  it 'should be an instance of Regexp' do
76
- RMuh::RPT::Log::Util::UnitedOperationsRPT::WOUNDED
77
- .should be_an_instance_of Regexp
79
+ expect(
80
+ RMuh::RPT::Log::Util::UnitedOperationsRPT::WOUNDED
81
+ ).to be_an_instance_of Regexp
78
82
  end
79
83
 
80
84
  it 'should match an example line' do
81
85
  l = '2014/02/16, 5:22:55 "4152.41 seconds: Sherminator (CIV) has ' \
82
86
  'been team wounded by Xcenocide (WEST) for 1.50828 damage."'
83
87
  m = RMuh::RPT::Log::Util::UnitedOperationsRPT::WOUNDED.match(l)
84
- m.should_not be_nil
85
- m['year'].should eql '2014'
86
- m['month'].should eql '02'
87
- m['day'].should eql '16'
88
- m['hour'].should eql '5'
89
- m['min'].should eql '22'
90
- m['sec'].should eql '55'
91
- m['server_time'].should eql '4152.41'
92
- m['victim'].should eql 'Sherminator'
93
- m['victim_team'].should eql 'CIV'
94
- m['offender'].should eql 'Xcenocide'
95
- m['offender_team'].should eql 'WEST'
96
- m['damage'].should eql '1.50828'
88
+ expect(m).to_not be_nil
89
+ expect(m['year']).to eql '2014'
90
+ expect(m['month']).to eql '02'
91
+ expect(m['day']).to eql '16'
92
+ expect(m['hour']).to eql '5'
93
+ expect(m['min']).to eql '22'
94
+ expect(m['sec']).to eql '55'
95
+ expect(m['server_time']).to eql '4152.41'
96
+ expect(m['victim']).to eql 'Sherminator'
97
+ expect(m['victim_team']).to eql 'CIV'
98
+ expect(m['offender']).to eql 'Xcenocide'
99
+ expect(m['offender_team']).to eql 'WEST'
100
+ expect(m['damage']).to eql '1.50828'
97
101
  end
98
102
  end
99
103
 
100
104
  context '::ANNOUNCEMENT' do
101
105
  it 'should be an instance of Regexp' do
102
- RMuh::RPT::Log::Util::UnitedOperationsRPT::ANNOUNCEMENT
103
- .should be_an_instance_of Regexp
106
+ expect(
107
+ RMuh::RPT::Log::Util::UnitedOperationsRPT::ANNOUNCEMENT
108
+ ).to be_an_instance_of Regexp
104
109
  end
105
110
 
106
111
  it 'should match an example line' do
107
112
  l = '2014/02/16, 4:13:10 "############################# Start ' \
108
113
  'CO08_Escape_Chernarus_V1 #############################"'
109
114
  m = RMuh::RPT::Log::Util::UnitedOperationsRPT::ANNOUNCEMENT.match(l)
110
- m.should_not be_nil
111
- m['year'].should eql '2014'
112
- m['month'].should eql '02'
113
- m['day'].should eql '16'
114
- m['hour'].should eql '4'
115
- m['min'].should eql '13'
116
- m['sec'].should eql '10'
117
- m['head'].should eql '#############################'
118
- m['message'].should eql 'Start CO08_Escape_Chernarus_V1'
119
- m['tail'].should eql '#############################'
115
+ expect(m).to_not be_nil
116
+ expect(m['year']).to eql '2014'
117
+ expect(m['month']).to eql '02'
118
+ expect(m['day']).to eql '16'
119
+ expect(m['hour']).to eql '4'
120
+ expect(m['min']).to eql '13'
121
+ expect(m['sec']).to eql '10'
122
+ expect(m['head']).to eql '#############################'
123
+ expect(m['message']).to eql 'Start CO08_Escape_Chernarus_V1'
124
+ expect(m['tail']).to eql '#############################'
120
125
  end
121
126
  end
122
127
  end
@@ -5,41 +5,41 @@ require File.join(File.expand_path('../..', __FILE__), 'lib/rmuh/version')
5
5
  describe RMuh do
6
6
  context '::VERSION_MAJ' do
7
7
  it 'should have a major version that is an integer' do
8
- RMuh::VERSION_MAJ.is_a?(Integer).should be_true
8
+ expect(RMuh::VERSION_MAJ.is_a?(Integer)).to be_true
9
9
  end
10
10
 
11
11
  it 'should have a major version that is a positive number' do
12
- (RMuh::VERSION_MAJ > -1).should be_true
12
+ expect(RMuh::VERSION_MAJ > -1).to be_true
13
13
  end
14
14
  end
15
15
 
16
16
  context '::VERSION_MIN' do
17
17
  it 'should have a minor version that is an integer' do
18
- RMuh::VERSION_MIN.is_a?(Integer).should be_true
18
+ expect(RMuh::VERSION_MIN.is_a?(Integer)).to be_true
19
19
  end
20
20
 
21
21
  it 'should have a minor version that is a positive integer' do
22
- (RMuh::VERSION_MIN > -1).should be_true
22
+ expect(RMuh::VERSION_MIN > -1).to be_true
23
23
  end
24
24
  end
25
25
 
26
26
  context '::VERSION_REV' do
27
27
  it 'should have a revision number that is an integer' do
28
- RMuh::VERSION_REV.is_a?(Integer).should be_true
28
+ expect(RMuh::VERSION_REV.is_a?(Integer)).to be_true
29
29
  end
30
30
 
31
31
  it 'should have a revision number that is a positive integer' do
32
- (RMuh::VERSION_REV > -1).should be_true
32
+ expect(RMuh::VERSION_REV > -1).to be_true
33
33
  end
34
34
  end
35
35
 
36
36
  context '::VERSION' do
37
37
  it 'should have a version that is a string' do
38
- RMuh::VERSION.should be_an_instance_of String
38
+ expect(RMuh::VERSION).to be_an_instance_of String
39
39
  end
40
40
 
41
41
  it 'should match the following format N.N.N' do
42
- /\A(?:\d+?\.){2}\d+?/.match(RMuh::VERSION).should_not be_nil
42
+ expect(/\A(?:\d+?\.){2}\d+?/.match(RMuh::VERSION)).to_not be_nil
43
43
  end
44
44
  end
45
45
  end
@@ -10,15 +10,17 @@ describe RMuh::ServerStats::Base do
10
10
  let(:port) { RMuh::ServerStats::Base::DEFAULT_PORT }
11
11
 
12
12
  it 'should be an instance of Fixnum' do
13
- port.should be_an_instance_of Fixnum
13
+ expect(port).to be_an_instance_of Fixnum
14
14
  end
15
15
 
16
16
  it 'should be the default ArmA 2 port' do
17
- port.should eql 2_302
17
+ expect(port).to eql 2_302
18
18
  end
19
19
  end
20
20
 
21
21
  context '::validate_opts' do
22
+ let(:srv_hash) { { host: '127.0.0.1' } }
23
+
22
24
  it 'should take no more than one arg' do
23
25
  expect do
24
26
  RMuh::ServerStats::Base.validate_opts(nil, nil)
@@ -37,9 +39,23 @@ describe RMuh::ServerStats::Base do
37
39
  end.to raise_error ArgumentError
38
40
  end
39
41
 
42
+ it 'should set the default port if not provided' do
43
+ h = srv_hash.dup
44
+ RMuh::ServerStats::Base.validate_opts(h)
45
+ expect(h.key?(:port)).to be_true
46
+ expect(h[:port]).to eql RMuh::ServerStats::Base::DEFAULT_PORT
47
+ end
48
+
49
+ it 'should set the auto_cache key to true if not provided' do
50
+ h = srv_hash.dup
51
+ RMuh::ServerStats::Base.validate_opts(h)
52
+ expect(h.key?(:auto_cache)).to be_true
53
+ expect(h[:auto_cache]).to be_true
54
+ end
55
+
40
56
  it 'should return nil' do
41
57
  x = RMuh::ServerStats::Base.validate_opts(host: '127.0.0.1')
42
- x.should be_nil
58
+ expect(x).to be_nil
43
59
  end
44
60
  end
45
61
 
@@ -60,13 +76,13 @@ describe RMuh::ServerStats::Base do
60
76
 
61
77
  it 'should convert each key to an instance variable' do
62
78
  h = { one: 1, two: '2', three: :three }
63
- b.instance_variable_get(:@one).should be_nil
64
- b.instance_variable_get(:@two).should be_nil
65
- b.instance_variable_get(:@three).should be_nil
79
+ expect(b.instance_variable_get(:@one)).to be_nil
80
+ expect(b.instance_variable_get(:@two)).to be_nil
81
+ expect(b.instance_variable_get(:@three)).to be_nil
66
82
  b.send(:opts_to_instance, h)
67
- b.instance_variable_get(:@one).should eql h[:one]
68
- b.instance_variable_get(:@two).should eql h[:two]
69
- b.instance_variable_get(:@three).should eql h[:three]
83
+ expect(b.instance_variable_get(:@one)).to eql h[:one]
84
+ expect(b.instance_variable_get(:@two)).to eql h[:two]
85
+ expect(b.instance_variable_get(:@three)).to eql h[:three]
70
86
  end
71
87
  end
72
88
 
@@ -79,7 +95,7 @@ describe RMuh::ServerStats::Base do
79
95
 
80
96
  it 'should return an instance of itself if arg 1 is a Hash' do
81
97
  s = RMuh::ServerStats::Base.new(host: '127.0.0.1')
82
- s.should be_an_instance_of RMuh::ServerStats::Base
98
+ expect(s).to be_an_instance_of RMuh::ServerStats::Base
83
99
  end
84
100
 
85
101
  it 'should require the host attribute' do
@@ -91,21 +107,21 @@ describe RMuh::ServerStats::Base do
91
107
  it 'should set an instance variable for each thing in Hash' do
92
108
  h = { host: '1.2.3.4', port: 2_303, cache: false }
93
109
  s = RMuh::ServerStats::Base.new(h)
94
- s.instance_variable_get(:@host).should eql h[:host]
95
- s.instance_variable_get(:@port).should eql h[:port]
96
- s.instance_variable_get(:@cache).should eql h[:cache]
110
+ expect(s.instance_variable_get(:@host)).to eql h[:host]
111
+ expect(s.instance_variable_get(:@port)).to eql h[:port]
112
+ expect(s.instance_variable_get(:@cache)).to eql h[:cache]
97
113
  end
98
114
 
99
115
  it 'should create an instance of GamespyQuery::Socket' do
100
116
  s = RMuh::ServerStats::Base.new(host: '127.0.0.1')
101
117
  x = s.instance_variable_get(:@gsq)
102
- x.should be_an_instance_of GamespyQuery::Socket
118
+ expect(x).to be_an_instance_of GamespyQuery::Socket
103
119
  end
104
120
 
105
121
  it 'should specify default values for @port and @cache' do
106
122
  s = RMuh::ServerStats::Base.new(host: '127.0.0.1')
107
- s.instance_variable_get(:@cache).should be true
108
- s.instance_variable_get(:@port).should eql 2_302
123
+ expect(s.instance_variable_get(:@cache)).to be true
124
+ expect(s.instance_variable_get(:@port)).to eql 2_302
109
125
  end
110
126
  end
111
127
 
@@ -120,7 +136,7 @@ describe RMuh::ServerStats::Base do
120
136
  end
121
137
 
122
138
  it 'should return a Hash' do
123
- b.send(:sync).should be_an_instance_of Hash
139
+ expect(b.send(:sync)).to be_an_instance_of Hash
124
140
  end
125
141
  end
126
142
 
@@ -133,13 +149,13 @@ describe RMuh::ServerStats::Base do
133
149
 
134
150
  it 'should return the content of @servicestats if cache == true' do
135
151
  b.instance_variable_set(:@serverstats, one: 'two')
136
- b.send(:remote_stats).should eql(one: 'two')
152
+ expect(b.send(:remote_stats)).to eql(one: 'two')
137
153
  end
138
154
 
139
155
  it 'should return the return value from the #sync method if cache true' do
140
156
  n = RMuh::ServerStats::Base.new(host: '127.0.0.1', cache: false)
141
157
  n.stub(:sync).and_return(one: 'two')
142
- n.send(:remote_stats).should eql(one: 'two')
158
+ expect(n.send(:remote_stats)).to eql(one: 'two')
143
159
  end
144
160
  end
145
161
 
@@ -157,12 +173,12 @@ describe RMuh::ServerStats::Base do
157
173
 
158
174
  it 'should set the contents of @serverstats if caching' do
159
175
  @b.update_cache
160
- @b.instance_variable_get(:@serverstats).should eql(one: 'two')
176
+ expect(@b.instance_variable_get(:@serverstats)).to eql(one: 'two')
161
177
  end
162
178
 
163
179
  it 'should not set the contents of @serverstats if no caching' do
164
180
  @bf.update_cache
165
- @bf.instance_variable_get(:@serverstats).should be_nil
181
+ expect(@bf.instance_variable_get(:@serverstats)).to be_nil
166
182
  end
167
183
  end
168
184
 
@@ -180,11 +196,11 @@ describe RMuh::ServerStats::Base do
180
196
  end
181
197
 
182
198
  it 'should return the contents of @serverstats if caching enabled' do
183
- @b.stats.should eql @b.instance_variable_get(:@serverstats)
199
+ expect(@b.stats).to eql @b.instance_variable_get(:@serverstats)
184
200
  end
185
201
 
186
202
  it 'should return the contents of sync if caching is disabled' do
187
- @bf.stats.should eql(one: 'two')
203
+ expect(@bf.stats).to eql(one: 'two')
188
204
  end
189
205
  end
190
206
  end