riot_api 0.0.4 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/CHANGELOG.md +5 -0
- data/README.md +3 -2
- data/lib/riot_api/api.rb +5 -3
- data/lib/riot_api/middleware/custom_logger.rb +70 -0
- data/lib/riot_api/model.rb +8 -0
- data/lib/riot_api/model/champion.rb +17 -0
- data/lib/riot_api/model/champion_stat.rb +13 -0
- data/lib/riot_api/model/game.rb +22 -0
- data/lib/riot_api/model/league.rb +13 -0
- data/lib/riot_api/model/league_entry.rb +21 -0
- data/lib/riot_api/model/mastery_page.rb +11 -0
- data/lib/riot_api/model/match.rb +17 -0
- data/lib/riot_api/model/member.rb +10 -0
- data/lib/riot_api/model/player.rb +9 -0
- data/lib/riot_api/model/player_stat_summary.rb +12 -0
- data/lib/riot_api/model/roster.rb +10 -0
- data/lib/riot_api/model/rune.rb +10 -0
- data/lib/riot_api/model/rune_page.rb +12 -0
- data/lib/riot_api/model/rune_slot.rb +10 -0
- data/lib/riot_api/model/statistic.rb +12 -0
- data/lib/riot_api/model/talent.rb +9 -0
- data/lib/riot_api/model/team.rb +26 -0
- data/lib/riot_api/model/team_id.rb +7 -0
- data/lib/riot_api/model/team_stat_detail.rb +13 -0
- data/lib/riot_api/model/team_stat_summary.rb +11 -0
- data/lib/riot_api/resource/base.rb +10 -0
- data/lib/riot_api/resource/champions.rb +4 -2
- data/lib/riot_api/resource/game.rb +8 -2
- data/lib/riot_api/resource/league.rb +6 -2
- data/lib/riot_api/resource/stats.rb +15 -3
- data/lib/riot_api/resource/summoner.rb +23 -7
- data/lib/riot_api/resource/team.rb +8 -2
- data/lib/riot_api/version.rb +1 -1
- data/spec/api_spec.rb +111 -54
- data/spec/model/champion_spec.rb +14 -0
- data/spec/model/champion_stat_spec.rb +18 -0
- data/spec/model/game_spec.rb +18 -0
- data/spec/model/league_entry_spec.rb +13 -0
- data/spec/model/league_spec.rb +17 -0
- data/spec/model/mastery_page_spec.rb +16 -0
- data/spec/model/match_spec.rb +13 -0
- data/spec/model/member_spec.rb +13 -0
- data/spec/model/player_stat_summary_spec.rb +20 -0
- data/spec/model/roster_spec.rb +15 -0
- data/spec/model/rune_page_spec.rb +16 -0
- data/spec/model/rune_slot_spec.rb +15 -0
- data/spec/model/rune_spec.rb +17 -0
- data/spec/model/statistic_spec.rb +17 -0
- data/spec/model/talent_spec.rb +16 -0
- data/spec/model/team_id_spec.rb +13 -0
- data/spec/model/team_spec.rb +44 -0
- data/spec/model/team_stat_detail_spec.rb +20 -0
- data/spec/model/team_stat_summary_stat.rb +27 -0
- data/spec/spec_helper.rb +11 -0
- data/spec/vcr/cassettes/RiotApi_API/_league/_by_summoner/{should_return_leagues_data_for_summoner.yml → should_return_league_object_for_summoner.yml} +0 -0
- data/spec/vcr/cassettes/RiotApi_API/_new/should_output_to_stdout_with_debug_parameter.yml +41 -0
- data/spec/vcr/cassettes/RiotApi_API/_new/should_raise_an_error_if_the_raise_error_status_flag_is_enabled.yml +55 -0
- data/spec/vcr/cassettes/RiotApi_API/_summoner/_id/should_return_information_from_the_summoner_id.yml +9 -15
- data/spec/vcr/cassettes/RiotApi_API/_summoner/_name/should_return_information_from_the_summoner_name.yml +9 -15
- metadata +72 -43
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RiotApi::Model::Champion do
|
4
|
+
|
5
|
+
describe '#initialize' do
|
6
|
+
let(:data) { { active:true, attack_rank:3, bot_enabled:false, bot_mm_enabled:false, defense_rank:4, difficulty_rank:8, free_to_play:false, id:103, magic_rank:8, name:"Ahri", ranked_play_enabled:true } }
|
7
|
+
let(:champion) { RiotApi::Model::Champion.new data }
|
8
|
+
|
9
|
+
it "should create a valid object" do
|
10
|
+
champion.id.should == data[:id]
|
11
|
+
champion.name.should == data[:name]
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RiotApi::Model::ChampionStat do
|
4
|
+
|
5
|
+
describe '#initialize' do
|
6
|
+
let(:data) { { :id => 111, :name => "Nautilus", :stats => [ { :c => 1, :id => 13, :name => "TOTAL_PENTA_KILLS", :value => 0 }, { :c => 1, :id => 14, :name => "TOTAL_DEATHS_PER_SESSION", :value => 5 } ] } }
|
7
|
+
let(:champion_stat) { RiotApi::Model::ChampionStat.new data }
|
8
|
+
|
9
|
+
it "should create a valid object" do
|
10
|
+
champion_stat.id.should == data[:id]
|
11
|
+
champion_stat.name.should == data[:name]
|
12
|
+
champion_stat.stats.class.should == Array
|
13
|
+
champion_stat.stats.first.class.should == RiotApi::Model::Statistic
|
14
|
+
|
15
|
+
champion_stat.statistics.should == champion_stat.stats
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RiotApi::Model::Game do
|
4
|
+
|
5
|
+
describe '#initialize' do
|
6
|
+
let(:data) { {"game_id"=>1188581883, "invalid"=>false, "game_mode"=>"CLASSIC", "game_type"=>"MATCHED_GAME", "sub_type"=>"RANKED_SOLO_5x5", "map_id"=>1, "team_id"=>200, "champion_id"=>412, "spell1"=>14, "spell2"=>4, "level"=>30, "create_date"=>1386619495913, "create_date_str"=>1386619495913, "fellow_players"=>[{"summoner_id"=>20200953, "team_id"=>100, "champion_id"=>92}, {"summoner_id"=>43470519, "team_id"=>200, "champion_id"=>33}], "statistics"=>[{"id"=>1, "name"=>"LEVEL", "value"=>12}, {"id"=>2, "name"=>"GOLD_EARNED", "value"=>8568}]} }
|
7
|
+
let(:game) { RiotApi::Model::Game.new data }
|
8
|
+
|
9
|
+
it "should create a valid object" do
|
10
|
+
game.game_id.should == data['game_id']
|
11
|
+
game.game_mode.should == data['game_mode']
|
12
|
+
game.fellow_players.class.should == Array
|
13
|
+
game.fellow_players.first.class.should == RiotApi::Model::Player
|
14
|
+
game.statistics.class.should == Array
|
15
|
+
game.statistics.first.class.should == RiotApi::Model::Statistic
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RiotApi::Model::LeagueEntry do
|
4
|
+
|
5
|
+
describe '#initialize' do
|
6
|
+
let(:data) { {"player_or_team_id"=>"7460", "player_or_team_name"=>"Chaox", "league_name"=>"Wukong's Lancers", "queue_type"=>"RANKED_SOLO_5x5", "tier"=>"CHALLENGER", "rank"=>"I", "league_points"=>204, "wins"=>919, "losses"=>866, "is_hot_streak"=>false, "is_veteran"=>false, "is_fresh_blood"=>false, "is_inactive"=>false, "last_played"=>0, "time_until_decay"=>-1} }
|
7
|
+
let(:league_entry) { RiotApi::Model::LeagueEntry.new data }
|
8
|
+
|
9
|
+
it "should create a valid object" do
|
10
|
+
league_entry.player_or_team_name.should == 'Chaox'
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RiotApi::Model::League do
|
4
|
+
|
5
|
+
describe '#initialize' do
|
6
|
+
let(:data) { {"timestamp"=>1387214440647, "name"=>"Wukong's Lancers", "tier"=>"CHALLENGER", "queue"=>"RANKED_SOLO_5x5", "entries"=>[{"player_or_team_id"=>"7460", "player_or_team_name"=>"Chaox", "league_name"=>"Wukong's Lancers", "queue_type"=>"RANKED_SOLO_5x5", "tier"=>"CHALLENGER", "rank"=>"I", "league_points"=>204, "wins"=>919, "losses"=>866, "is_hot_streak"=>false, "is_veteran"=>false, "is_fresh_blood"=>false, "is_inactive"=>false, "last_played"=>0, "time_until_decay"=>-1}, {"player_or_team_id"=>"38839329", "player_or_team_name"=>"Xia0MeLotusMindy", "league_name"=>"Wukong's Lancers", "queue_type"=>"RANKED_SOLO_5x5", "tier"=>"CHALLENGER", "rank"=>"I", "league_points"=>629, "wins"=>504, "losses"=>393, "is_hot_streak"=>false, "is_veteran"=>true, "is_fresh_blood"=>false, "is_inactive"=>false, "last_played"=>0, "time_until_decay"=>-1}]} }
|
7
|
+
let(:league) { RiotApi::Model::League.new data }
|
8
|
+
let(:league_entry) { league.entries.first }
|
9
|
+
|
10
|
+
it "should create a valid object" do
|
11
|
+
league.name.should == data['name']
|
12
|
+
league.entries.count.should == 2
|
13
|
+
league_entry.class.should == RiotApi::Model::LeagueEntry
|
14
|
+
league_entry.player_or_team_name.should == 'Chaox'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RiotApi::Model::MasteryPage do
|
4
|
+
|
5
|
+
describe '#initialize' do
|
6
|
+
let(:data) { { :current => false, :name => "Standard", :talents => [RiotApi::Model::Talent.new] } }
|
7
|
+
let(:rune_page) { RiotApi::Model::MasteryPage.new data }
|
8
|
+
|
9
|
+
it "should create a valid object" do
|
10
|
+
rune_page.name.should == data[:name]
|
11
|
+
rune_page.talents.should_not be_empty
|
12
|
+
rune_page.talents.first.class.should == RiotApi::Model::Talent
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RiotApi::Model::Match do
|
4
|
+
|
5
|
+
describe '#initialize' do
|
6
|
+
let(:data) { { assists: 24, date: 1383711181657, deaths: 12, game_id: 1147232295, game_mode: "CLASSIC", invalid: false, kills: 22, map_id: 1, opposing_team_kills: 12, opposing_team_name: "mcmaster lol", win: true } }
|
7
|
+
let(:match) { RiotApi::Model::Match.new data }
|
8
|
+
|
9
|
+
it "should create a valid object" do
|
10
|
+
match.assists.should == data[:assists]
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RiotApi::Model::Member do
|
4
|
+
|
5
|
+
describe '#initialize' do
|
6
|
+
let(:data) { { invite_date: 1321959007000, join_date: 1321959007000, player_id: 17772, status: "MEMBER" } }
|
7
|
+
let(:member) { RiotApi::Model::Member.new data }
|
8
|
+
|
9
|
+
it "should create a valid object" do
|
10
|
+
member.player_id.should == data[:player_id]
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RiotApi::Model::PlayerStatSummary do
|
4
|
+
|
5
|
+
describe '#initialize' do
|
6
|
+
let(:data) { { aggregated_stats: [ { count: 0, id: 23, name: "TOTAL_TURRETS_KILLED" }, { count: 150, id: 53, name: "TOTAL_DECAYER" } ], losses: 0, modify_date: 1385124845000, modify_date_str: 1385124845000, player_stat_summary_type: "AramUnranked5x5", wins: 1 } }
|
7
|
+
let(:player_stat_summary) { RiotApi::Model::PlayerStatSummary.new data }
|
8
|
+
|
9
|
+
it "should create a valid object" do
|
10
|
+
player_stat_summary.aggregated_stats.class.should == Array
|
11
|
+
player_stat_summary.aggregated_stats.first.class.should == RiotApi::Model::Statistic
|
12
|
+
|
13
|
+
player_stat_summary.losses.should == data[:losses]
|
14
|
+
player_stat_summary.modify_date.should == data[:modify_date]
|
15
|
+
player_stat_summary.modify_date_str.should == data[:modify_date_str].to_s
|
16
|
+
player_stat_summary.player_stat_summary_type.should == data[:player_stat_summary_type]
|
17
|
+
player_stat_summary.wins.should == data[:wins]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RiotApi::Model::Roster do
|
4
|
+
|
5
|
+
describe '#initialize' do
|
6
|
+
let(:data) { { member_list: [ { invite_date: 1321959007000, join_date: 1321959007000, player_id: 17772, status: "MEMBER" } ], owner_id: 19199530 } }
|
7
|
+
let(:roster) { RiotApi::Model::Roster.new data }
|
8
|
+
|
9
|
+
it "should create a valid object" do
|
10
|
+
roster.owner_id.should == data[:owner_id]
|
11
|
+
roster.member_list.class.should == Array
|
12
|
+
roster.member_list.first.class.should == RiotApi::Model::Member
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RiotApi::Model::RunePage do
|
4
|
+
|
5
|
+
describe '#initialize' do
|
6
|
+
let(:data) { { :current => false, :id => 16220664, :name => "Tank", :slots => [RiotApi::Model::RuneSlot.new] } }
|
7
|
+
let(:rune_page) { RiotApi::Model::RunePage.new data }
|
8
|
+
|
9
|
+
it "should create a valid object" do
|
10
|
+
rune_page.id.should == data[:id]
|
11
|
+
rune_page.slots.should_not be_empty
|
12
|
+
rune_page.slots.first.class.should == RiotApi::Model::RuneSlot
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RiotApi::Model::RuneSlot do
|
4
|
+
|
5
|
+
describe '#initialize' do
|
6
|
+
let(:data) { { :rune => RiotApi::Model::Rune.new, :rune_slot_id=>28 } }
|
7
|
+
let(:rune_slot) { RiotApi::Model::RuneSlot.new data }
|
8
|
+
|
9
|
+
it "should create a valid object" do
|
10
|
+
rune_slot.rune_slot_id.should == data[:rune_slot_id]
|
11
|
+
rune_slot.rune.should_not be_nil
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RiotApi::Model::Rune do
|
4
|
+
|
5
|
+
describe '#initialize' do
|
6
|
+
let(:data) { {id:5289, name:"Greater Glyph of Magic Resist", description:"+1.34 magic resist", tier:3} }
|
7
|
+
let(:rune) { RiotApi::Model::Rune.new data }
|
8
|
+
|
9
|
+
it "should create a valid object" do
|
10
|
+
rune.id.should == data[:id]
|
11
|
+
rune.name.should == data[:name]
|
12
|
+
rune.description.should == data[:description]
|
13
|
+
rune.tier.should == data[:tier]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RiotApi::Model::Statistic do
|
4
|
+
|
5
|
+
describe '#initialize' do
|
6
|
+
let(:data) { { :c => 1, :id => 14, :name => "TOTAL_DEATHS_PER_SESSION", :value => 5 } }
|
7
|
+
let(:statistic) { RiotApi::Model::Statistic.new data }
|
8
|
+
|
9
|
+
it "should create a valid object" do
|
10
|
+
statistic.c.should == data[:c]
|
11
|
+
statistic.count.should == data[:c]
|
12
|
+
statistic.id.should == data[:id]
|
13
|
+
statistic.name.should == data[:name]
|
14
|
+
statistic.value.should == data[:value]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RiotApi::Model::Talent do
|
4
|
+
|
5
|
+
describe '#initialize' do
|
6
|
+
let(:data) { { id: 4212, name: "Recovery", rank: 2 } }
|
7
|
+
let(:rune) { RiotApi::Model::Talent.new data }
|
8
|
+
|
9
|
+
it "should create a valid object" do
|
10
|
+
rune.id.should == data[:id]
|
11
|
+
rune.name.should == data[:name]
|
12
|
+
rune.rank.should == data[:rank]
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RiotApi::Model::TeamId do
|
4
|
+
|
5
|
+
describe '#initialize' do
|
6
|
+
let(:data) { { full_id: "TEAM-e4936d7b-b80e-4367-a76c-5ccf7388c995" } }
|
7
|
+
let(:team_id) { RiotApi::Model::TeamId.new data }
|
8
|
+
|
9
|
+
it "should create a valid object" do
|
10
|
+
team_id.full_id.should == data[:full_id]
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RiotApi::Model::Team do
|
4
|
+
|
5
|
+
describe '#initialize' do
|
6
|
+
let(:match_history_data) { { assists: 24, date: 1383711181657, deaths: 12, game_id: 1147232295, game_mode: "CLASSIC", invalid: false, kills: 22, map_id: 1, opposing_team_kills: 12, opposing_team_name: "mcmaster lol", win: true } }
|
7
|
+
let(:member_list_data) { { invite_date: 1321959007000, join_date: 1321959007000, player_id: 17772, status: "MEMBER" } }
|
8
|
+
let(:roster_data) { { member_list: [ member_list_data ], owner_id: 19199530 } }
|
9
|
+
let(:team_id_data) { { full_id: "TEAM-e4936d7b-b80e-4367-a76c-5ccf7388c995" } }
|
10
|
+
let(:team_stat_details_data) { { average_games_played: 0, losses: 1, team_id: team_id_data, team_stat_type: "RANKED_TEAM_5x5", wins: 30 } }
|
11
|
+
let(:team_stat_summary_data) { { team_id: team_id_data, team_stat_details: [ team_stat_details_data ] } }
|
12
|
+
let(:data) { { create_date: 1321959007000, last_game_date: 1383711181000, last_join_date: 1383700685000, last_joined_ranked_team_queue_date: 1383708165000, match_history: [ match_history_data ], modify_date: 1383711181000, name: "Team Solo Mid", roster: roster_data, second_last_join_date: 1380166227000, status: "RANKED", tag: "TSM", team_id: team_id_data, team_stat_summary: team_stat_summary_data, third_last_join_date: 1372822629000, timestamp: 1387464944264 } }
|
13
|
+
let(:team) { RiotApi::Model::Team.new data }
|
14
|
+
|
15
|
+
it "should create a valid object" do
|
16
|
+
team.create_date.should == data[:create_date]
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should create match_history correctly" do
|
20
|
+
team.match_history.class.should == Array
|
21
|
+
team.match_history.first.class.should == RiotApi::Model::Match
|
22
|
+
team.match_history.first.assists.should == match_history_data[:assists]
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should create roster correctly" do
|
26
|
+
team.roster.class.should == RiotApi::Model::Roster
|
27
|
+
team.roster.owner_id.should == roster_data[:owner_id]
|
28
|
+
team.roster.member_list.class.should == Array
|
29
|
+
team.roster.member_list.first.class.should == RiotApi::Model::Member
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should create team_id correctly" do
|
33
|
+
team.team_id.class.should == RiotApi::Model::TeamId
|
34
|
+
team.team_id.full_id.should == team_id_data[:full_id]
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should create team_stat_summary correctly" do
|
38
|
+
team.team_stat_summary.class.should == RiotApi::Model::TeamStatSummary
|
39
|
+
team.team_stat_summary.team_id.class.should == RiotApi::Model::TeamId
|
40
|
+
team.team_stat_summary.team_stat_details.class.should == Array
|
41
|
+
team.team_stat_summary.team_stat_details.first.class.should == RiotApi::Model::TeamStatDetail
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RiotApi::Model::TeamStatDetail do
|
4
|
+
|
5
|
+
describe '#initialize' do
|
6
|
+
let(:team_id_data) { { full_id: "TEAM-e4936d7b-b80e-4367-a76c-5ccf7388c995" } }
|
7
|
+
let(:data) { { average_games_played: 0, losses: 1, team_id: team_id_data, team_stat_type: "RANKED_TEAM_5x5", wins: 30 } }
|
8
|
+
let(:team_stat_detail) { RiotApi::Model::TeamStatDetail.new data }
|
9
|
+
|
10
|
+
it "should create a valid object" do
|
11
|
+
team_stat_detail.losses.should == data[:losses]
|
12
|
+
team_stat_detail.team_id.class.should == RiotApi::Model::TeamId
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should create team_id correctly" do
|
16
|
+
team_stat_detail.team_id.full_id.should == team_id_data[:full_id]
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RiotApi::Model::TeamStatSummary do
|
4
|
+
|
5
|
+
describe '#initialize' do
|
6
|
+
let(:team_id_data) { { full_id: "TEAM-e4936d7b-b80e-4367-a76c-5ccf7388c995" } }
|
7
|
+
let(:team_stat_details_data) { { average_games_played: 0, losses: 1, team_id: team_id_data, team_stat_type: "RANKED_TEAM_5x5", wins: 30 } }
|
8
|
+
let(:data) { { team_id: team_id_data, team_stat_details: [ team_stat_details_data ] } }
|
9
|
+
let(:team_stat_summary) { RiotApi::Model::TeamStatSummary.new data }
|
10
|
+
|
11
|
+
it "should create a valid object" do
|
12
|
+
team_stat_summary.team_id.class.should == RiotApi::Model::TeamId
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should create team_id correctly" do
|
16
|
+
team_stat_summary.team_id.class.should == RiotApi::Model::TeamId
|
17
|
+
team_stat_summary.team_id.full_id.should == team_id_data[:full_id]
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should create team_stat_details correctly" do
|
21
|
+
team_stat_summary.team_stat_details.class.should == Array
|
22
|
+
team_stat_summary.team_stat_details.first.class.should == RiotApi::Model::TeamStatDetail
|
23
|
+
team_stat_summary.team_stat_details.first.team_id.class.should == RiotApi::Model::TeamId
|
24
|
+
team_stat_summary.team_stat_details.first.losses.should == 1
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -26,3 +26,14 @@ end
|
|
26
26
|
|
27
27
|
Dir["./spec/support/**/*.rb"].sort.each {|f| require f}
|
28
28
|
|
29
|
+
require 'stringio'
|
30
|
+
|
31
|
+
def capture_stdout &block
|
32
|
+
old_stdout = $stdout
|
33
|
+
fake_stdout = StringIO.new
|
34
|
+
$stdout = fake_stdout
|
35
|
+
block.call
|
36
|
+
fake_stdout.string
|
37
|
+
ensure
|
38
|
+
$stdout = old_stdout
|
39
|
+
end
|
File without changes
|
@@ -0,0 +1,41 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://prod.api.pvp.net/api/lol/euw/v1.1/summoner/by-name/BestLuxEUW?api_key=api_key_YYYYYYYYYYYYYYYYYYYYY
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- riot_api rubygem v0.0.4
|
12
|
+
response:
|
13
|
+
status:
|
14
|
+
code: 200
|
15
|
+
message:
|
16
|
+
headers:
|
17
|
+
access-control-allow-headers:
|
18
|
+
- Content-Type
|
19
|
+
access-control-allow-methods:
|
20
|
+
- GET, POST, DELETE, PUT
|
21
|
+
access-control-allow-origin:
|
22
|
+
- ! '*'
|
23
|
+
content-type:
|
24
|
+
- application/json;charset=UTF-8
|
25
|
+
date:
|
26
|
+
- Mon, 16 Dec 2013 17:20:03 GMT
|
27
|
+
server:
|
28
|
+
- Jetty(9.1.0.v20131115)
|
29
|
+
x-newrelic-app-data:
|
30
|
+
- XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
|
31
|
+
content-length:
|
32
|
+
- '146'
|
33
|
+
connection:
|
34
|
+
- Close
|
35
|
+
body:
|
36
|
+
encoding: US-ASCII
|
37
|
+
string: ! '{"id":44600324,"name":"Best Lux EUW","profileIconId":7,"summonerLevel":6,"revisionDate":1375116256000,"revisionDateStr":"07/29/2013
|
38
|
+
04:44 PM UTC"}'
|
39
|
+
http_version:
|
40
|
+
recorded_at: Mon, 16 Dec 2013 17:20:06 GMT
|
41
|
+
recorded_with: VCR 2.8.0
|
@@ -0,0 +1,55 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://prod.api.pvp.net/api/lol/euw/v1.1/summoner/by-name/fakemcfakename?api_key=api_key_YYYYYYYYYYYYYYYYYYYYY
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- riot_api rubygem v0.0.4
|
12
|
+
response:
|
13
|
+
status:
|
14
|
+
code: 404
|
15
|
+
message:
|
16
|
+
headers:
|
17
|
+
access-control-allow-headers:
|
18
|
+
- Content-Type
|
19
|
+
access-control-allow-methods:
|
20
|
+
- GET, POST, DELETE, PUT
|
21
|
+
access-control-allow-origin:
|
22
|
+
- ! '*'
|
23
|
+
cache-control:
|
24
|
+
- must-revalidate,no-cache,no-store
|
25
|
+
content-type:
|
26
|
+
- text/html; charset=UTF-8
|
27
|
+
date:
|
28
|
+
- Tue, 17 Dec 2013 01:54:24 GMT
|
29
|
+
server:
|
30
|
+
- Jetty(9.1.0.v20131115)
|
31
|
+
x-newrelic-app-data:
|
32
|
+
- XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
|
33
|
+
content-length:
|
34
|
+
- '1366'
|
35
|
+
connection:
|
36
|
+
- Close
|
37
|
+
body:
|
38
|
+
encoding: US-ASCII
|
39
|
+
string: ! "<html>\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html;
|
40
|
+
charset=ISO-8859-1\"/>\n<title>Error 404 Not Found</title>\n</head>\n<body><h2>HTTP
|
41
|
+
ERROR 404</h2>\n<p>Problem accessing /api/lol/euw/v1.1/summoner/by-name/fakemcfakename.
|
42
|
+
Reason:\n<pre> Not Found</pre></p><br/> \n<br/>
|
43
|
+
\ \n<br/> \n<br/>
|
44
|
+
\ \n<br/> \n<br/>
|
45
|
+
\ \n<br/> \n<br/>
|
46
|
+
\ \n<br/> \n<br/>
|
47
|
+
\ \n<br/> \n<br/>
|
48
|
+
\ \n<br/> \n<br/>
|
49
|
+
\ \n<br/> \n<br/>
|
50
|
+
\ \n<br/> \n<br/>
|
51
|
+
\ \n<br/> \n<br/>
|
52
|
+
\ \n\n</body>\n</html>\n"
|
53
|
+
http_version:
|
54
|
+
recorded_at: Tue, 17 Dec 2013 01:54:37 GMT
|
55
|
+
recorded_with: VCR 2.8.0
|