Sha256: f2c11229f7e9f05b5997acfad91e38ecba2a7071ad21da232e525b01eda29598
Contents?: true
Size: 1.71 KB
Versions: 1
Compression:
Stored size: 1.71 KB
Contents
require "spec_helper" require "lol" include Lol describe Request do context "initialization" do it "requires an api_key parameter" do expect { ChampionRequest.new }.to raise_error(ArgumentError) end it "accepts a region parameter" do expect { ChampionRequest.new "foo" }.to raise_error(ArgumentError) end end subject { Request.new "api_key", "euw"} describe "#perform_request" do it "calls HTTParty get" do expect(subject.class).to receive(:get).and_return(error_401) expect { subject.perform_request "foo"}.to raise_error(InvalidAPIResponse) end it "handles 401" do expect(subject.class).to receive(:get).and_return(error_401) expect { subject.perform_request "foo" }.to raise_error(InvalidAPIResponse) end end describe "api_url" do it "defaults on Request#region" do expect(subject.api_url("foo", "bar")).to match(/\/euw\//) end it "requires an api_key a version and a path" do expect { subject.api_url "foo" }.to raise_error(ArgumentError) end it "returns a full fledged api url" do expect(subject.api_url("foo", "bar")).to eq("http://prod.api.pvp.net/api/euw/foo/bar?api_key=api_key") end it "has lol if url is v1.1" do expect(subject.api_url("v1.1", "foo")).to eq("http://prod.api.pvp.net/api/lol/euw/v1.1/foo?api_key=api_key") end it "does not have lol if url is v2.1 or greater" do expect(subject.api_url("v2.1", "foo")).to eq("http://prod.api.pvp.net/api/euw/v2.1/foo?api_key=api_key") end it "optionally accept query string parameters" do expect(subject.api_url("v2.1", "foo", a: 'b')).to eq("http://prod.api.pvp.net/api/euw/v2.1/foo?a=b&api_key=api_key") end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ruby-lol-0.0.7 | spec/lol/request_spec.rb |