Sha256: 41d2f059e418d1ff18576a3c818be43d1ba01044c2c069ca19ec2672fc112778

Contents?: true

Size: 1.25 KB

Versions: 6

Compression:

Stored size: 1.25 KB

Contents

require "spec_helper"
require "lol"

include Lol

describe ChampionRequest do
  it "inherits from Request" do
    expect(ChampionRequest.ancestors[1]).to eq(Request)
  end

  describe "get" do
    let(:request) { ChampionRequest.new "api_key", "euw" }

    context "specifying an id" do
      subject do
        expect(request).to receive(:perform_request).with(request.api_url("champion/266", "freeToPlay" => false)).and_return(load_fixture("champion-266", ChampionRequest.api_version, "get"))

        request.get :id => 266
      end

      it "returns a champion" do
        expect(subject).to be_a(Champion)
      end
    end

    context "getting all" do
      subject do
        expect(request).to receive(:perform_request).with(request.api_url("champion", "freeToPlay" => false)).and_return(load_fixture("champion", ChampionRequest.api_version, "get"))

        request.get
      end

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

      it "returns an array of champions" do
        expect(subject.map {|e| e.class}.uniq).to eq([Champion])
      end

      it "fetches champions from the API" do
        expect(subject.size).to eq(load_fixture("champion", ChampionRequest.api_version, "get")["champions"].size)
      end

    end


  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ruby-lol-0.9.18 spec/lol/champion_request_spec.rb
ruby-lol-0.9.17 spec/lol/champion_request_spec.rb
ruby-lol-0.9.16 spec/lol/champion_request_spec.rb
ruby-lol-0.9.15 spec/lol/champion_request_spec.rb
ruby-lol-0.9.14 spec/lol/champion_request_spec.rb
ruby-lol-0.9.13 spec/lol/champion_request_spec.rb