bnet 0.0.3 → 0.0.4

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.
data/lib/bnet/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Bnet
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -0,0 +1,56 @@
1
+ require 'spec_helper'
2
+
3
+ describe Bnet::Diablo3::Follower do
4
+
5
+ describe('.from_api(follower_type, raw_response)') do
6
+ subject {described_class.from_api(follower_type, raw_response)}
7
+ let(:follower_type) {'templar'}
8
+ let(:raw_response) do
9
+ {
10
+ 'level' => 69,
11
+ 'stats' => {
12
+ 'magicFind' => 50,
13
+ 'experienceBonus' => 40,
14
+ 'goldFind' => 30
15
+ },
16
+
17
+ 'skills' => [
18
+ { 'skill' => {'name' => 'Falcon Punch'}},
19
+ { 'skill' => {'name' => 'Surprise Abortion'}}
20
+ ],
21
+
22
+ 'items' => {
23
+ 'head' => {'name' => 'Falcon Helmet', 'id' => 'Falcon_Helm'},
24
+ 'hands' => {'name' => 'Falcon Gloves', 'id' => 'Falcon_Gloves'}
25
+ }
26
+ }
27
+ end
28
+
29
+ it "should be initialized" do
30
+ expect(subject).to be_an_instance_of(described_class)
31
+ expect(subject).to have_attributes(
32
+ {
33
+ follower_type: 'templar',
34
+ level: 69,
35
+ magic_find: 50,
36
+ experience_bonus: 40,
37
+ gold_find: 30
38
+ }
39
+ )
40
+ end
41
+
42
+ it "assign follower skills" do
43
+ expect(subject.skills).to match([
44
+ an_object_having_attributes(name: 'Falcon Punch'),
45
+ an_object_having_attributes(name: 'Surprise Abortion')
46
+ ])
47
+ end
48
+
49
+ it "assign follower items" do
50
+ expect(subject.items).to match([
51
+ an_object_having_attributes(location: 'head', name: 'Falcon Helmet', item_id: 'Falcon_Helm'),
52
+ an_object_having_attributes(location: 'hands', name: 'Falcon Gloves', item_id: 'Falcon_Gloves')
53
+ ])
54
+ end
55
+ end
56
+ end
@@ -20,6 +20,47 @@ describe Bnet::Diablo3::Hero do
20
20
  expect(subject.hero_class).to eq('wizard')
21
21
  end
22
22
 
23
+ it "assigns follower" do
24
+ expect(subject.followers).to match([
25
+ an_object_having_attributes(
26
+ follower_type: 'templar', level: 70,
27
+ gold_find: 11, magic_find: 0, experience_bonus: 19,
28
+ skills: include(
29
+ an_object_having_attributes(name: "Intervene"),
30
+ an_object_having_attributes(name: "Loyalty"),
31
+ an_object_having_attributes(name: "Charge"),
32
+ an_object_having_attributes(name: "Inspire")
33
+ ),
34
+ items: include(
35
+ an_object_having_attributes(name: "Intrepid Trinket", item_id: 'Templar_Special_203', location: 'special'),
36
+ an_object_having_attributes(name: "Cut Blast", item_id: 'Axe_1H_301', location: 'mainHand'),
37
+ an_object_having_attributes(name: "Savior's Interceptor", item_id: 'Shield_208', location: 'offHand')
38
+ )
39
+ ),
40
+
41
+ an_object_having_attributes(
42
+ follower_type: 'scoundrel', level: 70,
43
+ gold_find: 0, magic_find: 0, experience_bonus: 0,
44
+ skills: match([]),
45
+ items: include(
46
+ an_object_having_attributes(name: "Unwavering Find", item_id: 'Scoundrel_Special_204', location: 'special'),
47
+ an_object_having_attributes(name: "Light Crossbow of Slaying", item_id: 'Crossbow_001', location: 'mainHand'),
48
+ an_object_having_attributes(name: "Loyalty Aim", item_id: 'Ring_18', location: 'rightFinger')
49
+ )
50
+ ),
51
+
52
+ an_object_having_attributes(
53
+ follower_type: 'enchantress', level: 70,
54
+ gold_find: 0, magic_find: 0, experience_bonus: 0,
55
+ items: include(
56
+ an_object_having_attributes(name: "Citadel Bounty", item_id: 'Enchantress_Special_204', location: 'special'),
57
+ an_object_having_attributes(name: "Adept's Atrocity", item_id: 'Staff_203', location: 'mainHand'),
58
+ an_object_having_attributes(name: "Black Wheel", item_id: 'Ring_19', location: 'rightFinger')
59
+ )
60
+ )
61
+ ])
62
+ end
63
+
23
64
  it "assigns items" do
24
65
  expect(subject.items).to match([
25
66
  an_object_having_attributes(location: "head", name: "Leoric's Crown", item_id: "Unique_Helm_002_x1" ),
@@ -1,4 +1,18 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Bnet::Diablo3::Item do
4
+ describe ".from_api(location, raw_response)" do
5
+ subject { described_class.from_api(location, raw_response) }
6
+ let(:location) {'head'}
7
+ let(:raw_response) { {'name' => 'PooPoo Hat', 'id' => "Poopoo_69"} }
8
+
9
+ it "should be initialized" do
10
+ expect(subject).to be_a_kind_of(described_class)
11
+ expect(subject).to have_attributes({
12
+ name: 'PooPoo Hat',
13
+ item_id: "Poopoo_69"
14
+ })
15
+ end
16
+
17
+ end
4
18
  end
@@ -0,0 +1,40 @@
1
+ # => {"primaryRace"=>"PROTOSS", "terranWins"=>0, "protossWins"=>0, "zergWins"=>0, "highest1v1Rank"=>"DIAMOND",
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Bnet::Starcraft2::Career do
6
+ describe '.from_api(args)' do
7
+ subject { described_class.from_api(args) }
8
+ let(:args) do
9
+ {
10
+ 'primaryRace' => 'PROTOSS',
11
+ 'terranWins' => 1,
12
+ 'protosswins' => 3,
13
+ 'zergWins' => 0,
14
+ 'highest1v1Rank' => "DIAMOND",
15
+ 'highestTeamRank' => "MASTER",
16
+ "seasonTotalGames" => 0,
17
+ "careerTotalGames" => 780
18
+ }
19
+ end
20
+
21
+
22
+ it "returns an instance" do
23
+ expect(subject).to be_a_kind_of(described_class)
24
+ expect(subject).to have_attributes(
25
+ primary_race: 'PROTOSS',
26
+ terran_wins: 1,
27
+ protoss_wins: 3,
28
+ zerg_wins: 0,
29
+ highest_1v1_rank: 'DIAMOND',
30
+ highest_team_rank: 'MASTER',
31
+ season_total_games: 0,
32
+ career_total_games: 780
33
+ )
34
+ end
35
+ end
36
+
37
+ end
38
+
39
+
40
+
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ describe Bnet::Starcraft2::Match do
4
+ describe '.all(profile)', vcr: {cassette_name: 'SC2 Matches for Naniwa Profile found'} do
5
+ subject{described_class.all(profile)}
6
+ let(:profile) { Bnet::Starcraft2::Profile.new(profile_id: 2210662, name: 'NaNiwa', region: 'eu')}
7
+
8
+ it "returns a collection of matches for a given profile" do
9
+ expect(subject).to include(
10
+ an_object_having_attributes( map: "Deadwing LE", match_type: "SOLO", decision: "WIN", speed: "FASTER", date: 1410222237),
11
+ an_object_having_attributes( map: "Deadwing LE", match_type: "SOLO", decision: "WIN", speed: "FASTER", date: 1410221657),
12
+ an_object_having_attributes( map: "King Sejong Station LE", match_type: "SOLO", decision: "WIN", speed: "FASTER", date: 1410220846)
13
+ )
14
+ end
15
+
16
+ end
17
+ end
@@ -15,7 +15,7 @@ describe Bnet::Starcraft2::Profile do
15
15
 
16
16
  it "is initialized" do
17
17
  expect(subject).to be_a_kind_of(described_class)
18
- expect(subject.display_name).to eq("Testname")
18
+ expect(subject.name).to eq("Testname")
19
19
  end
20
20
  end
21
21
 
@@ -26,7 +26,11 @@ describe Bnet::Starcraft2::Profile do
26
26
  {region: 'us', profile_id: 2143215, name: 'PlayerOne'}
27
27
  }
28
28
  it "returns an instance" do
29
- expect(subject.display_name).to eq("PlayerOne")
29
+ expect(subject.name).to eq("PlayerOne")
30
+ end
31
+
32
+ it "sets the region" do
33
+ expect(subject.region).to eq('us')
30
34
  end
31
35
 
32
36
  it "sets the achievement point details" do
@@ -39,6 +43,19 @@ describe Bnet::Starcraft2::Profile do
39
43
  expect(subject.protoss_level).to eq(2)
40
44
  expect(subject.zerg_level).to eq(0)
41
45
  end
46
+
47
+ it "assigns the career" do
48
+ expect(subject.career).to have_attributes(
49
+ :career_total_games => 780,
50
+ :highest_1v1_rank => "DIAMOND",
51
+ :highest_team_rank => "MASTER",
52
+ :primary_race => "PROTOSS",
53
+ :season_total_games => 0,
54
+ :terran_wins => 0,
55
+ :zerg_wins => 0
56
+ )
57
+ end
58
+
42
59
  end
43
60
 
44
61
  context "specified user does not exist on the server", {vcr: {cassette_name: "sc2_profile_not_found" }} do
@@ -50,4 +67,27 @@ describe Bnet::Starcraft2::Profile do
50
67
  end
51
68
  end
52
69
 
70
+ describe '#matches' do
71
+ context 'Naniwa user is found', vcr: {cassette_name: 'SC2 Naniwa profile found' } do
72
+ subject { profile.matches }
73
+ # subject { binding.pry }
74
+ let(:profile) {
75
+ a = Bnet::Starcraft2::Profile.find(profile_id: 2210662, name: 'NaNiwa', region: 'eu')
76
+ }
77
+
78
+ it "returns a collection of matches for a given profile" do
79
+ expect(subject).to_not be_empty
80
+ expect(subject).to include(
81
+ an_object_having_attributes( map: "Deadwing LE", match_type: "SOLO", decision: "WIN", speed: "FASTER", date: 1410222237),
82
+ an_object_having_attributes( map: "Deadwing LE", match_type: "SOLO", decision: "WIN", speed: "FASTER", date: 1410221657),
83
+ an_object_having_attributes( map: "King Sejong Station LE", match_type: "SOLO", decision: "WIN", speed: "FASTER", date: 1410220846)
84
+ )
85
+ end
86
+ end
87
+ end
88
+
89
+ describe '#ladders' do
90
+ subject {profile.ladders}
91
+ it "returns the ladder statistics for the profile"
92
+ end
53
93
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bnet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Buddy Magsipoc
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-06 00:00:00.000000000 Z
11
+ date: 2014-09-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -196,6 +196,9 @@ files:
196
196
  - Rakefile
197
197
  - TODO.md
198
198
  - bnet.gemspec
199
+ - fixtures/cassettes/Bnet_Starcraft2_Match/_all_profile_/returns_a_collection_of_matches_for_a_given_profile.yml
200
+ - fixtures/cassettes/SC2_Matches_for_Naniwa_Profile_found.yml
201
+ - fixtures/cassettes/SC2_Naniwa_profile_found.yml
199
202
  - fixtures/cassettes/diablo_hero_found.yml
200
203
  - fixtures/cassettes/diablo_hero_notf_found.yml
201
204
  - fixtures/cassettes/diablo_hero_reload.yml
@@ -215,10 +218,13 @@ files:
215
218
  - lib/bnet/configuration.rb
216
219
  - lib/bnet/diablo3.rb
217
220
  - lib/bnet/diablo3/career.rb
221
+ - lib/bnet/diablo3/follower.rb
218
222
  - lib/bnet/diablo3/hero.rb
219
223
  - lib/bnet/diablo3/item.rb
220
224
  - lib/bnet/diablo3/skill.rb
221
225
  - lib/bnet/starcraft2.rb
226
+ - lib/bnet/starcraft2/career.rb
227
+ - lib/bnet/starcraft2/match.rb
222
228
  - lib/bnet/starcraft2/profile.rb
223
229
  - lib/bnet/version.rb
224
230
  - lib/bnet/wow.rb
@@ -230,10 +236,13 @@ files:
230
236
  - spec/bnet/account_spec.rb
231
237
  - spec/bnet/api_spec.rb
232
238
  - spec/bnet/diablo3/career_spec.rb
239
+ - spec/bnet/diablo3/follower_spec.rb
233
240
  - spec/bnet/diablo3/hero_spec.rb
234
241
  - spec/bnet/diablo3/item_spec.rb
235
242
  - spec/bnet/diablo3/skill_spec.rb
236
243
  - spec/bnet/diablo3_spec.rb
244
+ - spec/bnet/starcraft2/career_spec.rb
245
+ - spec/bnet/starcraft2/match_spec.rb
237
246
  - spec/bnet/starcraft2/profile_spec.rb
238
247
  - spec/bnet/wow/character_spec.rb
239
248
  - spec/bnet/wow/data/base_spec.rb
@@ -272,10 +281,13 @@ test_files:
272
281
  - spec/bnet/account_spec.rb
273
282
  - spec/bnet/api_spec.rb
274
283
  - spec/bnet/diablo3/career_spec.rb
284
+ - spec/bnet/diablo3/follower_spec.rb
275
285
  - spec/bnet/diablo3/hero_spec.rb
276
286
  - spec/bnet/diablo3/item_spec.rb
277
287
  - spec/bnet/diablo3/skill_spec.rb
278
288
  - spec/bnet/diablo3_spec.rb
289
+ - spec/bnet/starcraft2/career_spec.rb
290
+ - spec/bnet/starcraft2/match_spec.rb
279
291
  - spec/bnet/starcraft2/profile_spec.rb
280
292
  - spec/bnet/wow/character_spec.rb
281
293
  - spec/bnet/wow/data/base_spec.rb