open_dota_api 0.2.2 → 0.2.3

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.
@@ -6,7 +6,7 @@ describe OpenDotaApi::Hero do
6
6
  let(:localized_name) { 'Anti-Mage' }
7
7
  let(:primary_attr) { 'agi' }
8
8
  let(:attack_type) { 'Melee' }
9
- let(:roles) { %w(Carry Escape Nuker) }
9
+ let(:roles) { %w[Carry Escape Nuker] }
10
10
  let(:legs) { 2 }
11
11
 
12
12
  let(:heroes_file) { File.read('spec/data/heroes.json') }
@@ -1,99 +1,199 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe OpenDotaApi::Match do
4
- let(:match_id) { 3_149_215_336 }
5
- let(:start_time) { 1_493_566_333 }
6
- let(:duration) { 2109 }
7
- let(:series_id) { 135_248 }
8
- let(:series_type) { 2 }
9
- let(:radiant_team_id) { 2_586_976 }
10
- let(:dire_team_id) { 1_883_502 }
11
- let(:match_seq_num) { 2_750_393_746 }
12
- let(:league_id) { 5157 }
13
- let(:first_blood_time) { 53 }
14
- let(:winner) { :dire }
15
- let(:cluster) { 136 }
16
- let(:replay_salt) { 565_926_067 }
17
- let(:replay_url) { 'http://replay136.valve.net/570/3149215336_565926067.dem.bz2' }
18
- let(:players_length) { 10 }
19
- let(:player_class) { OpenDotaApi::Match::Player }
20
-
21
- let(:match_file) { File.read('spec/data/match.json') }
22
- let(:response_json) { JSON.parse(match_file) }
23
- let(:match) { OpenDotaApi::Match.new(response_json) }
24
-
25
- it 'returns endpoint' do
26
- expect(described_class::ENDPOINT).to eq 'matches'
27
- end
28
-
29
- it 'inherits entity object' do
30
- expect(match).to be_a OpenDotaApi::Entity
31
- end
32
-
33
- it 'is not instantiable' do
34
- expect { described_class.instantiate }.to raise_error NotImplementedError
35
- end
36
-
37
- describe 'default attributes' do
38
- it 'returns match id' do
39
- expect(match.match_id).to eq match_id
4
+ context 'official match' do
5
+ let(:match_id) { 3_149_215_336 }
6
+ let(:start_time) { 1_493_566_333 }
7
+ let(:duration) { 2109 }
8
+ let(:series_id) { 135_248 }
9
+ let(:series_type) { 2 }
10
+ let(:radiant_team_id) { 2_586_976 }
11
+ let(:dire_team_id) { 1_883_502 }
12
+ let(:match_seq_num) { 2_750_393_746 }
13
+ let(:league_id) { 5157 }
14
+ let(:first_blood_time) { 53 }
15
+ let(:winner) { :dire }
16
+ let(:cluster) { 136 }
17
+ let(:replay_salt) { 565_926_067 }
18
+ let(:replay_url) { 'http://replay136.valve.net/570/3149215336_565926067.dem.bz2' }
19
+ let(:players_length) { 10 }
20
+ let(:player_class) { OpenDotaApi::Match::Player }
21
+
22
+ let(:match_file) { File.read('spec/data/match.json') }
23
+ let(:response_json) { JSON.parse(match_file) }
24
+ let(:match) { OpenDotaApi::Match.new(response_json) }
25
+
26
+ it 'returns endpoint' do
27
+ expect(described_class::ENDPOINT).to eq 'matches'
40
28
  end
41
29
 
42
- it 'returns start time' do
43
- expect(match.start_time).to eq start_time
30
+ it 'inherits entity object' do
31
+ expect(match).to be_a OpenDotaApi::Entity
44
32
  end
45
33
 
46
- it 'returns duration' do
47
- expect(match.duration).to eq duration
34
+ it 'is not instantiable' do
35
+ expect { described_class.instantiate }.to raise_error NotImplementedError
48
36
  end
49
37
 
50
- it 'returns series id' do
51
- expect(match.series_id).to eq series_id
52
- end
38
+ describe 'default attributes' do
39
+ it 'returns match id' do
40
+ expect(match.match_id).to eq match_id
41
+ end
53
42
 
54
- it 'returns series type' do
55
- expect(match.series_type).to eq series_type
56
- end
43
+ it 'returns start time' do
44
+ expect(match.start_time).to eq start_time
45
+ end
57
46
 
58
- it 'returns radiant team id' do
59
- expect(match.radiant_team_id).to eq radiant_team_id
60
- end
47
+ it 'returns duration' do
48
+ expect(match.duration).to eq duration
49
+ end
61
50
 
62
- it 'returns dire team id' do
63
- expect(match.dire_team_id).to eq dire_team_id
64
- end
51
+ it 'returns series id' do
52
+ expect(match.series_id).to eq series_id
53
+ end
65
54
 
66
- it 'returns match sequence number' do
67
- expect(match.match_seq_num).to eq match_seq_num
68
- end
55
+ it 'returns series type' do
56
+ expect(match.series_type).to eq series_type
57
+ end
69
58
 
70
- it 'returns league id' do
71
- expect(match.league_id).to eq league_id
72
- end
59
+ it 'returns radiant team id' do
60
+ expect(match.radiant_team_id).to eq radiant_team_id
61
+ end
73
62
 
74
- it 'returns first blood time' do
75
- expect(match.first_blood_time).to eq first_blood_time
76
- end
63
+ it 'returns dire team id' do
64
+ expect(match.dire_team_id).to eq dire_team_id
65
+ end
66
+
67
+ it 'returns match sequence number' do
68
+ expect(match.match_seq_num).to eq match_seq_num
69
+ end
70
+
71
+ it 'returns league id' do
72
+ expect(match.league_id).to eq league_id
73
+ end
74
+
75
+ it 'returns first blood time' do
76
+ expect(match.first_blood_time).to eq first_blood_time
77
+ end
78
+
79
+ it 'returns winner' do
80
+ expect(match.winner).to eq winner
81
+ end
82
+
83
+ it 'returns cluster' do
84
+ expect(match.cluster).to eq cluster
85
+ end
77
86
 
78
- it 'returns winner' do
79
- expect(match.winner).to eq winner
87
+ it 'returns replay salt' do
88
+ expect(match.replay_salt).to eq replay_salt
89
+ end
90
+
91
+ it 'returns replay url' do
92
+ expect(match.replay_url).to eq replay_url
93
+ end
94
+
95
+ it 'returns players' do
96
+ expect(match.players.length).to eq players_length
97
+ expect(match.players.all? { |player| player.is_a? player_class }).to be_truthy
98
+ end
80
99
  end
100
+ end
81
101
 
82
- it 'returns cluster' do
83
- expect(match.cluster).to eq cluster
102
+ context 'unofficial match' do
103
+ let(:match_id) { 3_344_092_796 }
104
+ let(:start_time) { 1_501_349_085 }
105
+ let(:duration) { 2590 }
106
+ let(:series_id) { 0 }
107
+ let(:series_type) { 0 }
108
+ let(:radiant_team_id) { nil }
109
+ let(:dire_team_id) { nil }
110
+ let(:match_seq_num) { 2_917_433_466 }
111
+ let(:league_id) { 0 }
112
+ let(:first_blood_time) { 2 }
113
+ let(:winner) { :dire }
114
+ let(:cluster) { 192 }
115
+ let(:replay_salt) { 120_334_496 }
116
+ let(:replay_url) { 'http://replay192.valve.net/570/3344092796_120334496.dem.bz2' }
117
+ let(:players_length) { 10 }
118
+ let(:player_class) { OpenDotaApi::Match::Player }
119
+
120
+ let(:match_file) { File.read('spec/data/unofficial_match.json') }
121
+ let(:response_json) { JSON.parse(match_file) }
122
+ let(:match) { OpenDotaApi::Match.new(response_json) }
123
+
124
+ it 'returns endpoint' do
125
+ expect(described_class::ENDPOINT).to eq 'matches'
84
126
  end
85
127
 
86
- it 'returns replay salt' do
87
- expect(match.replay_salt).to eq replay_salt
128
+ it 'inherits entity object' do
129
+ expect(match).to be_a OpenDotaApi::Entity
88
130
  end
89
131
 
90
- it 'returns replay url' do
91
- expect(match.replay_url).to eq replay_url
132
+ it 'is not instantiable' do
133
+ expect { described_class.instantiate }.to raise_error NotImplementedError
92
134
  end
93
135
 
94
- it 'returns players' do
95
- expect(match.players.length).to eq players_length
96
- expect(match.players.all? { |player| player.is_a? player_class }).to be_truthy
136
+ describe 'default attributes' do
137
+ it 'returns match id' do
138
+ expect(match.match_id).to eq match_id
139
+ end
140
+
141
+ it 'returns start time' do
142
+ expect(match.start_time).to eq start_time
143
+ end
144
+
145
+ it 'returns duration' do
146
+ expect(match.duration).to eq duration
147
+ end
148
+
149
+ it 'returns series id' do
150
+ expect(match.series_id).to eq series_id
151
+ end
152
+
153
+ it 'returns series type' do
154
+ expect(match.series_type).to eq series_type
155
+ end
156
+
157
+ it 'returns radiant team id' do
158
+ expect(match.radiant_team_id).to eq radiant_team_id
159
+ end
160
+
161
+ it 'returns dire team id' do
162
+ expect(match.dire_team_id).to eq dire_team_id
163
+ end
164
+
165
+ it 'returns match sequence number' do
166
+ expect(match.match_seq_num).to eq match_seq_num
167
+ end
168
+
169
+ it 'returns league id' do
170
+ expect(match.league_id).to eq league_id
171
+ end
172
+
173
+ it 'returns first blood time' do
174
+ expect(match.first_blood_time).to eq first_blood_time
175
+ end
176
+
177
+ it 'returns winner' do
178
+ expect(match.winner).to eq winner
179
+ end
180
+
181
+ it 'returns cluster' do
182
+ expect(match.cluster).to eq cluster
183
+ end
184
+
185
+ it 'returns replay salt' do
186
+ expect(match.replay_salt).to eq replay_salt
187
+ end
188
+
189
+ it 'returns replay url' do
190
+ expect(match.replay_url).to eq replay_url
191
+ end
192
+
193
+ it 'returns players' do
194
+ expect(match.players.length).to eq players_length
195
+ expect(match.players.all? { |player| player.is_a? player_class }).to be_truthy
196
+ end
97
197
  end
98
198
  end
99
199
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: open_dota_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yaroslav Oslavskiy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-27 00:00:00.000000000 Z
11
+ date: 2017-08-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -159,6 +159,7 @@ files:
159
159
  - spec/data/match.json
160
160
  - spec/data/pro_players.json
161
161
  - spec/data/teams.json
162
+ - spec/data/unofficial_match.json
162
163
  - spec/lib/open_dota_api/client_spec.rb
163
164
  - spec/lib/open_dota_api/connection_spec.rb
164
165
  - spec/lib/open_dota_api/hero_spec.rb
@@ -199,6 +200,7 @@ test_files:
199
200
  - spec/data/match.json
200
201
  - spec/data/pro_players.json
201
202
  - spec/data/teams.json
203
+ - spec/data/unofficial_match.json
202
204
  - spec/lib/open_dota_api/client_spec.rb
203
205
  - spec/lib/open_dota_api/connection_spec.rb
204
206
  - spec/lib/open_dota_api/hero_spec.rb