-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
All Requests have been moved in separate classes now.
- Loading branch information
Showing
5 changed files
with
48 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module Lol | ||
class LeagueRequest < Request | ||
# Retrieves leagues data for summoner, including leagues for all of summoner's teams, v2.1 | ||
# @return [Array] an array of champions | ||
def get summoner_id | ||
response = perform_request(api_url("v2.1", "league/by-summoner/#{summoner_id}"))[summoner_id] | ||
response.is_a?(Hash) ? [League.new(response)] : response.map {|l| League.new l} | ||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
require "spec_helper" | ||
require "lol" | ||
|
||
include Lol | ||
|
||
describe LeagueRequest do | ||
it "inherits from Request" do | ||
expect(LeagueRequest.ancestors[1]).to eq(Request) | ||
end | ||
|
||
describe "#get" do | ||
let(:request) { LeagueRequest.new "api_key", "euw" } | ||
|
||
subject do | ||
expect(request.class).to receive(:get).with(request.api_url("v2.1", "league/by-summoner/foo")).and_return(load_fixture("league", "v2.1", "get")) | ||
|
||
request.get("foo") | ||
end | ||
|
||
it "returns an array of Leagues" do | ||
expect(subject.map(&:class).uniq).to eq([League]) | ||
end | ||
end | ||
end |