riot_api 0.0.2 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +11 -0
- data/README.md +33 -1
- data/lib/riot_api/api.rb +36 -4
- data/lib/riot_api/model/base.rb +9 -0
- data/lib/riot_api/model/summoner.rb +13 -0
- data/lib/riot_api/model.rb +8 -0
- data/lib/riot_api/resource/base.rb +4 -3
- data/lib/riot_api/resource/base_v21.rb +9 -0
- data/lib/riot_api/resource/champions.rb +20 -0
- data/lib/riot_api/resource/game.rb +21 -0
- data/lib/riot_api/resource/league.rb +21 -0
- data/lib/riot_api/resource/stats.rb +3 -3
- data/lib/riot_api/resource/summoner.rb +18 -3
- data/lib/riot_api/resource/team.rb +21 -0
- data/lib/riot_api/resource.rb +6 -1
- data/lib/riot_api/version.rb +1 -1
- data/lib/riot_api.rb +1 -0
- data/riot_api.gemspec +1 -0
- data/spec/api_spec.rb +154 -9
- data/spec/model/summoner_spec.rb +14 -0
- data/spec/spec_helper.rb +6 -0
- data/spec/support/vcr.rb +1 -1
- data/spec/vcr/cassettes/RiotApi_API/_champions/_free/should_return_a_list_of_all_free_champions.yml +40 -0
- data/spec/vcr/cassettes/RiotApi_API/_champions/_list/should_return_a_list_of_all_champions.yml +40 -0
- data/spec/vcr/cassettes/RiotApi_API/_game/_recent/should_return_a_list_of_recent_games_played.yml +40 -0
- data/spec/vcr/cassettes/RiotApi_API/_league/_by_summoner/should_return_leagues_data_for_summoner.yml +862 -0
- data/spec/vcr/cassettes/RiotApi_API/_stats/_ranked/omitting_season/should_return_ranked_information_from_the_summoner_id.yml +40 -0
- data/spec/vcr/cassettes/RiotApi_API/_stats/_ranked/specifying_season/should_return_ranked_information_from_the_summoner_id_for_the_specified_season.yml +40 -0
- data/spec/vcr/cassettes/RiotApi_API/_stats/_summary/omitting_season/should_return_summary_information_from_the_summoner_id.yml +40 -0
- data/spec/vcr/cassettes/RiotApi_API/_stats/_summary/specifying_season/should_return_summary_information_from_the_summoner_id_for_the_specified_season.yml +40 -0
- data/spec/vcr/cassettes/RiotApi_API/_summoner/_masteries/should_return_a_list_of_mastery_pages_containing_lists_of_talents.yml +79 -0
- data/spec/vcr/cassettes/RiotApi_API/_summoner/_names/should_return_an_array_of_summoners_with_name_set.yml +40 -0
- data/spec/vcr/cassettes/RiotApi_API/_summoner/_runes/should_return_a_list_of_rune_pages_containing_lists_of_talents.yml +479 -0
- data/spec/vcr/cassettes/RiotApi_API/_team/_by_summoner/should_return_team_data_for_summoner.yml +201 -0
- metadata +89 -11
- checksums.yaml +0 -7
- data/spec/vcr/cassettes/RiotApi_API/_stats/_ranked/should_return_ranked_information_from_the_summoner_name.yml +0 -44
- data/spec/vcr/cassettes/RiotApi_API/_stats/_summary/should_return_summary_information_from_the_summoner_id.yml +0 -44
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
## 0.0.4
|
2
|
+
* Yanked 0.0.3 release as Team method not implemented
|
3
|
+
* Fixed team method
|
4
|
+
* Otherwise same as 0.0.3
|
5
|
+
|
6
|
+
## 0.0.3 (Yanked)
|
7
|
+
* All Endpoints Implemented
|
8
|
+
* Initial Model Approach for Summoner using Virtus
|
9
|
+
* Refactoring of base paths and regions to DRY up resources
|
10
|
+
* Errors for invalid regions parameter
|
11
|
+
|
1
12
|
## 0.0.2
|
2
13
|
* Refactored URL building
|
3
14
|
* Add Stats method
|
data/README.md
CHANGED
@@ -45,6 +45,38 @@ summoner_details = ra.summoner.name('Best Lux EUW')
|
|
45
45
|
summoner.name # => "Best Lux EUW"
|
46
46
|
```
|
47
47
|
|
48
|
+
## Methods
|
49
|
+
|
50
|
+
```
|
51
|
+
RiotApi::API
|
52
|
+
#summoner
|
53
|
+
#name(summoner_name)
|
54
|
+
should return information from a given summoner name
|
55
|
+
#id(summoner_name)
|
56
|
+
should return information from a given summoner id
|
57
|
+
#names(summoner_name_1, summoner_name_2)
|
58
|
+
should return an array of summoners with name set
|
59
|
+
#stats
|
60
|
+
#ranked(summoner_name)
|
61
|
+
should return ranked information from a given summoner name
|
62
|
+
#summary(summoner_name)
|
63
|
+
should return summary information from a given summoner id
|
64
|
+
#champions
|
65
|
+
#list
|
66
|
+
should return a list of all champions
|
67
|
+
#free
|
68
|
+
should return a list of all free champions
|
69
|
+
#game
|
70
|
+
#recent(summoner_name)
|
71
|
+
should return a list of recent games played from a given summoner id
|
72
|
+
#league
|
73
|
+
#by_summoner(summoner_name)
|
74
|
+
should return leagues data from a given summoner id
|
75
|
+
#team
|
76
|
+
#by_summoner(summoner_id)
|
77
|
+
should return team data from a given summoner id
|
78
|
+
```
|
79
|
+
|
48
80
|
## ChangeLog / History / Releases
|
49
81
|
|
50
82
|
see the [CHANGELOG.md](./CHANGELOG.md) file.
|
@@ -77,7 +109,7 @@ rspec
|
|
77
109
|
|
78
110
|
### Contributors
|
79
111
|
|
80
|
-
*
|
112
|
+
* [pcg79](https://github.com/pcg79)
|
81
113
|
|
82
114
|
For more information and a complete list see [the contributor page on GitHub](https://github.com/petems/riot_api/contributors).
|
83
115
|
|
data/lib/riot_api/api.rb
CHANGED
@@ -1,11 +1,26 @@
|
|
1
1
|
module RiotApi
|
2
2
|
class API
|
3
|
+
|
4
|
+
# Creates a new Riot API client instance.
|
5
|
+
#
|
6
|
+
# @param [Hash] params
|
7
|
+
# @option params [String] :api_key The api_key (required)
|
8
|
+
# @option params [String] :api_key The region ('eune','br','tr','na','euw') (required)
|
9
|
+
# @option params [String] :base_url ("http://prod.api.pvp.net/api/lol/#{@region}/") API base url with region
|
10
|
+
# @option params [Symbol] :faraday_adapter ('Faraday.default_adapter') Faraday adapter/http client library to use.
|
11
|
+
# @raise [ArgumentError] when no api_key is provided
|
12
|
+
# @raise [ArgumentError] when no region is provided
|
13
|
+
# @raise [ArgumentError] when region is not one of 'eune','br','tr','na', or 'euw'
|
14
|
+
# @example
|
15
|
+
# ra = RiotApi::API.new :api_key => '######', :region => 'euw'
|
16
|
+
#
|
17
|
+
# @see [Faraday]
|
3
18
|
def initialize(params)
|
4
19
|
@api_key = params[:api_key]
|
5
20
|
@region = params[:region]
|
6
21
|
@debug = params[:debug]
|
7
22
|
@ssl = params[:ssl] || { :verify => true }
|
8
|
-
@base_url = params[:base_url] || "http://prod.api.pvp.net/api/
|
23
|
+
@base_url = params[:base_url] || "http://prod.api.pvp.net/api/"
|
9
24
|
@faraday_adapter = params[:faraday_adapter] || Faraday.default_adapter
|
10
25
|
@raise_status_errors = params[:raise_status_errors] || false
|
11
26
|
@faraday = params[:faraday] || default_faraday
|
@@ -14,12 +29,28 @@ module RiotApi
|
|
14
29
|
raise ArgumentError, "Invalid Region (Valid regions: 'eune','br','tr','na','euw')" unless ['eune','br','tr','na','euw'].include?(@region)
|
15
30
|
end
|
16
31
|
|
17
|
-
def
|
18
|
-
RiotApi::Resource::
|
32
|
+
def champions
|
33
|
+
RiotApi::Resource::Champions.new(@faraday, @region)
|
34
|
+
end
|
35
|
+
|
36
|
+
def game
|
37
|
+
RiotApi::Resource::Game.new(@faraday, @region)
|
38
|
+
end
|
39
|
+
|
40
|
+
def league
|
41
|
+
RiotApi::Resource::League.new(@faraday, @region)
|
19
42
|
end
|
20
43
|
|
21
44
|
def stats
|
22
|
-
RiotApi::Resource::Stats.new(@faraday)
|
45
|
+
RiotApi::Resource::Stats.new(@faraday, @region)
|
46
|
+
end
|
47
|
+
|
48
|
+
def summoner
|
49
|
+
RiotApi::Resource::Summoner.new(@faraday, @region)
|
50
|
+
end
|
51
|
+
|
52
|
+
def team
|
53
|
+
RiotApi::Resource::Team.new(@faraday, @region)
|
23
54
|
end
|
24
55
|
|
25
56
|
def default_faraday
|
@@ -34,5 +65,6 @@ module RiotApi
|
|
34
65
|
faraday.headers['User-Agent'] = "riot_api rubygem v#{RiotApi::VERSION}"
|
35
66
|
end
|
36
67
|
end
|
68
|
+
|
37
69
|
end
|
38
70
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module RiotApi
|
2
|
+
module Model
|
3
|
+
class Summoner < Base
|
4
|
+
attribute :id, Integer
|
5
|
+
attribute :name, String
|
6
|
+
attribute :profile_icon_id, Integer
|
7
|
+
attribute :summoner_level, Integer
|
8
|
+
attribute :revision_date_str, String
|
9
|
+
attribute :revision_date, Integer
|
10
|
+
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -1,12 +1,13 @@
|
|
1
1
|
module RiotApi
|
2
2
|
module Resource
|
3
3
|
class Base
|
4
|
-
def initialize(connection, options = {})
|
4
|
+
def initialize(connection, region, options = {})
|
5
5
|
@connection = connection
|
6
|
+
@region = region
|
6
7
|
end
|
7
8
|
|
8
|
-
def
|
9
|
-
"v1.1"
|
9
|
+
def endpoint_precursor
|
10
|
+
"lol/#{@region}/v1.1"
|
10
11
|
end
|
11
12
|
end
|
12
13
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module RiotApi
|
2
|
+
module Resource
|
3
|
+
class Champions < Base
|
4
|
+
|
5
|
+
def list(free=false)
|
6
|
+
@connection.get(base_path, { :freeToPlay => free }).body.champions
|
7
|
+
end
|
8
|
+
|
9
|
+
def free
|
10
|
+
list(true)
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def base_path
|
16
|
+
"#{endpoint_precursor}/champion"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module RiotApi
|
2
|
+
module Resource
|
3
|
+
class Game < Base
|
4
|
+
|
5
|
+
def recent(summoner_id)
|
6
|
+
@connection.get(recent_path(summoner_id)).body.games
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def recent_path(summoner_id)
|
12
|
+
"#{base_path(summoner_id)}/recent"
|
13
|
+
end
|
14
|
+
|
15
|
+
def base_path(summoner_id)
|
16
|
+
"#{endpoint_precursor}/game/by-summoner/#{summoner_id}"
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module RiotApi
|
2
|
+
module Resource
|
3
|
+
class League < BaseV21
|
4
|
+
|
5
|
+
def by_summoner(summoner_id)
|
6
|
+
@connection.get(by_summoner_path(summoner_id)).body[summoner_id.to_s]
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def by_summoner_path(summoner_id)
|
12
|
+
"#{base_path}/by-summoner/#{summoner_id}"
|
13
|
+
end
|
14
|
+
|
15
|
+
def base_path
|
16
|
+
"#{endpoint_precursor}/league"
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -3,17 +3,17 @@ module RiotApi
|
|
3
3
|
class Stats < Base
|
4
4
|
|
5
5
|
def ranked(id, opts = {})
|
6
|
-
@connection.get("#{base_path(id)}/ranked").body
|
6
|
+
@connection.get("#{base_path(id)}/ranked", opts).body
|
7
7
|
end
|
8
8
|
|
9
9
|
def summary(id, opts = {})
|
10
|
-
@connection.get("#{base_path(id)}/summary").body
|
10
|
+
@connection.get("#{base_path(id)}/summary", opts).body
|
11
11
|
end
|
12
12
|
|
13
13
|
private
|
14
14
|
|
15
15
|
def base_path(id)
|
16
|
-
"#{
|
16
|
+
"#{endpoint_precursor}/stats/by-summoner/#{id}"
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
@@ -3,17 +3,32 @@ module RiotApi
|
|
3
3
|
class Summoner < Base
|
4
4
|
|
5
5
|
def name(name, opts = {})
|
6
|
-
@connection.get("#{base_path}/by-name/#{name}/").body
|
6
|
+
RiotApi::Model::Summoner.new @connection.get("#{base_path}/by-name/#{name}/").body
|
7
7
|
end
|
8
8
|
|
9
9
|
def id(id, opts = {})
|
10
|
-
@connection.get("#{base_path}/#{id}/").body
|
10
|
+
RiotApi::Model::Summoner.new @connection.get("#{base_path}/#{id}/").body
|
11
|
+
end
|
12
|
+
|
13
|
+
def masteries(id)
|
14
|
+
@connection.get("#{base_path}/#{id}/masteries").body
|
15
|
+
end
|
16
|
+
|
17
|
+
def names(*ids)
|
18
|
+
ids = ids.compact.join(',')
|
19
|
+
@connection.get("#{base_path}/#{ids}/name").body.summoners.map do |summoner|
|
20
|
+
RiotApi::Model::Summoner.new summoner
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def runes(id)
|
25
|
+
@connection.get("#{base_path}/#{id}/runes").body
|
11
26
|
end
|
12
27
|
|
13
28
|
private
|
14
29
|
|
15
30
|
def base_path
|
16
|
-
"#{
|
31
|
+
"#{endpoint_precursor}/summoner/"
|
17
32
|
end
|
18
33
|
|
19
34
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module RiotApi
|
2
|
+
module Resource
|
3
|
+
class Team < BaseV21
|
4
|
+
|
5
|
+
def by_summoner(summoner_id)
|
6
|
+
@connection.get(by_summoner_path(summoner_id)).body
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def by_summoner_path(summoner_id)
|
12
|
+
"#{base_path}/by-summoner/#{summoner_id}"
|
13
|
+
end
|
14
|
+
|
15
|
+
def base_path
|
16
|
+
"#{endpoint_precursor}/team"
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/riot_api/resource.rb
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
require 'riot_api/resource/base'
|
2
|
-
require 'riot_api/resource/
|
2
|
+
require 'riot_api/resource/base_v21'
|
3
|
+
require 'riot_api/resource/champions'
|
4
|
+
require 'riot_api/resource/game'
|
5
|
+
require 'riot_api/resource/league'
|
3
6
|
require 'riot_api/resource/stats'
|
7
|
+
require 'riot_api/resource/summoner'
|
8
|
+
require 'riot_api/resource/team'
|
4
9
|
|
5
10
|
module RiotApi
|
6
11
|
module Resource
|
data/lib/riot_api/version.rb
CHANGED
data/lib/riot_api.rb
CHANGED
data/riot_api.gemspec
CHANGED
@@ -26,6 +26,7 @@ Gem::Specification.new do |gem|
|
|
26
26
|
gem.add_dependency 'faraday_middleware', '~> 0.9.0'
|
27
27
|
gem.add_dependency 'json', '~> 1.8.1'
|
28
28
|
gem.add_dependency 'rash', '~> 0.4.0'
|
29
|
+
gem.add_dependency 'virtus', '~> 1.0.1'
|
29
30
|
|
30
31
|
gem.add_development_dependency 'rspec', '~> 2.0'
|
31
32
|
gem.add_development_dependency 'guard', '~> 2.1.0'
|
data/spec/api_spec.rb
CHANGED
@@ -59,6 +59,46 @@ describe RiotApi::API, :vcr do
|
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
62
|
+
describe '#masteries' do
|
63
|
+
let(:summoner_id) { '19531813' }
|
64
|
+
|
65
|
+
let(:response) {
|
66
|
+
subject.summoner.masteries summoner_id
|
67
|
+
}
|
68
|
+
|
69
|
+
it 'should return a list of mastery pages containing lists of talents' do
|
70
|
+
response.pages.count.should be > 0
|
71
|
+
response.pages.first.talents.count.should be > 0
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
describe '#names' do
|
76
|
+
let(:froggen) { '19531813' }
|
77
|
+
let(:response) {
|
78
|
+
subject.summoner.names summoner_id, froggen
|
79
|
+
}
|
80
|
+
|
81
|
+
it "should return an array of summoners with name set" do
|
82
|
+
response.class.should == Array
|
83
|
+
response.count.should == 2
|
84
|
+
response.first.class.should == RiotApi::Model::Summoner
|
85
|
+
response.first.name.should == "Best Lux EUW"
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
describe '#runes' do
|
90
|
+
let(:summoner_id) { '19531813' }
|
91
|
+
|
92
|
+
let(:response) {
|
93
|
+
subject.summoner.runes summoner_id
|
94
|
+
}
|
95
|
+
|
96
|
+
it 'should return a list of rune pages containing lists of talents' do
|
97
|
+
response.pages.count.should be > 0
|
98
|
+
response.pages.first.slots.count.should be > 0
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
62
102
|
end
|
63
103
|
|
64
104
|
describe '#stats' do
|
@@ -66,26 +106,131 @@ describe RiotApi::API, :vcr do
|
|
66
106
|
|
67
107
|
# Ranked command requires user has played ranked
|
68
108
|
describe '#ranked' do
|
109
|
+
|
110
|
+
describe 'omitting season' do
|
111
|
+
let(:response) {
|
112
|
+
subject.stats.ranked summoner_id
|
113
|
+
}
|
114
|
+
|
115
|
+
it 'should return ranked information from the summoner id' do
|
116
|
+
response.summonerId.should eql(19531813)
|
117
|
+
response.champions.first.first.should eql ["id", 111]
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
describe 'specifying season' do
|
122
|
+
let(:response) {
|
123
|
+
subject.stats.ranked summoner_id, :season => "SEASON3"
|
124
|
+
}
|
125
|
+
|
126
|
+
it 'should return ranked information from the summoner id for the specified season' do
|
127
|
+
response.summonerId.should eql(19531813)
|
128
|
+
response.champions.first.first.should eql ["id", 111]
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
describe '#summary' do
|
134
|
+
|
135
|
+
describe 'omitting season' do
|
136
|
+
let(:response) {
|
137
|
+
subject.stats.summary summoner_id
|
138
|
+
}
|
139
|
+
|
140
|
+
it 'should return summary information from the summoner id' do
|
141
|
+
response.summonerId.should eql(19531813)
|
142
|
+
response.playerStatSummaries.first.should include 'aggregated_stats'
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
describe 'specifying season' do
|
147
|
+
let(:response) {
|
148
|
+
subject.stats.summary summoner_id, :season => "SEASON3"
|
149
|
+
}
|
150
|
+
|
151
|
+
it 'should return summary information from the summoner id for the specified season' do
|
152
|
+
response.summonerId.should eql(19531813)
|
153
|
+
response.playerStatSummaries.first.should include 'aggregated_stats'
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
end
|
159
|
+
|
160
|
+
describe '#champions' do
|
161
|
+
let(:current_champion_count) { 116 }
|
162
|
+
|
163
|
+
describe '#list' do
|
69
164
|
let(:response) {
|
70
|
-
subject.
|
165
|
+
subject.champions.list
|
71
166
|
}
|
72
167
|
|
73
|
-
it 'should return
|
74
|
-
response.
|
75
|
-
response.
|
168
|
+
it 'should return a list of all champions' do
|
169
|
+
response.count.should be >= current_champion_count
|
170
|
+
response.first.respond_to?(:name).should be_true
|
76
171
|
end
|
77
172
|
end
|
78
173
|
|
79
|
-
describe '#
|
174
|
+
describe '#free' do
|
80
175
|
let(:response) {
|
81
|
-
subject.
|
176
|
+
subject.champions.free
|
82
177
|
}
|
83
178
|
|
84
|
-
it 'should return
|
85
|
-
response.
|
86
|
-
response.
|
179
|
+
it 'should return a list of all free champions' do
|
180
|
+
response.count.should be < current_champion_count
|
181
|
+
response.count.should be > 0
|
182
|
+
response.first.respond_to?(:name).should be_true
|
183
|
+
response.first.free_to_play.should be_true
|
87
184
|
end
|
88
185
|
end
|
89
186
|
|
90
187
|
end
|
188
|
+
|
189
|
+
describe '#game' do
|
190
|
+
let(:summoner_id) { '19531813' }
|
191
|
+
|
192
|
+
# Ranked command requires user has played ranked
|
193
|
+
describe '#recent' do
|
194
|
+
let(:response) {
|
195
|
+
subject.game.recent summoner_id
|
196
|
+
}
|
197
|
+
|
198
|
+
it 'should return a list of recent games played' do
|
199
|
+
response.count.should > 0
|
200
|
+
response.first.respond_to?(:champion_id).should be_true
|
201
|
+
end
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
describe '#league', :vcr do
|
206
|
+
let(:summoner_id) { '19531813' }
|
207
|
+
|
208
|
+
describe '#by_summoner' do
|
209
|
+
let(:response) {
|
210
|
+
subject.league.by_summoner summoner_id
|
211
|
+
}
|
212
|
+
|
213
|
+
it 'should return leagues data for summoner' do
|
214
|
+
response["entries"].count.should > 0
|
215
|
+
response.tier.should == 'CHALLENGER'
|
216
|
+
end
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
220
|
+
|
221
|
+
describe '#team', :vcr do
|
222
|
+
let(:summoner_id) { '19531813' }
|
223
|
+
|
224
|
+
describe '#by_summoner' do
|
225
|
+
let(:response) {
|
226
|
+
subject.team.by_summoner summoner_id
|
227
|
+
}
|
228
|
+
|
229
|
+
it 'should return team data for summoner' do
|
230
|
+
response.count.should > 0
|
231
|
+
response.first.first.should == ["timestamp", 1387051307170]
|
232
|
+
end
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
91
236
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RiotApi::Model::Summoner do
|
4
|
+
|
5
|
+
describe '#initialize' do
|
6
|
+
let(:data) { { id: 44600324, name: "Best Lux EUW", profile_icon_id: 7, summoner_level: 6, revision_date: 1375116256000, revision_date_str: "07/29/2013 04:44 PM UTC" } }
|
7
|
+
let(:summoner) { RiotApi::Model::Summoner.new data }
|
8
|
+
|
9
|
+
it "should create a valid object" do
|
10
|
+
summoner.id.should == data[:id]
|
11
|
+
summoner.revision_date.should == data[:revision_date]
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
2
|
+
require 'simplecov'
|
2
3
|
require 'coveralls'
|
4
|
+
SimpleCov.formatter = Coveralls::SimpleCov::Formatter
|
5
|
+
SimpleCov.start do
|
6
|
+
add_filter 'support/vcr'
|
7
|
+
end
|
8
|
+
|
3
9
|
Coveralls.wear!
|
4
10
|
|
5
11
|
require 'rspec/autorun'
|
data/spec/support/vcr.rb
CHANGED
@@ -12,7 +12,7 @@ VCR.configure do |c|
|
|
12
12
|
|
13
13
|
c.filter_sensitive_data('XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') do |http_interaction|
|
14
14
|
#Not sure if this needs removing, but better safe than sorry...
|
15
|
-
if http_interaction.response.headers['x-newrelic-app-data']
|
15
|
+
if http_interaction.response.headers['x-newrelic-app-data'] != nil
|
16
16
|
http_interaction.response.headers['x-newrelic-app-data'].first
|
17
17
|
end
|
18
18
|
end
|
data/spec/vcr/cassettes/RiotApi_API/_champions/_free/should_return_a_list_of_all_free_champions.yml
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://prod.api.pvp.net/api/lol/euw/v1.1/champion?api_key=api_key_YYYYYYYYYYYYYYYYYYYYY&freeToPlay=true
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- riot_api rubygem v0.0.1
|
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
|
+
- Wed, 11 Dec 2013 15:44:19 GMT
|
27
|
+
server:
|
28
|
+
- Jetty(9.1.0.v20131115)
|
29
|
+
x-newrelic-app-data:
|
30
|
+
- XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
|
31
|
+
content-length:
|
32
|
+
- '1890'
|
33
|
+
connection:
|
34
|
+
- Close
|
35
|
+
body:
|
36
|
+
encoding: US-ASCII
|
37
|
+
string: ! '{"champions":[{"id":31,"name":"Chogath","active":true,"attackRank":3,"defenseRank":7,"magicRank":7,"difficultyRank":7,"botEnabled":true,"freeToPlay":true,"botMmEnabled":true,"rankedPlayEnabled":true},{"id":104,"name":"Graves","active":true,"attackRank":8,"defenseRank":5,"magicRank":3,"difficultyRank":4,"botEnabled":true,"freeToPlay":true,"botMmEnabled":true,"rankedPlayEnabled":true},{"id":74,"name":"Heimerdinger","active":true,"attackRank":2,"defenseRank":6,"magicRank":8,"difficultyRank":4,"botEnabled":false,"freeToPlay":true,"botMmEnabled":false,"rankedPlayEnabled":true},{"id":39,"name":"Irelia","active":true,"attackRank":7,"defenseRank":4,"magicRank":5,"difficultyRank":5,"botEnabled":false,"freeToPlay":true,"botMmEnabled":true,"rankedPlayEnabled":true},{"id":43,"name":"Karma","active":true,"attackRank":1,"defenseRank":7,"magicRank":8,"difficultyRank":8,"botEnabled":false,"freeToPlay":true,"botMmEnabled":false,"rankedPlayEnabled":true},{"id":117,"name":"Lulu","active":true,"attackRank":4,"defenseRank":5,"magicRank":7,"difficultyRank":7,"botEnabled":false,"freeToPlay":true,"botMmEnabled":false,"rankedPlayEnabled":true},{"id":11,"name":"MasterYi","active":true,"attackRank":10,"defenseRank":4,"magicRank":2,"difficultyRank":2,"botEnabled":true,"freeToPlay":true,"botMmEnabled":true,"rankedPlayEnabled":true},{"id":133,"name":"Quinn","active":true,"attackRank":9,"defenseRank":4,"magicRank":2,"difficultyRank":7,"botEnabled":false,"freeToPlay":true,"botMmEnabled":false,"rankedPlayEnabled":true},{"id":35,"name":"Shaco","active":true,"attackRank":8,"defenseRank":4,"magicRank":6,"difficultyRank":9,"botEnabled":false,"freeToPlay":true,"botMmEnabled":false,"rankedPlayEnabled":true},{"id":4,"name":"TwistedFate","active":true,"attackRank":6,"defenseRank":2,"magicRank":6,"difficultyRank":9,"botEnabled":false,"freeToPlay":true,"botMmEnabled":false,"rankedPlayEnabled":true}]}'
|
38
|
+
http_version:
|
39
|
+
recorded_at: Wed, 11 Dec 2013 15:44:19 GMT
|
40
|
+
recorded_with: VCR 2.8.0
|