Skip to content

Commit

Permalink
Updated team request
Browse files Browse the repository at this point in the history
  • Loading branch information
intinig committed Sep 3, 2014
1 parent 0016953 commit 243cdea
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 24 deletions.
13 changes: 8 additions & 5 deletions lib/lol/team_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,22 @@ def self.api_version

# Retrieves the list of Teams for the given summoner
# @return [Array] List of Team
def get *summoner_ids
def by_summoner *summoner_ids
returns = {}
perform_request(api_url "team/by-summoner/#{summoner_ids.join(",")}").each do |s, t|
returns[s] = t.map {|data| Team.new data}
returns[s] = Team.new t
end
returns
end

# Retrieves the Teams for the given Team ID
# @return [Team]
def getbyid team_id
result = perform_request(api_url "team/#{team_id}")
Team.new result[team_id]
def get *team_ids
returns = {}
perform_request(api_url "team/#{team_ids.join(",")}").each do |t,d|
returns[t] = Team.new d
end
returns
end
end
end
1 change: 0 additions & 1 deletion spec/fixtures/v2.3/get-team-by-id.json

This file was deleted.

1 change: 0 additions & 1 deletion spec/fixtures/v2.3/get-team.json

This file was deleted.

1 change: 1 addition & 0 deletions spec/fixtures/v2.4/get-team-by-id.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"TEAM-c8e23190-b00c-11e3-91c1-782bcb4ce61a":{"fullId":"TEAM-c8e23190-b00c-11e3-91c1-782bcb4ce61a","name":"testingRGTS","tag":"rgtste","status":"PROVISIONAL","teamStatDetails":[{"teamStatType":"RANKED_TEAM_3x3","wins":0,"losses":0,"averageGamesPlayed":0},{"teamStatType":"RANKED_TEAM_5x5","wins":0,"losses":0,"averageGamesPlayed":0}],"roster":{"ownerId":30743211,"memberList":[{"playerId":30743211,"joinDate":1395322408000,"inviteDate":1395290341000,"status":"MEMBER"},{"playerId":33249714,"joinDate":1395657363000,"inviteDate":1395655873000,"status":"MEMBER"},{"playerId":31219624,"joinDate":1395656699000,"inviteDate":1395655875000,"status":"MEMBER"}]},"createDate":1395305470000,"modifyDate":1396432715000,"lastJoinDate":1395657363000,"secondLastJoinDate":1395656699000,"thirdLastJoinDate":1395322408000,"lastJoinedRankedTeamQueueDate":545837107898}}
1 change: 1 addition & 0 deletions spec/fixtures/v2.4/get-team.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"TEAM-c8e23190-b00c-11e3-91c1-782bcb4ce61a":{"fullId":"TEAM-c8e23190-b00c-11e3-91c1-782bcb4ce61a","name":"testingRGTS","tag":"rgtste","status":"PROVISIONAL","teamStatDetails":[{"teamStatType":"RANKED_TEAM_3x3","wins":0,"losses":0,"averageGamesPlayed":0},{"teamStatType":"RANKED_TEAM_5x5","wins":0,"losses":0,"averageGamesPlayed":0}],"roster":{"ownerId":30743211,"memberList":[{"playerId":30743211,"joinDate":1395322408000,"inviteDate":1395290341000,"status":"MEMBER"},{"playerId":33249714,"joinDate":1395657363000,"inviteDate":1395655873000,"status":"MEMBER"},{"playerId":31219624,"joinDate":1395656699000,"inviteDate":1395655875000,"status":"MEMBER"}]},"createDate":1395305470000,"modifyDate":1396432715000,"lastJoinDate":1395657363000,"secondLastJoinDate":1395656699000,"thirdLastJoinDate":1395322408000,"lastJoinedRankedTeamQueueDate":545825650248}}
26 changes: 9 additions & 17 deletions spec/lol/team_request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,43 +10,35 @@
expect(TeamRequest.ancestors[1]).to eq(Request)
end

describe "#get" do
describe "#by_summoner" do
let(:fixture) { load_fixture('team', TeamRequest.api_version) }

subject { request.get(1) }
subject { request.by_summoner(1) }

before(:each) { stub_request(request, 'team', 'team/by-summoner/1') }

it 'returns an hash' do
expect(subject).to be_a(Hash)
end

it 'returns an array of Team' do
expect(subject[subject.keys.first].map(&:class).uniq).to eq([Team])
end

it 'fetches Team from the API' do
expect(subject.size).to eq(fixture.size)
end
end

describe "#getbyid" do
describe "#get" do

it 'requires a summoner' do
expect { request.getbyid }.to raise_error ArgumentError
it 'requires a team id' do
expect { request.get }.to raise_error
end

context 'with summoner' do
subject { request.getbyid("TEAM-a9ad3db0-b377-11e3-b87d-782bcb4ce61a") }
context 'with team id' do
subject { request.get("TEAM-a9ad3db0-b377-11e3-b87d-782bcb4ce61a") }

before(:each) { stub_request(request, 'team-by-id', 'team/TEAM-a9ad3db0-b377-11e3-b87d-782bcb4ce61a') }

it 'returns a Team' do
expect(subject).to be_a Lol::Team
end

it 'fetches Team from the API' do
expect(subject.full_id).to eq "TEAM-a9ad3db0-b377-11e3-b87d-782bcb4ce61a"
it 'returns an array of Teams' do
subject.each {|k,v| expect(v).to be_a Lol::Team}
end
end

Expand Down

0 comments on commit 243cdea

Please sign in to comment.