Skip to content

Commit

Permalink
add StaticRequest#map (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
Diomede authored and Nicola Racco committed Feb 22, 2017
1 parent 7d8da4a commit eef6cd2
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/lol/static_request.rb
Expand Up @@ -18,6 +18,10 @@ def api_url path, params = {}
define_method(endpoint) { Proxy.new self, endpoint }
end

def map
Proxy.new self, 'map'
end

def realm
Proxy.new self, 'realm'
end
Expand Down
71 changes: 71 additions & 0 deletions spec/fixtures/v1.2/get-map.json
@@ -0,0 +1,71 @@
{
"type": "map",
"version": "7.4.1",
"data": {
"11": {
"mapName": "Summoner's Rift",
"mapId": 11,
"image": {
"full": "map11.png",
"sprite": "map0.png",
"group": "map",
"x": 96,
"y": 0,
"w": 48,
"h": 48
}
},
"12": {
"mapName": "Howling Abyss",
"mapId": 12,
"image": {
"full": "map12.png",
"sprite": "map0.png",
"group": "map",
"x": 144,
"y": 0,
"w": 48,
"h": 48
}
},
"14": {
"mapName": "Butcher's Bridge",
"mapId": 14,
"image": {
"full": "map14.png",
"sprite": "map0.png",
"group": "map",
"x": 192,
"y": 0,
"w": 48,
"h": 48
}
},
"8": {
"mapName": "The Crystal Scar",
"mapId": 8,
"image": {
"full": "map8.png",
"sprite": "map0.png",
"group": "map",
"x": 0,
"y": 0,
"w": 48,
"h": 48
}
},
"10": {
"mapName": "The Twisted Treeline",
"mapId": 10,
"image": {
"full": "map10.png",
"sprite": "map0.png",
"group": "map",
"x": 48,
"y": 0,
"w": 48,
"h": 48
}
}
}
}
14 changes: 14 additions & 0 deletions spec/lol/static_request_spec.rb
Expand Up @@ -68,6 +68,20 @@
end
end

describe "#map" do
subject { request.map.get }

before(:each) { stub_request(request, 'map', 'map') }

it "returns an Array" do
expect(subject).to be_an(Array)
end

it "returns an Array of OpenStructs" do
expect(subject.map(&:class).uniq).to eq([OpenStruct])
end
end

describe "#realm" do
subject { request.realm.get }

Expand Down

0 comments on commit eef6cd2

Please sign in to comment.