ruby-lol 0.12.2 → 1.0.0
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.
- checksums.yaml +4 -4
- data/.editorconfig +16 -0
- data/.gitignore +2 -0
- data/.rspec +1 -0
- data/.rubocop.yml +1157 -0
- data/.travis.yml +1 -1
- data/lib/lol/champion_mastery_request.rb +29 -57
- data/lib/lol/champion_request.rb +19 -23
- data/lib/lol/client.rb +16 -21
- data/lib/lol/dynamic_model.rb +14 -5
- data/lib/lol/featured_game_list.rb +15 -0
- data/lib/lol/league_request.rb +28 -49
- data/lib/lol/lol_status_request.rb +9 -26
- data/lib/lol/masteries_request.rb +14 -0
- data/lib/lol/match_request.rb +51 -9
- data/lib/lol/request.rb +55 -21
- data/lib/lol/runes_request.rb +14 -0
- data/lib/lol/spectator_request.rb +24 -0
- data/lib/lol/static_request.rb +34 -23
- data/lib/lol/summoner_request.rb +22 -51
- data/lib/lol/tournament_request.rb +95 -0
- data/lib/lol/version.rb +1 -1
- data/ruby-lol.gemspec +1 -1
- data/spec/api_version_spec.rb +10 -9
- data/spec/fixtures/{v1.2 → v3}/get-champion-266.json +0 -0
- data/spec/fixtures/{v1.2/get-champion.json → v3/get-champion-all.json} +0 -0
- data/spec/fixtures/{v1.0/get-champion-mastery-champions.json → v3/get-champion-masteries.json} +0 -0
- data/spec/fixtures/{v1.0/get-champion-mastery-champion.json → v3/get-champion-mastery.json} +0 -0
- data/spec/fixtures/v3/get-current-game.json +1 -0
- data/spec/fixtures/v3/get-featured-games.json +1 -0
- data/spec/fixtures/v3/get-ids-by-tc.json +1 -0
- data/spec/fixtures/v3/get-league-challenger.json +1 -0
- data/spec/fixtures/v3/get-league-master.json +1 -0
- data/spec/fixtures/v3/get-league-positions.json +1 -0
- data/spec/fixtures/v3/get-league-summoner.json +1 -0
- data/spec/fixtures/v3/get-lol-status-shard.json +1 -0
- data/spec/fixtures/v3/get-masteries.json +1 -0
- data/spec/fixtures/v3/get-match-with-tc.json +1 -0
- data/spec/fixtures/v3/get-match.json +1 -0
- data/spec/fixtures/v3/get-matches-recent.json +1 -0
- data/spec/fixtures/v3/get-matches.json +1 -0
- data/spec/fixtures/v3/get-runes.json +1 -0
- data/spec/fixtures/v3/get-static-champions-by-id.json +1 -0
- data/spec/fixtures/v3/get-static-champions.json +1 -0
- data/spec/fixtures/v3/get-static-items-by-id.json +1 -0
- data/spec/fixtures/v3/get-static-items.json +1 -0
- data/spec/fixtures/v3/get-static-maps.json +1 -0
- data/spec/fixtures/v3/get-static-masteries-by-id.json +1 -0
- data/spec/fixtures/v3/get-static-masteries.json +1 -0
- data/spec/fixtures/v3/get-static-realms.json +1 -0
- data/spec/fixtures/v3/get-static-runes-by-id.json +1 -0
- data/spec/fixtures/v3/get-static-runes.json +1 -0
- data/spec/fixtures/v3/get-static-summoner-spells-by-id.json +1 -0
- data/spec/fixtures/v3/get-static-summoner-spells.json +1 -0
- data/spec/fixtures/v3/get-static-versions.json +1 -0
- data/spec/fixtures/v3/get-summoner-by-name.json +1 -0
- data/spec/fixtures/v3/get-summoner.json +1 -0
- data/spec/fixtures/v3/get-timeline.json +1 -0
- data/spec/fixtures/v3/get-tournament-code.json +1 -0
- data/spec/lol/champion_mastery_request_spec.rb +33 -133
- data/spec/lol/champion_request_spec.rb +17 -30
- data/spec/lol/client_spec.rb +12 -56
- data/spec/lol/league_request_spec.rb +29 -72
- data/spec/lol/lol_status_request_spec.rb +6 -34
- data/spec/lol/masteries_request_spec.rb +15 -0
- data/spec/lol/match_request_spec.rb +45 -10
- data/spec/lol/request_spec.rb +5 -5
- data/spec/lol/runes_request_spec.rb +15 -0
- data/spec/lol/spectator_request_spec.rb +23 -0
- data/spec/lol/static_request_spec.rb +44 -48
- data/spec/lol/summoner_request_spec.rb +20 -71
- data/spec/lol/tournament_request_spec.rb +36 -0
- metadata +92 -175
- data/lib/lol/champion.rb +0 -37
- data/lib/lol/champion_mastery.rb +0 -50
- data/lib/lol/champion_statistics_summary.rb +0 -25
- data/lib/lol/current_game_request.rb +0 -16
- data/lib/lol/featured_games_request.rb +0 -15
- data/lib/lol/game.rb +0 -85
- data/lib/lol/game_request.rb +0 -19
- data/lib/lol/league.rb +0 -32
- data/lib/lol/league_entry.rb +0 -74
- data/lib/lol/mastery.rb +0 -16
- data/lib/lol/mastery_page.rb +0 -28
- data/lib/lol/match_list_request.rb +0 -15
- data/lib/lol/match_summary.rb +0 -59
- data/lib/lol/mini_series.rb +0 -29
- data/lib/lol/model.rb +0 -28
- data/lib/lol/player.rb +0 -21
- data/lib/lol/player_statistic.rb +0 -46
- data/lib/lol/ranked_statistics_summary.rb +0 -35
- data/lib/lol/roster.rb +0 -23
- data/lib/lol/rune_page.rb +0 -28
- data/lib/lol/rune_slot.rb +0 -29
- data/lib/lol/stats_request.rb +0 -35
- data/lib/lol/summoner.rb +0 -36
- data/lib/lol/team.rb +0 -110
- data/lib/lol/team_member.rb +0 -33
- data/lib/lol/team_request.rb +0 -32
- data/lib/lol/team_statistic.rb +0 -53
- data/lib/lol/tournament_code.rb +0 -58
- data/lib/lol/tournament_provider_request.rb +0 -111
- data/spec/fixtures/v1.0/get-champion-mastery-top-champions-10.json +0 -121
- data/spec/fixtures/v1.0/get-champion-mastery-top-champions.json +0 -38
- data/spec/fixtures/v1.0/get-current-game.json +0 -1065
- data/spec/fixtures/v1.0/get-featured-games.json +0 -730
- data/spec/fixtures/v1.0/get-lol-status-shard-by-region.json +0 -39
- data/spec/fixtures/v1.0/get-lol-status-shards.json +0 -78
- data/spec/fixtures/v1.2/get-champion-by-id.json +0 -6
- data/spec/fixtures/v1.2/get-item-by-id.json +0 -6
- data/spec/fixtures/v1.2/get-item.json +0 -1563
- data/spec/fixtures/v1.2/get-mastery-by-id.json +0 -9
- data/spec/fixtures/v1.2/get-mastery.json +0 -389
- data/spec/fixtures/v1.2/get-realm.json +0 -1
- data/spec/fixtures/v1.2/get-rune-by-id.json +0 -26
- data/spec/fixtures/v1.2/get-rune.json +0 -2966
- data/spec/fixtures/v1.2/get-static-champion.json +0 -714
- data/spec/fixtures/v1.2/get-summoner-spell-by-id.json +0 -39
- data/spec/fixtures/v1.2/get-summoner-spell.json +0 -97
- data/spec/fixtures/v1.2/get-versions.json +0 -1
- data/spec/fixtures/v1.3/get-game.json +0 -1040
- data/spec/fixtures/v1.3/get-ranked_stats.json +0 -1
- data/spec/fixtures/v1.3/get-stats.json +0 -1
- data/spec/fixtures/v1.4/get-summoner-by-name.json +0 -1
- data/spec/fixtures/v1.4/get-summoner-masteries.json +0 -898
- data/spec/fixtures/v1.4/get-summoner-name.json +0 -1
- data/spec/fixtures/v1.4/get-summoner-runes.json +0 -2547
- data/spec/fixtures/v1.4/get-summoner.json +0 -1
- data/spec/fixtures/v2.2/get-match.json +0 -1
- data/spec/fixtures/v2.2/get-match_list.json +0 -1
- data/spec/fixtures/v2.4/get-by-summoner.json +0 -1
- data/spec/fixtures/v2.4/get-team.json +0 -1
- data/spec/fixtures/v2.5/get-league-by-team.json +0 -1
- data/spec/fixtures/v2.5/get-league-challenger.json +0 -1
- data/spec/fixtures/v2.5/get-league-entry-by-team.json +0 -1
- data/spec/fixtures/v2.5/get-league-entry.json +0 -1
- data/spec/fixtures/v2.5/get-league-master.json +0 -1
- data/spec/fixtures/v2.5/get-league.json +0 -1
- data/spec/lol/champion_mastery_spec.rb +0 -20
- data/spec/lol/champion_spec.rb +0 -19
- data/spec/lol/champion_statistics_summary_spec.rb +0 -38
- data/spec/lol/current_game_request_spec.rb +0 -47
- data/spec/lol/featured_games_request_spec.rb +0 -39
- data/spec/lol/game_request_spec.rb +0 -32
- data/spec/lol/game_spec.rb +0 -51
- data/spec/lol/league_entry_spec.rb +0 -51
- data/spec/lol/league_spec.rb +0 -31
- data/spec/lol/mastery_page_spec.rb +0 -29
- data/spec/lol/mastery_spec.rb +0 -17
- data/spec/lol/match_list_request_spec.rb +0 -39
- data/spec/lol/match_summary_spec.rb +0 -25
- data/spec/lol/mini_series_spec.rb +0 -25
- data/spec/lol/model_spec.rb +0 -13
- data/spec/lol/player_spec.rb +0 -19
- data/spec/lol/player_statistic_spec.rb +0 -44
- data/spec/lol/ranked_statistics_summary_spec.rb +0 -32
- data/spec/lol/roster_spec.rb +0 -24
- data/spec/lol/rune_page_spec.rb +0 -28
- data/spec/lol/rune_slot_spec.rb +0 -16
- data/spec/lol/stats_request_spec.rb +0 -93
- data/spec/lol/summoner_spec.rb +0 -20
- data/spec/lol/team_member_spec.rb +0 -27
- data/spec/lol/team_request_spec.rb +0 -47
- data/spec/lol/team_spec.rb +0 -54
- data/spec/lol/team_statistic_spec.rb +0 -20
- data/spec/lol/tournament_code_spec.rb +0 -20
- data/spec/lol/tournament_provider_request_spec.rb +0 -73
|
@@ -4,94 +4,51 @@ require "lol"
|
|
|
4
4
|
include Lol
|
|
5
5
|
|
|
6
6
|
describe LeagueRequest do
|
|
7
|
-
|
|
8
|
-
expect(LeagueRequest.ancestors[1]).to eq(Request)
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
let(:request) { LeagueRequest.new("api_key", "euw") }
|
|
12
|
-
|
|
13
|
-
describe "#get" do
|
|
14
|
-
subject { request.get(123) }
|
|
15
|
-
|
|
16
|
-
let(:fixture) { load_fixture('league', request.class.api_version) }
|
|
17
|
-
|
|
18
|
-
before(:each) { stub_request(request, 'league', 'league/by-summoner/123') }
|
|
19
|
-
|
|
20
|
-
it "returns a hash of arrays of Leagues" do
|
|
21
|
-
expect(subject.map {|_,v| v.map(&:class).uniq}.flatten).to eq([League])
|
|
22
|
-
end
|
|
7
|
+
subject { LeagueRequest.new 'api_key', 'euw' }
|
|
23
8
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
end
|
|
9
|
+
it 'inherits from V3 Request' do
|
|
10
|
+
expect(LeagueRequest).to be < Request
|
|
27
11
|
end
|
|
28
12
|
|
|
29
|
-
describe
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
before(:each) { stub_request(request, 'league-entry', 'league/by-summoner/123/entry') }
|
|
35
|
-
|
|
36
|
-
it 'returns a hash of arrays of Leagues' do
|
|
37
|
-
expect(subject.map {|_,v| v.map(&:class).uniq}.flatten).to eq([League])
|
|
13
|
+
describe '#find_challenger' do
|
|
14
|
+
it 'returns a DynamicModel' do
|
|
15
|
+
stub_request subject, 'league-challenger', 'challengerleagues/by-queue/RANKED_SOLO_5x5'
|
|
16
|
+
expect(subject.find_challenger).to be_a DynamicModel
|
|
38
17
|
end
|
|
39
18
|
|
|
40
|
-
it '
|
|
41
|
-
|
|
19
|
+
it 'finds the challenger league for the given queue' do
|
|
20
|
+
stub_request subject, 'league-challenger', 'challengerleagues/by-queue/foo'
|
|
21
|
+
subject.find_challenger queue: 'foo'
|
|
42
22
|
end
|
|
43
23
|
end
|
|
44
24
|
|
|
45
|
-
describe '#
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
before(:each) { stub_request(request, 'league-by-team', 'league/by-team/TEAM-7d7013d0-b38b-11e3-9e38-782bcb497d6f') }
|
|
51
|
-
|
|
52
|
-
it 'returns a hash of arrays of Leagues' do
|
|
53
|
-
expect(subject.map {|_,v| v.map(&:class).uniq}.flatten).to eq([League])
|
|
25
|
+
describe '#find_master' do
|
|
26
|
+
it 'returns a LeagueList' do
|
|
27
|
+
stub_request subject, 'league-master', 'masterleagues/by-queue/RANKED_SOLO_5x5'
|
|
28
|
+
expect(subject.find_master).to be_a DynamicModel
|
|
54
29
|
end
|
|
55
30
|
|
|
56
|
-
it '
|
|
57
|
-
|
|
31
|
+
it 'finds the master league for the given queue' do
|
|
32
|
+
stub_request subject, 'league-master', 'masterleagues/by-queue/foo'
|
|
33
|
+
subject.find_master queue: 'foo'
|
|
58
34
|
end
|
|
59
35
|
end
|
|
60
36
|
|
|
61
|
-
describe '#
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
it 'returns a hash of arrays of Leagues' do
|
|
69
|
-
expect(subject.map {|_,v| v.map(&:class).uniq}.flatten).to eq([League])
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
it 'has hash keys with string team id' do
|
|
73
|
-
expect(subject.keys).to eq(fixture.keys)
|
|
37
|
+
describe '#summoner_leagues' do
|
|
38
|
+
it 'returns an array of LeagueList objects' do
|
|
39
|
+
stub_request subject, 'league-summoner', 'leagues/by-summoner/1'
|
|
40
|
+
result = subject.summoner_leagues summoner_id: 1
|
|
41
|
+
expect(result).to be_a Array
|
|
42
|
+
expect(result.map(&:class).uniq).to eq [DynamicModel]
|
|
74
43
|
end
|
|
75
44
|
end
|
|
76
45
|
|
|
77
|
-
describe '#
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
expect(subject.class).to eq(League)
|
|
46
|
+
describe '#summoner_positions' do
|
|
47
|
+
it 'returns an array of DynamicModel objects' do
|
|
48
|
+
stub_request subject, 'league-positions', 'positions/by-summoner/1'
|
|
49
|
+
result = subject.summoner_positions summoner_id: 1
|
|
50
|
+
expect(result).to be_a Array
|
|
51
|
+
expect(result.map(&:class).uniq).to eq [DynamicModel]
|
|
84
52
|
end
|
|
85
53
|
end
|
|
86
|
-
|
|
87
|
-
describe '#master' do
|
|
88
|
-
subject { request.master('RANKED_SOLO_5x5')}
|
|
89
|
-
|
|
90
|
-
before(:each) { stub_request(request, 'league-master', 'league/master', { :type => 'RANKED_SOLO_5x5'})}
|
|
91
|
-
|
|
92
|
-
it 'returns League' do
|
|
93
|
-
expect(subject.class).to eq(League)
|
|
94
|
-
end
|
|
95
|
-
end
|
|
96
|
-
|
|
97
54
|
end
|
|
@@ -4,44 +4,16 @@ require "lol"
|
|
|
4
4
|
include Lol
|
|
5
5
|
|
|
6
6
|
describe LolStatusRequest do
|
|
7
|
-
|
|
8
|
-
expect(LolStatusRequest.ancestors[1]).to eq(Request)
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
describe '#api_url' do
|
|
12
|
-
it 'returns full url for' do
|
|
13
|
-
expect(subject.api_url('shards')).to eq 'http://status.leagueoflegends.com/shards'
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
it 'returns full url with path' do
|
|
17
|
-
expect(subject.api_url('shards', 'something')).to eq 'http://status.leagueoflegends.com/shards/something'
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
describe "#shards" do
|
|
22
|
-
let(:response) { subject.shards }
|
|
7
|
+
subject { LolStatusRequest.new "api_key", "euw" }
|
|
23
8
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
it 'returns an array' do
|
|
27
|
-
expect(response).to be_a(Array)
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
it 'returns an array of Shard' do
|
|
31
|
-
expect(response.map(&:class).uniq).to eq([DynamicModel])
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
it 'fetches shards from the API' do
|
|
35
|
-
fixture = load_fixture('lol-status-shards', LolStatusRequest.api_version)
|
|
36
|
-
expect(response.size).to eq(fixture.size)
|
|
37
|
-
end
|
|
9
|
+
it 'inherits from Request' do
|
|
10
|
+
expect(LolStatusRequest).to be < Request
|
|
38
11
|
end
|
|
39
12
|
|
|
40
|
-
describe '#
|
|
41
|
-
|
|
42
|
-
let(:response) { subject.current_shard }
|
|
13
|
+
describe '#shard_data' do
|
|
14
|
+
let(:response) { subject.shard_data }
|
|
43
15
|
|
|
44
|
-
before(:each) { stub_request(subject, 'lol-status-shard
|
|
16
|
+
before(:each) { stub_request(subject, 'lol-status-shard', 'shard-data') }
|
|
45
17
|
|
|
46
18
|
it 'returns a Shard' do
|
|
47
19
|
expect(response).to be_a(DynamicModel)
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
require "lol"
|
|
3
|
+
|
|
4
|
+
describe Lol::MasteriesRequest do
|
|
5
|
+
subject { Lol::MasteriesRequest.new "api_key", "euw" }
|
|
6
|
+
|
|
7
|
+
describe "#by_summoner_id" do
|
|
8
|
+
it "returns an Array of DynamicModel" do
|
|
9
|
+
stub_request subject, "masteries", "masteries/by-summoner/1"
|
|
10
|
+
result = subject.by_summoner_id 1
|
|
11
|
+
expect(result).to be_a Array
|
|
12
|
+
expect(result.map(&:class).uniq).to eq [Lol::DynamicModel]
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -4,24 +4,59 @@ require "lol"
|
|
|
4
4
|
include Lol
|
|
5
5
|
|
|
6
6
|
describe MatchRequest do
|
|
7
|
+
subject { MatchRequest.new "api_key", "euw" }
|
|
8
|
+
|
|
7
9
|
it "inherits from Request" do
|
|
8
|
-
expect(MatchRequest
|
|
10
|
+
expect(MatchRequest).to be < Request
|
|
9
11
|
end
|
|
10
12
|
|
|
11
|
-
|
|
13
|
+
describe "#find" do
|
|
14
|
+
context "without a tournament code" do
|
|
15
|
+
let(:result) { subject.find 1 }
|
|
16
|
+
before { stub_request subject, 'match', "matches/1" }
|
|
17
|
+
|
|
18
|
+
it "returns a DynamicModel" do
|
|
19
|
+
expect(result).to be_a DynamicModel
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
context "with a tournament code" do
|
|
24
|
+
let(:result) { subject.find 1, tournament_code: 2 }
|
|
25
|
+
before { stub_request subject, 'match-with-tc', "matches/1/by-tournament-code/2" }
|
|
26
|
+
|
|
27
|
+
it "returns a DynamicModel" do
|
|
28
|
+
expect(result).to be_a DynamicModel
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
12
32
|
|
|
13
|
-
describe "#
|
|
14
|
-
|
|
33
|
+
describe "#find_timeline" do
|
|
34
|
+
it "returns a DynamicModel" do
|
|
35
|
+
stub_request subject, 'timeline', "timelines/by-match/1"
|
|
36
|
+
expect(subject.find_timeline 1).to be_a DynamicModel
|
|
37
|
+
end
|
|
38
|
+
end
|
|
15
39
|
|
|
16
|
-
|
|
40
|
+
describe "#ids_by_tournament_code" do
|
|
41
|
+
it "returns a list of ids" do
|
|
42
|
+
stub_request subject, 'ids-by-tc', "matches/by-tournament-code/1/ids"
|
|
43
|
+
result = subject.ids_by_tournament_code '1'
|
|
44
|
+
expect(result).to be_a Array
|
|
45
|
+
expect(result.map(&:class).uniq).to eq [Integer]
|
|
46
|
+
end
|
|
47
|
+
end
|
|
17
48
|
|
|
18
|
-
|
|
19
|
-
|
|
49
|
+
describe "#all" do
|
|
50
|
+
it "returns a DynamicModel" do
|
|
51
|
+
stub_request subject, 'matches', "matchlists/by-account/1"
|
|
52
|
+
expect(subject.all account_id: 1).to be_a DynamicModel
|
|
20
53
|
end
|
|
54
|
+
end
|
|
21
55
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
56
|
+
describe "#recent" do
|
|
57
|
+
it "returns a DynamicModel" do
|
|
58
|
+
stub_request subject, 'matches-recent', "matchlists/by-account/1/recent"
|
|
59
|
+
expect(subject.recent account_id: 1).to be_a DynamicModel
|
|
25
60
|
end
|
|
26
61
|
end
|
|
27
62
|
end
|
data/spec/lol/request_spec.rb
CHANGED
|
@@ -162,11 +162,11 @@ describe Request do
|
|
|
162
162
|
|
|
163
163
|
describe "api_url" do
|
|
164
164
|
it "defaults on Request#region" do
|
|
165
|
-
expect(subject.api_url("bar")).to match(/\/
|
|
165
|
+
expect(subject.api_url("bar")).to match(/\/euw1\./)
|
|
166
166
|
end
|
|
167
167
|
|
|
168
168
|
it "defaults on Reques.api_version" do
|
|
169
|
-
expect(subject.api_url("bar")).to match(/\/
|
|
169
|
+
expect(subject.api_url("bar")).to match(/\/v3\//)
|
|
170
170
|
end
|
|
171
171
|
|
|
172
172
|
it "a path" do
|
|
@@ -174,11 +174,11 @@ describe Request do
|
|
|
174
174
|
end
|
|
175
175
|
|
|
176
176
|
it "returns a full fledged api url" do
|
|
177
|
-
expect(subject.api_url("bar")).to eq("https://
|
|
177
|
+
expect(subject.api_url("bar")).to eq("https://euw1.api.riotgames.com/lol/platform/v3/bar?api_key=api_key")
|
|
178
178
|
end
|
|
179
179
|
|
|
180
180
|
it "optionally accept query string parameters" do
|
|
181
|
-
expect(subject.api_url("foo", a: 'b')).to eq("https://
|
|
181
|
+
expect(subject.api_url("foo", a: 'b')).to eq("https://euw1.api.riotgames.com/lol/platform/v3/foo?a=b&api_key=api_key")
|
|
182
182
|
end
|
|
183
183
|
|
|
184
184
|
it "delegates the base url to #api_base_url" do
|
|
@@ -194,7 +194,7 @@ describe Request do
|
|
|
194
194
|
|
|
195
195
|
describe "#api_base_url" do
|
|
196
196
|
it "returns the base domain" do
|
|
197
|
-
expect(subject.api_base_url).to eq "https://
|
|
197
|
+
expect(subject.api_base_url).to eq "https://euw1.api.riotgames.com"
|
|
198
198
|
end
|
|
199
199
|
end
|
|
200
200
|
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
require "lol"
|
|
3
|
+
|
|
4
|
+
describe Lol::RunesRequest do
|
|
5
|
+
subject { Lol::RunesRequest.new "api_key", "euw" }
|
|
6
|
+
|
|
7
|
+
describe "#by_summoner_id" do
|
|
8
|
+
it "returns an Array of DynamicModel" do
|
|
9
|
+
stub_request subject, "runes", "runes/by-summoner/1"
|
|
10
|
+
result = subject.by_summoner_id 1
|
|
11
|
+
expect(result).to be_a Array
|
|
12
|
+
expect(result.map(&:class).uniq).to eq [Lol::DynamicModel]
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
require "lol"
|
|
3
|
+
|
|
4
|
+
describe Lol::SpectatorRequest do
|
|
5
|
+
subject { described_class.new "api_key", "euw" }
|
|
6
|
+
|
|
7
|
+
describe "#current_game" do
|
|
8
|
+
it "returns a DynamicModel" do
|
|
9
|
+
stub_request subject, "current-game", "active-games/by-summoner/23"
|
|
10
|
+
expect(subject.current_game summoner_id: 23).to be_a Lol::DynamicModel
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
describe "#featured_games" do
|
|
15
|
+
it "returns a FeaturedGameList" do
|
|
16
|
+
stub_request subject, "featured-games", "featured-games"
|
|
17
|
+
result = subject.featured_games
|
|
18
|
+
expect(result).to be_a Lol::FeaturedGameList
|
|
19
|
+
expect(result.client_refresh_interval).not_to be_nil
|
|
20
|
+
expect(result.size).not_to be_zero
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -4,87 +4,83 @@ require "lol"
|
|
|
4
4
|
include Lol
|
|
5
5
|
|
|
6
6
|
describe StaticRequest do
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
expect(request.api_url("foo")).to eq("https://global.api.pvp.net/api/lol/static-data/euw/v1.2/foo?api_key=api_key")
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
StaticRequest::STANDARD_ENDPOINTS.each do |endpoint|
|
|
22
|
-
describe "##{endpoint}" do
|
|
7
|
+
let(:subject) { StaticRequest.new("api_key", "euw") }
|
|
8
|
+
|
|
9
|
+
{
|
|
10
|
+
"champion" => "champions",
|
|
11
|
+
"item" => "items",
|
|
12
|
+
"mastery" => "masteries",
|
|
13
|
+
"rune" => "runes",
|
|
14
|
+
"summoner_spell" => "summoner_spells"
|
|
15
|
+
}.each do |old_edpoint, new_endpoint|
|
|
16
|
+
describe "##{new_endpoint}" do
|
|
23
17
|
it "returns a Proxy" do
|
|
24
|
-
expect(
|
|
18
|
+
expect(subject.send(new_endpoint).class).to eq(StaticRequest::Proxy)
|
|
25
19
|
end
|
|
26
20
|
|
|
27
21
|
describe "#get" do
|
|
28
|
-
|
|
29
|
-
expect(request).to receive(:get).with(endpoint, anything, anything)
|
|
22
|
+
let(:fixture_name) { "static-#{new_endpoint.dasherize}" }
|
|
30
23
|
|
|
31
|
-
|
|
24
|
+
it "proxies get to StaticRequest with the correct endpoint" do
|
|
25
|
+
expect(subject).to receive(:get).with(new_endpoint, anything, anything)
|
|
26
|
+
subject.send(new_endpoint).get
|
|
32
27
|
end
|
|
33
28
|
|
|
34
|
-
context "
|
|
35
|
-
|
|
36
|
-
let(:fixture_name) { endpoint == 'champion' ? 'static-champion' : endpoint.dasherize }
|
|
29
|
+
context "without an id" do
|
|
37
30
|
let(:fixture) { load_fixture(fixture_name, StaticRequest.api_version) }
|
|
38
31
|
|
|
39
|
-
|
|
32
|
+
let(:result) { subject.public_send(new_endpoint).get }
|
|
40
33
|
|
|
41
|
-
before
|
|
34
|
+
before { stub_request(subject, fixture_name, "#{new_endpoint.dasherize}") }
|
|
42
35
|
|
|
43
|
-
it "returns an Array" do
|
|
44
|
-
expect(
|
|
36
|
+
it "returns an Array of OpenStruct" do
|
|
37
|
+
expect(result).to be_a Array
|
|
38
|
+
expect(result.map(&:class).uniq).to eq([OpenStruct])
|
|
45
39
|
end
|
|
46
40
|
|
|
47
|
-
it "
|
|
48
|
-
expect(
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
it "fetches #{endpoint} from the API" do
|
|
52
|
-
expect(subject.size).to eq(fixture["data"].size)
|
|
41
|
+
it "fetches #{new_endpoint} from the API" do
|
|
42
|
+
expect(result.size).to eq(fixture["data"].size)
|
|
53
43
|
end
|
|
54
44
|
end
|
|
55
45
|
|
|
56
|
-
context "
|
|
57
|
-
let(:id) { 1 }
|
|
58
|
-
|
|
59
|
-
before(:each) { stub_request(request, "#{endpoint.dasherize}-by-id", "#{endpoint.dasherize}/#{id}") }
|
|
60
|
-
|
|
61
|
-
subject { request.public_send(endpoint).get(id) }
|
|
62
|
-
|
|
46
|
+
context "with an id" do
|
|
63
47
|
it "returns an OpenStruct" do
|
|
64
|
-
|
|
48
|
+
stub_request(subject, "#{fixture_name}-by-id", "#{new_endpoint.dasherize}/1")
|
|
49
|
+
expect(subject.public_send(new_endpoint).get 1).to be_a OpenStruct
|
|
65
50
|
end
|
|
66
51
|
end
|
|
67
52
|
end
|
|
68
53
|
end
|
|
69
54
|
end
|
|
70
55
|
|
|
71
|
-
describe "#
|
|
72
|
-
|
|
56
|
+
describe "#maps" do
|
|
57
|
+
let(:result) { subject.maps.get }
|
|
58
|
+
|
|
59
|
+
before(:each) { stub_request(subject, 'static-maps', 'maps') }
|
|
60
|
+
|
|
61
|
+
it "returns an Array of OpenStructs" do
|
|
62
|
+
expect(result).to be_a Array
|
|
63
|
+
expect(result.map(&:class).uniq).to eq [OpenStruct]
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
describe "#realms" do
|
|
68
|
+
let(:result) { subject.realms.get }
|
|
73
69
|
|
|
74
|
-
before(:each) { stub_request(
|
|
70
|
+
before(:each) { stub_request(subject, 'static-realms', 'realms') }
|
|
75
71
|
|
|
76
72
|
it "returns an OpenStruct" do
|
|
77
|
-
expect(
|
|
73
|
+
expect(result).to be_a OpenStruct
|
|
78
74
|
end
|
|
79
75
|
end
|
|
80
76
|
|
|
81
77
|
describe "#versions" do
|
|
82
|
-
|
|
78
|
+
let(:result) { subject.versions.get }
|
|
83
79
|
|
|
84
|
-
before(:each) { stub_request(
|
|
80
|
+
before(:each) { stub_request(subject, 'static-versions', 'versions') }
|
|
85
81
|
|
|
86
82
|
it "returns an Array" do
|
|
87
|
-
expect(
|
|
83
|
+
expect(result).to be_an(Array)
|
|
88
84
|
end
|
|
89
85
|
end
|
|
90
86
|
|