Sha256: 5b39ed062887e9e54e72f3a3c6a6b4483a1c657fc53719aa85864ff672d5071c

Contents?: true

Size: 1.73 KB

Versions: 3

Compression:

Stored size: 1.73 KB

Contents

require 'helper'

describe Fantasydata::API::LeagueLeaders do

  before do
    @client = new_test_client
  end

  describe '#league_leaders_by_season' do
    before do
      stub_get("/nfl/v2/JSON/SeasonLeagueLeaders/2014/OFFENSE/FantasyPoints").
      to_return(:body => fixture("league_leaders/by_season.json"),
                 :headers => {:content_type => "application/json; charset=utf-8"})
    end

    it "requests correct resource" do
      @client.league_leaders_by_season(2014, 'offense', 'FantasyPoints')
      expect(a_get("/nfl/v2/JSON/SeasonLeagueLeaders/2014/OFFENSE/FantasyPoints")).to have_been_made
    end

    it "returns league leaders" do
      leaders = @client.league_leaders_by_season(2014, 'offense', 'FantasyPoints')
      expect(leaders).to be_an Array
      expect(leaders.first).to be_an Fantasydata::PlayerSeasonStat
      expect(leaders.first.player_id).to eq 2593
    end
  end

  describe '#league_leaders_by_week' do
    before do
      stub_get("/nfl/v2/JSON/GameLeagueLeaders/2014/11/OFFENSE/FantasyPoints").
      to_return(:body => fixture("league_leaders/by_week.json"),
                 :headers => {:content_type => "application/json; charset=utf-8"})
    end

    it "requests correct resource" do
      @client.league_leaders_by_week(2014, 11, 'offense', 'FantasyPoints')
      expect(a_get("/nfl/v2/JSON/GameLeagueLeaders/2014/11/OFFENSE/FantasyPoints")).to have_been_made
    end

    it "returns league leaders" do
      leaders = @client.league_leaders_by_week(2014, 11, 'offense', 'FantasyPoints')
      expect(leaders).to be_an Array
      expect(leaders.first).to be_an Fantasydata::PlayerGameStat
      expect(leaders.first.player_id).to eq 15565
      expect(leaders.first.game_key).to eq '201411114'
    end
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
fantasydata-0.2.2 spec/fantasydata/api/league_leaders_spec.rb
fantasydata-0.2.1 spec/fantasydata/api/league_leaders_spec.rb
fantasydata-0.2.0 spec/fantasydata/api/league_leaders_spec.rb