ruby-lol 0.9.9 → 0.9.10

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.
@@ -1 +1,16 @@
1
- {"30743211":{"id":30743211,"name":"intinig","profileIconId":599,"summonerLevel":30,"revisionDate":1390360425000},"33249714":{"id":33249714,"name":"intinir","profileIconId":26,"summonerLevel":30,"revisionDate":1390538264000}}
1
+ {
2
+ "30743211": {
3
+ "id": 30743211,
4
+ "name": "intinig",
5
+ "profileIconId": 599,
6
+ "summonerLevel": 30,
7
+ "revisionDate": 1390360425000
8
+ },
9
+ "33249714": {
10
+ "id": 33249714,
11
+ "name": "intinir",
12
+ "profileIconId": 26,
13
+ "summonerLevel": 30,
14
+ "revisionDate": 1390538264000
15
+ }
16
+ }
@@ -93,6 +93,18 @@ describe Client do
93
93
  end
94
94
  end
95
95
 
96
+ describe "#static" do
97
+ it "returns an instance of StaticRequest" do
98
+ expect(subject.static).to be_a(StaticRequest)
99
+ end
100
+
101
+ it "initializes the StaticRequest with the current API key and region" do
102
+ expect(StaticRequest).to receive(:new).with(subject.api_key, subject.region)
103
+
104
+ subject.static
105
+ end
106
+ end
107
+
96
108
  describe "#api_key" do
97
109
  it "returns an api key" do
98
110
  expect(subject.api_key).to eq("foo")
@@ -59,15 +59,6 @@ describe Request do
59
59
  expect(subject.api_url("bar")).to eq("http://prod.api.pvp.net/api/lol/euw/v1.1/bar?api_key=api_key")
60
60
  end
61
61
 
62
- it "has lol if url is different from v2.1" do
63
- expect(subject.api_url("foo")).to eq("http://prod.api.pvp.net/api/lol/euw/v1.1/foo?api_key=api_key")
64
- end
65
-
66
- it "does not have lol only url is v2.1" do
67
- expect(Request).to receive(:api_version).at_least(:once).and_return("v2.1")
68
- expect(subject.api_url("foo")).to eq("http://prod.api.pvp.net/api/euw/v2.1/foo?api_key=api_key")
69
- end
70
-
71
62
  it "optionally accept query string parameters" do
72
63
  expect(subject.api_url("foo", a: 'b')).to eq("http://prod.api.pvp.net/api/lol/euw/v1.1/foo?a=b&api_key=api_key")
73
64
  end
@@ -0,0 +1,93 @@
1
+ require "spec_helper"
2
+ require "lol"
3
+
4
+ include Lol
5
+
6
+ describe StaticRequest do
7
+ describe "api_version" do
8
+ it "is v1" do
9
+ expect(StaticRequest.api_version).to eq("v1")
10
+ end
11
+ end
12
+
13
+ let(:request) { StaticRequest.new "api_key", "euw" }
14
+
15
+ describe "api_url" do
16
+ it "contains a static-data path component" do
17
+ expect(request.api_url("foo")).to eq("http://prod.api.pvp.net/api/lol/static-data/euw/v1/foo?api_key=api_key")
18
+ end
19
+ end
20
+
21
+ StaticRequest::STANDARD_ENDPOINTS.each do |endpoint|
22
+ describe "##{endpoint}" do
23
+ it "returns a Proxy" do
24
+ expect(request.send(endpoint).class).to eq(StaticRequest::Proxy)
25
+ end
26
+
27
+ describe "#get" do
28
+ it "proxies get to StaticRequest with the correct endpoint" do
29
+ expect(request).to receive(:get).with(endpoint, anything, anything)
30
+
31
+ request.send(endpoint).get
32
+ end
33
+
34
+ context "without_id" do
35
+ let(:fixtures) { load_fixture("#{endpoint.dasherize}", StaticRequest.api_version, "get") }
36
+
37
+ subject do
38
+ expect(request).to receive(:perform_request)
39
+ .with(request.api_url("#{endpoint.dasherize}"))
40
+ .and_return(fixtures)
41
+
42
+ request.send(endpoint).get
43
+ end
44
+
45
+ it "returns an Array" do
46
+ expect(subject).to be_an(Array)
47
+ end
48
+
49
+ it "returns an Array of OpenStructs" do
50
+ expect(subject.map(&:class).uniq).to eq([OpenStruct])
51
+ end
52
+
53
+ it "fetches #{endpoint} from the API" do
54
+ expect(subject.size).to eq(fixtures["data"].size)
55
+ end
56
+ end
57
+
58
+ context "with_id" do
59
+ let(:id) { 1 }
60
+ let(:fixtures) { load_fixture("#{endpoint.dasherize}-by-id", StaticRequest.api_version, "get") }
61
+
62
+ subject do
63
+ expect(request).to receive(:perform_request)
64
+ .with(request.api_url("#{endpoint.dasherize}/#{id}"))
65
+ .and_return(fixtures)
66
+
67
+ request.send(endpoint).get(id)
68
+ end
69
+
70
+ it "returns an OpenStruct" do
71
+ expect(subject).to be_an(OpenStruct)
72
+ end
73
+ end
74
+ end
75
+ end
76
+ end
77
+
78
+ describe "realm" do
79
+ let(:fixtures) { load_fixture("realm", StaticRequest.api_version, "get") }
80
+
81
+ subject do
82
+ expect(request).to receive(:perform_request)
83
+ .with(request.api_url("realm"))
84
+ .and_return(fixtures)
85
+
86
+ request.send("realm").get
87
+ end
88
+
89
+ it "returns an OpenStruct" do
90
+ expect(subject).to be_an(OpenStruct)
91
+ end
92
+ end
93
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-lol
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.9
4
+ version: 0.9.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Giovanni Intini
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-04 00:00:00.000000000 Z
11
+ date: 2014-02-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -281,6 +281,7 @@ files:
281
281
  - lib/lol/rune.rb
282
282
  - lib/lol/rune_page.rb
283
283
  - lib/lol/rune_slot.rb
284
+ - lib/lol/static_request.rb
284
285
  - lib/lol/stats_request.rb
285
286
  - lib/lol/summoner.rb
286
287
  - lib/lol/summoner_request.rb
@@ -302,6 +303,17 @@ files:
302
303
  - spec/fixtures/v1.3/get-summoner-name.json
303
304
  - spec/fixtures/v1.3/get-summoner-runes.json
304
305
  - spec/fixtures/v1.3/get-summoner.json
306
+ - spec/fixtures/v1/get-champion-by-id.json
307
+ - spec/fixtures/v1/get-champion.json
308
+ - spec/fixtures/v1/get-item-by-id.json
309
+ - spec/fixtures/v1/get-item.json
310
+ - spec/fixtures/v1/get-mastery-by-id.json
311
+ - spec/fixtures/v1/get-mastery.json
312
+ - spec/fixtures/v1/get-realm.json
313
+ - spec/fixtures/v1/get-rune-by-id.json
314
+ - spec/fixtures/v1/get-rune.json
315
+ - spec/fixtures/v1/get-summoner-spell-by-id.json
316
+ - spec/fixtures/v1/get-summoner-spell.json
305
317
  - spec/fixtures/v2.2/get-team.json
306
318
  - spec/fixtures/v2.3/get-league.json
307
319
  - spec/lol/champion_request_spec.rb
@@ -325,6 +337,7 @@ files:
325
337
  - spec/lol/rune_page_spec.rb
326
338
  - spec/lol/rune_slot_spec.rb
327
339
  - spec/lol/rune_spec.rb
340
+ - spec/lol/static_request_spec.rb
328
341
  - spec/lol/stats_request_spec.rb
329
342
  - spec/lol/summoner_request_spec.rb
330
343
  - spec/lol/summoner_spec.rb
@@ -371,6 +384,17 @@ test_files:
371
384
  - spec/fixtures/v1.3/get-summoner-name.json
372
385
  - spec/fixtures/v1.3/get-summoner-runes.json
373
386
  - spec/fixtures/v1.3/get-summoner.json
387
+ - spec/fixtures/v1/get-champion-by-id.json
388
+ - spec/fixtures/v1/get-champion.json
389
+ - spec/fixtures/v1/get-item-by-id.json
390
+ - spec/fixtures/v1/get-item.json
391
+ - spec/fixtures/v1/get-mastery-by-id.json
392
+ - spec/fixtures/v1/get-mastery.json
393
+ - spec/fixtures/v1/get-realm.json
394
+ - spec/fixtures/v1/get-rune-by-id.json
395
+ - spec/fixtures/v1/get-rune.json
396
+ - spec/fixtures/v1/get-summoner-spell-by-id.json
397
+ - spec/fixtures/v1/get-summoner-spell.json
374
398
  - spec/fixtures/v2.2/get-team.json
375
399
  - spec/fixtures/v2.3/get-league.json
376
400
  - spec/lol/champion_request_spec.rb
@@ -394,6 +418,7 @@ test_files:
394
418
  - spec/lol/rune_page_spec.rb
395
419
  - spec/lol/rune_slot_spec.rb
396
420
  - spec/lol/rune_spec.rb
421
+ - spec/lol/static_request_spec.rb
397
422
  - spec/lol/stats_request_spec.rb
398
423
  - spec/lol/summoner_request_spec.rb
399
424
  - spec/lol/summoner_spec.rb