Sha256: 8fe3828649e62d5c2c4ee9824b823ee39c1bf1ef3ffc3989ae7b820ec8f7e3c7

Contents?: true

Size: 1.37 KB

Versions: 1

Compression:

Stored size: 1.37 KB

Contents

require 'test_helper'

describe NflData::Player do
  before do
    @player = NflData::Player.new
  end

  after do
    @player = nil
  end

  it 'has a first name' do
    @player.must_respond_to :first_name
  end

  it 'has a last name' do
    @player.must_respond_to :last_name
  end

  it 'has a full name' do
    @player.must_respond_to :full_name
  end

  it 'has a position' do
    @player.must_respond_to :position
  end

  it 'has a number' do
    @player.must_respond_to :number
  end

  it 'has a status' do
    @player.must_respond_to :status
  end

  it 'has a team' do
    @player.must_respond_to :team
  end

  it 'has an NFL player ID' do
    @player.must_respond_to :nfl_player_id
  end

  describe 'to_json' do
    before do
      @player.first_name = 'John'
      @player.last_name = 'Elway'
      @player.position = 'QB'
      @player.full_name = 'John Elway'
      @player.number = 7
      @player.status = 'Retired'
      @player.team = 'Broncos'
      @player.nfl_player_id = '123'
    end

    def valid_player_json
      JSON.generate({
        first_name: 'John',
        last_name: 'Elway',
        full_name: 'John Elway',
        position: 'QB',
        number: 7,
        status: 'Retired',
        team: 'Broncos',
        nfl_player_id: '123'
        })
    end

    it 'can return itself as JSON' do
      @player.to_json.must_equal valid_player_json
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nfl_data-0.0.2 test/nfl_data/player_test.rb