open_dota_api 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -9,6 +9,7 @@ describe OpenDotaApi::Client do
9
9
  let(:teams_file) { File.read('spec/data/teams.json') }
10
10
  let(:match_file) { File.read('spec/data/match.json') }
11
11
  let(:heroes_file) { File.read('spec/data/heroes.json') }
12
+ let(:pro_players_file) { File.read('spec/data/pro_players.json') }
12
13
  let(:data_file) { }
13
14
  let(:headers) do
14
15
  {
@@ -21,6 +22,7 @@ describe OpenDotaApi::Client do
21
22
  let(:expected_teams) { OpenDotaApi::Team.instantiate(response_json) }
22
23
  let(:expected_match) { OpenDotaApi::Match.new(response_json) }
23
24
  let(:expected_heroes) { OpenDotaApi::Hero.instantiate(response_json) }
25
+ let(:expected_pro_players) { OpenDotaApi::ProPlayers.instantiate(response_json) }
24
26
 
25
27
  before do
26
28
  stub_request(:get, "http://api.opendota.com/api/#{endpoint}/").
@@ -85,5 +87,18 @@ describe OpenDotaApi::Client do
85
87
  expect(client.heroes.to_deep_hash).to eq expected_heroes.to_deep_hash
86
88
  end
87
89
  end
90
+
91
+ describe '#pro_players' do
92
+ let(:endpoint) { "#{OpenDotaApi::ProPlayer::ENDPOINT}" }
93
+ let(:data_file) { pro_players_file }
94
+
95
+ it 'returns array of objects' do
96
+ expect(client.pro_players.all? { |hero| hero.kind_of? OpenDotaApi::ProPlayer }).to be_truthy
97
+ end
98
+
99
+ it 'returns list' do
100
+ expect(client.pro_players.to_deep_hash).to eq expected_heroes.to_deep_hash
101
+ end
102
+ end
88
103
  end
89
104
  end
@@ -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') }
@@ -31,7 +31,7 @@ describe OpenDotaApi::Match do
31
31
  end
32
32
 
33
33
  it 'is not instantiable' do
34
- expect{ described_class.instantiate }.to raise_error NotImplementedError
34
+ expect { described_class.instantiate }.to raise_error NotImplementedError
35
35
  end
36
36
 
37
37
  describe 'default attributes' do
@@ -0,0 +1,133 @@
1
+ require 'spec_helper'
2
+
3
+ describe OpenDotaApi::ProPlayer do
4
+ let(:account_id) { 1_296_625 }
5
+ let(:steam_id) { '76561197961562353' }
6
+ let(:avatar) { 'https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/95/951e9165740fda890651d8475fc50f5368a847bb.jpg' }
7
+ let(:avatar_medium) { 'https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/95/951e9165740fda890651d8475fc50f5368a847bb_medium.jpg' }
8
+ let(:avatar_full) { 'https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/95/951e9165740fda890651d8475fc50f5368a847bb_full.jpg' }
9
+ let(:profile_url) { 'http://steamcommunity.com/id/jnewsham/' }
10
+ let(:persona_name) { 'Newsham' }
11
+ let(:last_login) { Time.parse('2016-06-10 20:24:48.743000000 +0000').utc }
12
+ let(:full_history_time) { Time.parse('2015-10-27 05:14:26.768000000 +0000') }
13
+ let(:cheese) { 0 }
14
+ let(:fh_unavailable) { false }
15
+ let(:loc_country_code) { 'US' }
16
+ let(:last_match_time) { Time.parse('2017-06-28 03:13:57.000000000 +0000') }
17
+ let(:name) { 'Newsham' }
18
+ let(:country_code) { 'us' }
19
+ let(:fantasy_role) { 2 }
20
+ let(:team_id) { 3_724_222 }
21
+ let(:team_name) { 'Team Red' }
22
+ let(:team_tag) { 'Red' }
23
+ let(:is_locked) { true }
24
+ let(:is_pro) { true }
25
+ let(:locked_until) { 1_502_694_000 }
26
+
27
+ let(:pro_players_file) { File.read('spec/data/pro_players.json') }
28
+ let(:response_json) { JSON.parse(pro_players_file) }
29
+ let(:pro_players) { OpenDotaApi::ProPlayer.instantiate(response_json) }
30
+ let(:pro_player) { pro_players[8] } # Red.Newsham
31
+
32
+ it 'returns endpoint' do
33
+ expect(described_class::ENDPOINT).to eq 'proPlayers'
34
+ end
35
+
36
+ it 'inherits entity object' do
37
+ expect(pro_player).to be_a OpenDotaApi::Entity
38
+ end
39
+
40
+ it 'is instantiable' do
41
+ expect(pro_player).to be_a OpenDotaApi::Entities::Instantiatable
42
+ end
43
+
44
+ describe 'default attributes' do
45
+ it 'returns account id' do
46
+ expect(pro_player.account_id).to eq account_id
47
+ end
48
+
49
+ it 'returns steam id' do
50
+ expect(pro_player.steam_id).to eq steam_id
51
+ end
52
+
53
+ it 'returns avatar' do
54
+ expect(pro_player.avatar).to eq avatar
55
+ end
56
+
57
+ it 'returns avatar medium' do
58
+ expect(pro_player.avatar_medium).to eq avatar_medium
59
+ end
60
+
61
+ it 'returns avatar full' do
62
+ expect(pro_player.avatar_full).to eq avatar_full
63
+ end
64
+
65
+ it 'returns profile url' do
66
+ expect(pro_player.profile_url).to eq profile_url
67
+ end
68
+
69
+ it 'returns persona name' do
70
+ expect(pro_player.persona_name).to eq persona_name
71
+ end
72
+
73
+ it 'returns last login' do
74
+ expect(pro_player.last_login).to eq last_login
75
+ end
76
+
77
+ it 'returns full history time' do
78
+ expect(pro_player.full_history_time).to eq full_history_time
79
+ end
80
+
81
+ it 'returns cheese' do
82
+ expect(pro_player.cheese).to eq cheese
83
+ end
84
+
85
+ it 'returns fh unavailable' do
86
+ expect(pro_player.fh_unavailable).to eq fh_unavailable
87
+ end
88
+
89
+ it 'returns location country code' do
90
+ expect(pro_player.loc_country_code).to eq loc_country_code
91
+ end
92
+
93
+ it 'returns last match time' do
94
+ expect(pro_player.last_match_time).to eq last_match_time
95
+ end
96
+
97
+ it 'returns name' do
98
+ expect(pro_player.name).to eq name
99
+ end
100
+
101
+ it 'returns country code' do
102
+ expect(pro_player.country_code).to eq country_code
103
+ end
104
+
105
+ it 'returns fantasy role' do
106
+ expect(pro_player.fantasy_role).to eq fantasy_role
107
+ end
108
+
109
+ it 'returns team id' do
110
+ expect(pro_player.team_id).to eq team_id
111
+ end
112
+
113
+ it 'returns team name' do
114
+ expect(pro_player.team_name).to eq team_name
115
+ end
116
+
117
+ it 'returns team tag' do
118
+ expect(pro_player.team_tag).to eq team_tag
119
+ end
120
+
121
+ it 'returns if it is locked' do
122
+ expect(pro_player.is_locked).to eq is_locked
123
+ end
124
+
125
+ it 'returns if it is pro' do
126
+ expect(pro_player.is_pro).to eq is_pro
127
+ end
128
+
129
+ it 'returns locked until' do
130
+ expect(pro_player.locked_until).to eq locked_until
131
+ end
132
+ end
133
+ 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.1.0
4
+ version: 0.2.0
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-22 00:00:00.000000000 Z
11
+ date: 2017-07-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -140,11 +140,13 @@ files:
140
140
  - lib/open_dota_api/league.rb
141
141
  - lib/open_dota_api/match.rb
142
142
  - lib/open_dota_api/matches/player.rb
143
+ - lib/open_dota_api/pro_player.rb
143
144
  - lib/open_dota_api/team.rb
144
145
  - lib/open_dota_api/version.rb
145
146
  - spec/data/heroes.json
146
147
  - spec/data/leagues.json
147
148
  - spec/data/match.json
149
+ - spec/data/pro_players.json
148
150
  - spec/data/teams.json
149
151
  - spec/lib/open_dota_api/client_spec.rb
150
152
  - spec/lib/open_dota_api/connection_spec.rb
@@ -152,6 +154,7 @@ files:
152
154
  - spec/lib/open_dota_api/league_spec.rb
153
155
  - spec/lib/open_dota_api/match_spec.rb
154
156
  - spec/lib/open_dota_api/matches/player_spec.rb
157
+ - spec/lib/open_dota_api/pro_player_spec.rb
155
158
  - spec/lib/open_dota_api/team_spec.rb
156
159
  - spec/lib/open_dota_api_spec.rb
157
160
  - spec/spec_helper.rb
@@ -175,7 +178,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
175
178
  version: '0'
176
179
  requirements: []
177
180
  rubyforge_project:
178
- rubygems_version: 2.5.1
181
+ rubygems_version: 2.6.12
179
182
  signing_key:
180
183
  specification_version: 4
181
184
  summary: Ruby wrapper for Open Dota API
@@ -183,6 +186,7 @@ test_files:
183
186
  - spec/data/heroes.json
184
187
  - spec/data/leagues.json
185
188
  - spec/data/match.json
189
+ - spec/data/pro_players.json
186
190
  - spec/data/teams.json
187
191
  - spec/lib/open_dota_api/client_spec.rb
188
192
  - spec/lib/open_dota_api/connection_spec.rb
@@ -190,6 +194,7 @@ test_files:
190
194
  - spec/lib/open_dota_api/league_spec.rb
191
195
  - spec/lib/open_dota_api/match_spec.rb
192
196
  - spec/lib/open_dota_api/matches/player_spec.rb
197
+ - spec/lib/open_dota_api/pro_player_spec.rb
193
198
  - spec/lib/open_dota_api/team_spec.rb
194
199
  - spec/lib/open_dota_api_spec.rb
195
200
  - spec/spec_helper.rb