From eef6cd20326aae0f6eb08fc872fc4678f89814c9 Mon Sep 17 00:00:00 2001 From: Diomede Date: Wed, 22 Feb 2017 16:53:53 +0100 Subject: [PATCH] add StaticRequest#map (#61) --- lib/lol/static_request.rb | 4 ++ spec/fixtures/v1.2/get-map.json | 71 +++++++++++++++++++++++++++++++++ spec/lol/static_request_spec.rb | 14 +++++++ 3 files changed, 89 insertions(+) create mode 100644 spec/fixtures/v1.2/get-map.json diff --git a/lib/lol/static_request.rb b/lib/lol/static_request.rb index 63ab700..1c8443c 100644 --- a/lib/lol/static_request.rb +++ b/lib/lol/static_request.rb @@ -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 diff --git a/spec/fixtures/v1.2/get-map.json b/spec/fixtures/v1.2/get-map.json new file mode 100644 index 0000000..8e784e5 --- /dev/null +++ b/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 + } + } + } +} diff --git a/spec/lol/static_request_spec.rb b/spec/lol/static_request_spec.rb index f5a8636..fca519b 100644 --- a/spec/lol/static_request_spec.rb +++ b/spec/lol/static_request_spec.rb @@ -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 }