Sha256: ff64871bd4b862e7d6e00a29a8b03651683914fc79c682e555e11f6d60e2280b

Contents?: true

Size: 1.77 KB

Versions: 6

Compression:

Stored size: 1.77 KB

Contents

require 'spec_helper'

describe SportsDataApi::Mlb::Boxscore, vcr: {
    cassette_name: 'sports_data_api_mlb_game_boxscore',
    record: :new_episodes,
    match_requests_on: [:host, :path]
} do

  context "closed game" do
    let(:boxscore) do
      SportsDataApi.set_key(:mlb, api_key(:mlb))
      SportsDataApi.set_access_level(:mlb, 't')
      SportsDataApi::Mlb.game_boxscore("000c465f-7c8c-46bb-8ea7-c26b2bc7c296")
    end

    subject { boxscore }
    it "inning eq 9" do
      boxscore.game_state[:inning].to_i.should eq 9
    end
    it "inning_half eq t" do
      boxscore.game_state[:inning_half].should eq 'T'
    end
    it "home team score eq 5" do
      boxscore.game_state[:home_score].should eq '5'
    end
    it "visitor team score eq 2" do
      boxscore.game_state[:visitor_score].should eq '2'
    end
    it "should return a game status" do
      boxscore.game_state[:status].should eq 'closed'
    end
  end

  context "inprogress game" do
    let(:url) { 'http://developer.sportsdatallc.com/files/mlb_v4_game_boxscore_example.xml' }

    let(:boxscore_xml) do
      str = RestClient.get(url).to_s
      xml = Nokogiri::XML(str)
      xml.remove_namespaces!
      xml.xpath('/boxscore').first
    end

    let(:boxscore) { SportsDataApi::Mlb::Boxscore.new(boxscore_xml)}

    subject { boxscore }
    it "inning eq 12" do
      boxscore.game_state[:inning].to_i.should eq 12
    end
    it "inning_half eq t" do
      boxscore.game_state[:inning_half].should eq 'T'
    end
    it "home team score eq 2" do
      boxscore.game_state[:home_score].should eq '2'
    end
    it "visitor team score eq 3" do
      boxscore.game_state[:visitor_score].should eq '3'
    end
    it "should return a game status" do
      boxscore.game_state[:status].should eq 'inprogress'
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
sports_data_api-0.2.4 spec/lib/sports_data_api/mlb/boxscore_spec.rb
sports_data_api-0.2.3 spec/lib/sports_data_api/mlb/boxscore_spec.rb
sports_data_api-0.2.2 spec/lib/sports_data_api/mlb/boxscore_spec.rb
sports_data_api-0.2.1 spec/lib/sports_data_api/mlb/boxscore_spec.rb
sports_data_api-0.2.0 spec/lib/sports_data_api/mlb/boxscore_spec.rb
sports_data_api-0.1.0 spec/lib/sports_data_api/mlb/boxscore_spec.rb