starcraft2 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +0 -1
- data/README.md +4 -1
- data/fixtures/cassettes/achievements.yml +13340 -0
- data/fixtures/cassettes/grandmaster.yml +6406 -0
- data/fixtures/cassettes/ladder_148200.yml +6374 -0
- data/fixtures/cassettes/rewards.yml +4192 -0
- data/fixtures/vcr_cassettes/grandmaster.yml +3221 -0
- data/fixtures/vcr_cassettes/previous_grandmaster.yml +39 -0
- data/lib/starcraft2.rb +1 -1
- data/lib/{sc2 → starcraft2}/achievement.rb +3 -5
- data/lib/starcraft2/character.rb +11 -0
- data/lib/{sc2 → starcraft2}/client.rb +24 -3
- data/lib/starcraft2/ladder.rb +10 -0
- data/lib/starcraft2/loader.rb +9 -0
- data/lib/starcraft2/member.rb +13 -0
- data/lib/{sc2 → starcraft2}/reward.rb +3 -5
- data/spec/spec_helper.rb +5 -2
- data/spec/starcraft2/achievement_spec.rb +71 -0
- data/spec/starcraft2/character_spec.rb +41 -0
- data/spec/starcraft2/client_spec.rb +114 -0
- data/spec/starcraft2/ladder_spec.rb +28 -0
- data/spec/starcraft2/member_spec.rb +81 -0
- data/spec/starcraft2/reward_spec.rb +59 -0
- data/starcraft2.gemspec +3 -1
- metadata +55 -13
- data/fixtures/vcr_cassettes/achievements.yml +0 -14844
- data/fixtures/vcr_cassettes/rewards.yml +0 -7692
- data/lib/sc2/loader.rb +0 -5
- data/spec/sc2/achievement_spec.rb +0 -58
- data/spec/sc2/client_spec.rb +0 -75
- data/spec/sc2/reward_spec.rb +0 -48
data/lib/sc2/loader.rb
DELETED
@@ -1,58 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe SC2::Achievement do
|
4
|
-
describe '#build_achievements' do
|
5
|
-
let(:achievements) { SC2::Achievement.build_achievements(@raw_achievement_data)}
|
6
|
-
|
7
|
-
before do
|
8
|
-
VCR.use_cassette('achievements') do
|
9
|
-
@raw_achievement_data = HTTParty.get('http://us.battle.net/api/sc2/data/achievements').body
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
it 'should build an array of achievements' do
|
14
|
-
achievements.class.should == Array
|
15
|
-
achievements.each do |a|
|
16
|
-
a.class.should == SC2::Achievement
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
describe '.initialize' do
|
22
|
-
let(:achievement) {SC2::Achievement.new(@options)}
|
23
|
-
|
24
|
-
before do
|
25
|
-
@options = {}
|
26
|
-
end
|
27
|
-
|
28
|
-
it 'should store the title' do
|
29
|
-
@options = {:title => 'Test Title'}
|
30
|
-
achievement.title.should == 'Test Title'
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'should store the description' do
|
34
|
-
@options = {:description => 'Description'}
|
35
|
-
achievement.description.should == 'Description'
|
36
|
-
end
|
37
|
-
|
38
|
-
it 'should store the achievement id' do
|
39
|
-
@options = {:achievement_id => 5}
|
40
|
-
achievement.achievement_id.should == 5
|
41
|
-
end
|
42
|
-
|
43
|
-
it 'should store the category id' do
|
44
|
-
@options = {:category_id => 10}
|
45
|
-
achievement.category_id.should == 10
|
46
|
-
end
|
47
|
-
|
48
|
-
it 'should store the points' do
|
49
|
-
@options = {:points => 5}
|
50
|
-
achievement.points.should == 5
|
51
|
-
end
|
52
|
-
|
53
|
-
it 'should store the icon data' do
|
54
|
-
@options = {:icon => {:x => 1, :y => 2, :w => 3, :h => 4, :offset => 0, :url => 'http://example.com'}}
|
55
|
-
achievement.icon.should == {:x => 1, :y => 2, :w => 3, :h => 4, :offset => 0, :url => 'http://example.com'}
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
data/spec/sc2/client_spec.rb
DELETED
@@ -1,75 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe SC2::Client do
|
4
|
-
let(:client) { SC2::Client.new(@options)}
|
5
|
-
|
6
|
-
before do
|
7
|
-
@options = {:host => 'us.battle.net'}
|
8
|
-
end
|
9
|
-
|
10
|
-
context 'url constants' do
|
11
|
-
it 'should store the achievements url' do
|
12
|
-
SC2::Client::ACHIEVEMENTS_PATH.should == '/api/sc2/data/achievements'
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'should store the rewards url' do
|
16
|
-
SC2::Client::REWARDS_PATH.should == '/api/sc2/data/rewards'
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
describe ".initialize" do
|
21
|
-
it 'should store the locale' do
|
22
|
-
@options = { :locale => 'en_US' }
|
23
|
-
client.locale.should == 'en_US'
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'should store the host' do
|
27
|
-
@options = { :host => 'someserver.com'}
|
28
|
-
client.host.should == 'someserver.com'
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
describe ".achievements" do
|
33
|
-
it 'should return an array of achievements' do
|
34
|
-
VCR.use_cassette('achievements') do
|
35
|
-
client.achievements.class.should == Array
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
it 'should return items of type SC2::Achievement' do
|
40
|
-
VCR.use_cassette('achievements') do
|
41
|
-
client.achievements.first.class.should == SC2::Achievement
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
it "should return achievements in the correct locale" do
|
46
|
-
@options.merge!({:locale => "pt_BR"})
|
47
|
-
|
48
|
-
VCR.use_cassette('achievements') do
|
49
|
-
client.achievements.first.title.should == "TCT Destruidor"
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
describe ".rewards" do
|
55
|
-
it 'should return an array of rewards' do
|
56
|
-
VCR.use_cassette('rewards') do
|
57
|
-
client.rewards.class.should == Array
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
it 'should return items of type SC2::Reward' do
|
62
|
-
VCR.use_cassette('rewards') do
|
63
|
-
client.rewards.first.class.should == SC2::Reward
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
it "should return rewards in the correct locale" do
|
68
|
-
@options.merge!({:locale => "pt_BR"})
|
69
|
-
|
70
|
-
VCR.use_cassette('rewards') do
|
71
|
-
client.rewards.first.title.should == "Kachinsky"
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
data/spec/sc2/reward_spec.rb
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe SC2::Reward do
|
4
|
-
describe '#build_rewards' do
|
5
|
-
let(:rewards) { SC2::Reward.build_rewards(@raw_reward_data)}
|
6
|
-
|
7
|
-
before do
|
8
|
-
VCR.use_cassette('rewards') do
|
9
|
-
@raw_reward_data = HTTParty.get('http://us.battle.net/api/sc2/data/rewards').body
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
it 'should build an array of rewards' do
|
14
|
-
rewards.class.should == Array
|
15
|
-
rewards.each do |r|
|
16
|
-
r.class.should == SC2::Reward
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
describe '.initialize' do
|
22
|
-
let(:reward) {SC2::Reward.new(@options)}
|
23
|
-
|
24
|
-
before do
|
25
|
-
@options = {}
|
26
|
-
end
|
27
|
-
|
28
|
-
it 'should store the title' do
|
29
|
-
@options = {:title => 'Test Title'}
|
30
|
-
reward.title.should == 'Test Title'
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'should store the id' do
|
34
|
-
@options = {:id => 3}
|
35
|
-
reward.id.should == 3
|
36
|
-
end
|
37
|
-
|
38
|
-
it 'should store the icon data' do
|
39
|
-
@options = {:icon => {:x => 1, :y => 2, :w => 3, :h => 4, :offset => 0, :url => 'http://example.com'}}
|
40
|
-
reward.icon.should == {:x => 1, :y => 2, :w => 3, :h => 4, :offset => 0, :url => 'http://example.com'}
|
41
|
-
end
|
42
|
-
|
43
|
-
it "should store the achievement id" do
|
44
|
-
@options = {:achievement_id => 5}
|
45
|
-
reward.achievement_id.should == 5
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|