Sha256: e397e19a9d8e0bcbf4678a2e6bc46f4b3638963ac6f9bc718da489ef3e82ccc6

Contents?: true

Size: 1.8 KB

Versions: 3

Compression:

Stored size: 1.8 KB

Contents

require 'test_helper'

describe PlayerParser do
  before do
    @parser = PlayerParser.new
  end

  after do
    @parser = nil
  end

  it 'should know the correct base url' do
    @parser.base_url.must_equal "http://www.nfl.com/players/search?category=position&conferenceAbbr=null&playerType=current&conference=ALL&filter="
  end

  describe 'get_by_position' do
    it 'should get quarterbacks' do
      VCR.use_cassette('quarterbacks') do
        response = @parser.get_by_position(:quarterbacks)

        response.keys.must_include :quarterbacks
        response[:quarterbacks].count.must_equal 125
      end
    end

    it 'should get runningbacks' do
      VCR.use_cassette('runningbacks') do
        response = @parser.get_by_position(:runningbacks)

        response.keys.must_include :runningbacks
        response[:runningbacks].count.must_equal 261
      end
    end

    it 'should get wide receivers' do
      VCR.use_cassette('wide_receivers') do
        response = @parser.get_by_position(:wide_receivers)

        response.keys.must_include :wide_receivers
        response[:wide_receivers].count.must_equal 387
      end
    end

    it 'should get tight ends' do
      VCR.use_cassette('tight_ends') do
        response = @parser.get_by_position(:tight_ends)

        response.keys.must_include :tight_ends
        response[:tight_ends].count.must_equal 197
      end
    end

    it 'should get all the players' do
      VCR.use_cassette('all_players') do
        response = @parser.get_by_position(:all)

        {
          quarterbacks: 125,
          runningbacks: 261,
          wide_receivers: 387,
          tight_ends: 197
        }.each do |position, player_count|
          response.keys.must_include position
          response[position].count.must_equal player_count
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
nfl_data-0.0.7 test/nfl_data/parsers/player_parser_test.rb
nfl_data-0.0.6 test/nfl_data/parsers/player_parser_test.rb
nfl_data-0.0.5 test/nfl_data/parsers/player_parser_test.rb