starcraft2 0.0.10 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,54 @@
1
+ require 'spec_helper'
2
+
3
+ describe Starcraft2::Profile::Career do
4
+ let(:profile) { Starcraft2::Profile::Career.new(@options) }
5
+
6
+ before do
7
+ @options = {}
8
+ end
9
+
10
+ it 'should store the primary_race' do
11
+ @options = {:primary_race => 'PROTOSS'}
12
+ profile.primary_race.should == 'PROTOSS'
13
+ end
14
+
15
+ it 'should store the league' do
16
+ @options = {:league => 'GAMMA'}
17
+ profile.league.should == 'GAMMA'
18
+ end
19
+
20
+ it 'should store the terran_wins' do
21
+ @options = {:terran_wins => 121}
22
+ profile.terran_wins.should == 121
23
+ end
24
+
25
+ it 'should store the protoss_wins' do
26
+ @options = {:protoss_wins => 123}
27
+ profile.protoss_wins.should == 123
28
+ end
29
+
30
+ it 'should store the zerg_wins' do
31
+ @options = {:zerg_wins => 82}
32
+ profile.zerg_wins.should == 82
33
+ end
34
+
35
+ it 'should store the highest_1v1_rank' do
36
+ @options = {:highest1v1_rank => 'GOLD'}
37
+ profile.highest1v1_rank.should == 'GOLD'
38
+ end
39
+
40
+ it 'should store the highest_team_rank' do
41
+ @options = {:highest_team_rank => 'MASTER'}
42
+ profile.highest_team_rank.should =='MASTER'
43
+ end
44
+
45
+ it 'should store the season_total_games' do
46
+ @options = {:season_total_games => 596}
47
+ profile.season_total_games.should == 596
48
+ end
49
+
50
+ it 'should store the career_total_games' do
51
+ @options = {:career_total_games => 1293}
52
+ profile.career_total_games.should == 1293
53
+ end
54
+ end
@@ -0,0 +1,34 @@
1
+ require 'spec_helper'
2
+
3
+ describe Starcraft2::Profile::Match do
4
+ let(:match) {Starcraft2::Profile::Match.new(@options)}
5
+
6
+ before do
7
+ @options = {}
8
+ end
9
+
10
+ it 'should set the map' do
11
+ @options = {:map => 'foo'}
12
+ match.map.should == 'foo'
13
+ end
14
+
15
+ it 'should set the type' do
16
+ @options = {:type => 'bar'}
17
+ match.type.should == 'bar'
18
+ end
19
+
20
+ it 'should set the decision' do
21
+ @options = {:decision => 'wowzer'}
22
+ match.decision.should == 'wowzer'
23
+ end
24
+
25
+ it 'should set the speed' do
26
+ @options = {:speed => 'slow'}
27
+ match.speed.should == 'slow'
28
+ end
29
+
30
+ it 'should set the date' do
31
+ @options = {:date => 37373837}
32
+ match.date.should == 37373837
33
+ end
34
+ end
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ describe Starcraft2::Profile::Rewards do
4
+ let(:rewards) { Starcraft2::Profile::Rewards.new(@options) }
5
+
6
+ before do
7
+ @options = {}
8
+ end
9
+
10
+ it 'should store selected' do
11
+ @options = {:selected => [18730036, 2009110693, 2359737029, 3319454886]}
12
+ rewards.selected.should == [18730036, 2009110693, 2359737029, 3319454886]
13
+ end
14
+
15
+ it 'should store earned' do
16
+ @options = {:earned => [19065053, 97993138, 171155159, 199895074, 354595443, 367294557, 382993515, 414497095, 540410724]}
17
+ rewards.earned.should == [19065053, 97993138, 171155159, 199895074, 354595443, 367294557, 382993515, 414497095, 540410724]
18
+ end
19
+ end
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+
3
+ describe Starcraft2::Profile::Season do
4
+ let(:season) { Starcraft2::Profile::Season.new(@options) }
5
+
6
+ before do
7
+ @options = {}
8
+ end
9
+
10
+ it 'should store the season_id' do
11
+ @options = {:season_id => 11}
12
+ season.season_id.should == 11
13
+ end
14
+
15
+ it 'should store the total_games_this_season' do
16
+ @options = {:total_games_this_season => 252}
17
+ season.total_games_this_season.should == 252
18
+ end
19
+
20
+ it 'should store the stats' do
21
+ @options = {:stats => [{ :type => '1v1', :wins => 129, :games => 102 }, { :type => '2v2', :wins => 21, :games => 9}]}
22
+ season.stats.class.should == Array
23
+ season.stats.first.class.should == Starcraft2::Profile::Stats
24
+ season.stats.first.type.should == '1v1'
25
+ season.stats.first.wins.should == 129
26
+ season.stats.first.games.should == 102
27
+ season.stats.last.type.should == '2v2'
28
+ season.stats.last.wins.should == 21
29
+ season.stats.last.games.should == 9
30
+ end
31
+ end
@@ -0,0 +1,40 @@
1
+ require 'spec_helper'
2
+
3
+ describe Starcraft2::Profile::SwarmLevels do
4
+ let(:swarm_levels) { Starcraft2::Profile::SwarmLevels.new(@options) }
5
+
6
+ before do
7
+ @options = {}
8
+ end
9
+
10
+ describe '.initialize' do
11
+ it 'should store the level' do
12
+ @options = {:level => 10}
13
+ swarm_levels.level.should == 10
14
+ end
15
+
16
+ it 'should store terran info' do
17
+ @options = {:terran => {:level => 9, :total_level_XP => 150000, :current_level_XP => 8826}}
18
+ swarm_levels.terran.class.should == Starcraft2::Profile::SwarmRace
19
+ swarm_levels.terran.level.should == 9
20
+ swarm_levels.terran.total_level_xp.should == 150000
21
+ swarm_levels.terran.current_level_xp.should == 8826
22
+ end
23
+
24
+ it 'should store zerg info' do
25
+ @options = {:zerg => {:level => 9, :total_level_XP => 150000, :current_level_XP => 8826}}
26
+ swarm_levels.zerg.class.should == Starcraft2::Profile::SwarmRace
27
+ swarm_levels.zerg.level.should == 9
28
+ swarm_levels.zerg.total_level_xp.should == 150000
29
+ swarm_levels.zerg.current_level_xp.should == 8826
30
+ end
31
+
32
+ it 'should store protoss info' do
33
+ @options = {:protoss => {:level => 9, :total_level_XP => 150000, :current_level_XP => 8826}}
34
+ swarm_levels.protoss.class.should == Starcraft2::Profile::SwarmRace
35
+ swarm_levels.protoss.level.should == 9
36
+ swarm_levels.protoss.total_level_xp.should == 150000
37
+ swarm_levels.protoss.current_level_xp.should == 8826
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,215 @@
1
+ require 'spec_helper'
2
+
3
+ describe Starcraft2::Profile do
4
+ let(:client) { Starcraft2::Client.new }
5
+ let(:profile) { Starcraft2::Profile.new(@options) }
6
+
7
+ describe '#build' do
8
+ let(:profile) { Starcraft2::Profile.build(client, @profile_json) }
9
+
10
+ before do
11
+ VCR.use_cassette("profile_999000") do
12
+ @profile_json = HTTParty.get('https://us.battle.net/api/sc2/profile/999000/1/DayNine/').body
13
+ end
14
+ end
15
+
16
+ it 'should build a profile' do
17
+ profile.class.should == Starcraft2::Profile
18
+ end
19
+ end
20
+
21
+ describe '.initialize' do
22
+ before do
23
+ @options = {}
24
+ end
25
+
26
+ it 'should store the id' do
27
+ @options = {:id => 12345}
28
+ profile.id.should == 12345
29
+ end
30
+
31
+ it 'should store the realm' do
32
+ @options = {:realm => 1}
33
+ profile.realm.should == 1
34
+ end
35
+
36
+ it 'should store the display_name' do
37
+ @options = {:display_name => 'steve'}
38
+ profile.display_name.should == 'steve'
39
+ end
40
+
41
+ it 'should store the clan_name' do
42
+ @options = {:clan_name => 'clan'}
43
+ profile.clan_name.should == 'clan'
44
+ end
45
+
46
+ it 'should store the clan_tag' do
47
+ @options = {:clan_tag => 'tag'}
48
+ profile.clan_tag.should == 'tag'
49
+ end
50
+
51
+ it 'should store the profile_path' do
52
+ @options = {:profile_path => '/profile/example'}
53
+ profile.profile_path.should == '/profile/example'
54
+ end
55
+
56
+ it 'should store the portrait' do
57
+ @options = {:portrait => {'x' => 1, 'y' => 2, 'w' => 3, 'h' => 4, 'offset' => 0, 'url' => 'https://example.com'}}
58
+ profile.portrait.x.should == 1
59
+ profile.portrait.y.should == 2
60
+ profile.portrait.w.should == 3
61
+ profile.portrait.h.should == 4
62
+ profile.portrait.offset.should == 0
63
+ profile.portrait.url.should == 'https://example.com'
64
+ end
65
+
66
+ it 'should store the career' do
67
+ @options = {
68
+ :career => {
69
+ :primary_race => 'TERRAN',
70
+ :league => 'KAPPA',
71
+ :terran_wins => 1,
72
+ :protoss_wins => 268,
73
+ :zerg_wins => 7,
74
+ :highest1v1_rank => 'MASTER',
75
+ :highest_team_rank => 'MASTER',
76
+ :season_total_games => 399,
77
+ :career_total_games => 1531
78
+ }
79
+ }
80
+ profile.career.primary_race.should == 'TERRAN'
81
+ profile.career.league.should == 'KAPPA'
82
+ profile.career.terran_wins.should == 1
83
+ profile.career.protoss_wins.should == 268
84
+ profile.career.zerg_wins.should == 7
85
+ profile.career.highest1v1_rank.should == 'MASTER'
86
+ profile.career.highest_team_rank.should == 'MASTER'
87
+ profile.career.season_total_games.should == 399
88
+ profile.career.career_total_games.should == 1531
89
+ end
90
+
91
+ it 'should store the swarm_levels' do
92
+ @options = {
93
+ :swarm_levels => {
94
+ :level => 45,
95
+ :terran => {
96
+ :level => 9,
97
+ :total_level_XP => 150000,
98
+ :current_level_XP => 8826
99
+ },
100
+ :zerg => {
101
+ :level => 6,
102
+ :total_level_XP => 150000,
103
+ :current_level_XP => 1231
104
+ },
105
+ :protoss => {
106
+ :level => 30,
107
+ :total_level_XP => 150000,
108
+ :current_level_XP => 8826
109
+ }
110
+ }
111
+ }
112
+
113
+ profile.swarm_levels.class.should == Starcraft2::Profile::SwarmLevels
114
+ profile.swarm_levels.level.should == 45
115
+
116
+ terran = profile.swarm_levels.terran
117
+ terran.class.should == Starcraft2::Profile::SwarmRace
118
+ terran.level.should == 9
119
+ terran.total_level_xp.should == 150000
120
+ terran.current_level_xp.should == 8826
121
+
122
+ zerg = profile.swarm_levels.zerg
123
+ zerg.class.should == Starcraft2::Profile::SwarmRace
124
+ zerg.level.should == 6
125
+ zerg.total_level_xp.should == 150000
126
+ zerg.current_level_xp.should == 1231
127
+
128
+ protoss = profile.swarm_levels.protoss
129
+ protoss.class.should == Starcraft2::Profile::SwarmRace
130
+ protoss.level.should == 30
131
+ protoss.total_level_xp.should == 150000
132
+ protoss.current_level_xp.should == 8826
133
+ end
134
+
135
+ it 'should store the campaign' do
136
+ @options = {:campaign => {:wol => 'BRUTAL', :hots => 'BRUTAL'}}
137
+ profile.campaign.wol.should == 'BRUTAL'
138
+ profile.campaign.hots.should == 'BRUTAL'
139
+ end
140
+
141
+ it 'should store the season' do
142
+ @options = {
143
+ :season => {
144
+ :season_id => 14,
145
+ :total_games_this_season => 399,
146
+ :stats => [
147
+ {
148
+ :type => '1v1',
149
+ :wins => 254,
150
+ :games => 357
151
+ }, {
152
+ :type => '2v2',
153
+ :wins => 27,
154
+ :games => 39
155
+ }
156
+ ]
157
+ }}
158
+ end
159
+
160
+ it 'should store the rewards' do
161
+ @options = {
162
+ :rewards => {
163
+ :selected => [18730036, 2009110693, 2359737029, 4189275055],
164
+ :earned => [144654643, 171155159, 199895074, 234481452, 367294557, 531423509, 533048170, 637508413]
165
+ }
166
+ }
167
+ profile.rewards.selected.should == [18730036, 2009110693, 2359737029, 4189275055]
168
+ profile.rewards.earned.should == [144654643, 171155159, 199895074, 234481452, 367294557, 531423509, 533048170, 637508413]
169
+ end
170
+
171
+ it 'should store the achievements' do
172
+ @options = {
173
+ :achievements => {
174
+ :points => {
175
+ :totalPoints => 3375,
176
+ :categoryPoints => {
177
+ '4325382' => 0,
178
+ '4325380' => 390,
179
+ '4325408' => 90,
180
+ '4325379' => 915,
181
+ '4325410' => 1380,
182
+ '4325377' => 600
183
+ }
184
+ },
185
+ :achievements => [
186
+ {
187
+ :achievementId => 91475320766493,
188
+ :completionDate => 1375779974
189
+ }, {
190
+ :achievementId => 91475035553809,
191
+ :completionDate => 1371117026
192
+ }
193
+ ]
194
+ }
195
+ }
196
+ end
197
+ end
198
+
199
+ describe '.matches' do
200
+ let(:client) { Starcraft2::Client.new() }
201
+
202
+ it 'should return a list of matches' do
203
+ VCR.use_cassette("matches_999000") do
204
+ matches = client.profile(:character_name => 'DayNine', :id => 999000, :realm => 1).matches
205
+ matches.class.should == Array
206
+ matches.first.class.should == Starcraft2::Profile::Match
207
+ matches.first.map.should == 'HOTS Unit Tester Online'
208
+ matches.first.type.should == 'CUSTOM'
209
+ matches.first.decision.should == 'BAILER'
210
+ matches.first.speed.should == 'FASTER'
211
+ matches.first.date.should == 1376528216
212
+ end
213
+ end
214
+ end
215
+ end
@@ -14,7 +14,7 @@ Gem::Specification.new do |gem|
14
14
  gem.test_files = `git ls-files -- {spec}/*`.split("\n")
15
15
  gem.name = "starcraft2"
16
16
  gem.require_paths = ["lib"]
17
- gem.version = "0.0.10"
17
+ gem.version = "0.1.0"
18
18
 
19
19
  gem.add_development_dependency 'rspec', '~> 2.6.0'
20
20
  gem.add_development_dependency 'rake'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: starcraft2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Ellithorpe
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-08-14 00:00:00.000000000 Z
13
+ date: 2013-08-15 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: httparty
@@ -127,6 +127,8 @@ files:
127
127
  - fixtures/cassettes/achievements.yml
128
128
  - fixtures/cassettes/grandmaster.yml
129
129
  - fixtures/cassettes/ladder_148200.yml
130
+ - fixtures/cassettes/matches_999000.yml
131
+ - fixtures/cassettes/profile_999000.yml
130
132
  - fixtures/cassettes/rewards.yml
131
133
  - fixtures/vcr_cassettes/grandmaster.yml
132
134
  - fixtures/vcr_cassettes/previous_grandmaster.yml
@@ -134,10 +136,23 @@ files:
134
136
  - lib/starcraft2/achievement.rb
135
137
  - lib/starcraft2/character.rb
136
138
  - lib/starcraft2/client.rb
139
+ - lib/starcraft2/errors/missing_arguments_error.rb
137
140
  - lib/starcraft2/icon.rb
138
141
  - lib/starcraft2/ladder.rb
139
142
  - lib/starcraft2/loader.rb
140
143
  - lib/starcraft2/member.rb
144
+ - lib/starcraft2/profile.rb
145
+ - lib/starcraft2/profile/achievement_item.rb
146
+ - lib/starcraft2/profile/achievements.rb
147
+ - lib/starcraft2/profile/campaign.rb
148
+ - lib/starcraft2/profile/career.rb
149
+ - lib/starcraft2/profile/match.rb
150
+ - lib/starcraft2/profile/points.rb
151
+ - lib/starcraft2/profile/rewards.rb
152
+ - lib/starcraft2/profile/season.rb
153
+ - lib/starcraft2/profile/stats.rb
154
+ - lib/starcraft2/profile/swarm_levels.rb
155
+ - lib/starcraft2/profile/swarm_race.rb
141
156
  - lib/starcraft2/reward.rb
142
157
  - lib/starcraft2/utils.rb
143
158
  - spec/spec_helper.rb
@@ -147,6 +162,14 @@ files:
147
162
  - spec/starcraft2/icon_spec.rb
148
163
  - spec/starcraft2/ladder_spec.rb
149
164
  - spec/starcraft2/member_spec.rb
165
+ - spec/starcraft2/profile/achievements_spec.rb
166
+ - spec/starcraft2/profile/campaign_spec.rb
167
+ - spec/starcraft2/profile/career_spec.rb
168
+ - spec/starcraft2/profile/match_spec.rb
169
+ - spec/starcraft2/profile/rewards_spec.rb
170
+ - spec/starcraft2/profile/season_spec.rb
171
+ - spec/starcraft2/profile/swarm_levels_spec.rb
172
+ - spec/starcraft2/profile_spec.rb
150
173
  - spec/starcraft2/reward_spec.rb
151
174
  - spec/starcraft2/utils_spec.rb
152
175
  - starcraft2.gemspec