sports_data_api 0.0.3 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +7 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +2 -1
- data/Guardfile +1 -1
- data/README.md +20 -5
- data/lib/sports_data_api/exception.rb +5 -0
- data/lib/sports_data_api/mlb/boxscore.rb +36 -0
- data/lib/sports_data_api/mlb/broadcast.rb +14 -0
- data/lib/sports_data_api/mlb/game.rb +30 -0
- data/lib/sports_data_api/mlb/game_stat.rb +26 -0
- data/lib/sports_data_api/mlb/game_stats.rb +44 -0
- data/lib/sports_data_api/mlb/games.rb +29 -0
- data/lib/sports_data_api/mlb/player.rb +17 -0
- data/lib/sports_data_api/mlb/players.rb +42 -0
- data/lib/sports_data_api/mlb/season.rb +18 -0
- data/lib/sports_data_api/mlb/team.rb +35 -0
- data/lib/sports_data_api/mlb/teams.rb +42 -0
- data/lib/sports_data_api/mlb/venue.rb +15 -0
- data/lib/sports_data_api/mlb/venues.rb +37 -0
- data/lib/sports_data_api/mlb.rb +82 -0
- data/lib/sports_data_api/nba/broadcast.rb +14 -0
- data/lib/sports_data_api/nba/game.rb +54 -0
- data/lib/sports_data_api/nba/games.rb +26 -0
- data/lib/sports_data_api/nba/player.rb +22 -0
- data/lib/sports_data_api/nba/season.rb +28 -0
- data/lib/sports_data_api/nba/team.rb +40 -0
- data/lib/sports_data_api/nba/teams.rb +83 -0
- data/lib/sports_data_api/nba/venue.rb +20 -0
- data/lib/sports_data_api/nba.rb +71 -0
- data/lib/sports_data_api/nfl/broadcast.rb +15 -0
- data/lib/sports_data_api/nfl/game.rb +83 -0
- data/lib/sports_data_api/nfl/games.rb +29 -0
- data/lib/sports_data_api/nfl/injuries.rb +9 -0
- data/lib/sports_data_api/nfl/player.rb +15 -0
- data/lib/sports_data_api/nfl/player_season_stats.rb +26 -0
- data/lib/sports_data_api/nfl/season.rb +27 -0
- data/lib/sports_data_api/nfl/team.rb +46 -0
- data/lib/sports_data_api/nfl/team_roster.rb +17 -0
- data/lib/sports_data_api/nfl/team_season_stats.rb +19 -0
- data/lib/sports_data_api/nfl/teams.rb +84 -0
- data/lib/sports_data_api/nfl/venue.rb +22 -0
- data/lib/sports_data_api/nfl/weather.rb +17 -0
- data/lib/sports_data_api/nfl/week.rb +20 -0
- data/lib/sports_data_api/nfl.rb +98 -0
- data/lib/sports_data_api/stats.rb +13 -0
- data/lib/sports_data_api/version.rb +1 -1
- data/lib/sports_data_api.rb +37 -12
- data/spec/cassettes/sports_data_api_mlb_game.yml +20193 -0
- data/spec/cassettes/sports_data_api_mlb_game_boxscore.yml +225 -0
- data/spec/cassettes/sports_data_api_mlb_game_stats.yml +657 -0
- data/spec/cassettes/sports_data_api_mlb_games.yml +195 -0
- data/spec/cassettes/sports_data_api_mlb_player.yml +10891 -0
- data/spec/cassettes/sports_data_api_mlb_season.yml +20193 -0
- data/spec/cassettes/sports_data_api_mlb_team.yml +182 -0
- data/spec/cassettes/sports_data_api_mlb_team_roster.yml +10891 -0
- data/spec/cassettes/sports_data_api_mlb_teams.yml +403 -0
- data/spec/cassettes/sports_data_api_mlb_venues.yml +343 -0
- data/spec/cassettes/sports_data_api_nba.yml +74176 -0
- data/spec/cassettes/sports_data_api_nba_broadcast.yml +88 -0
- data/spec/cassettes/sports_data_api_nba_game.yml +21202 -0
- data/spec/cassettes/sports_data_api_nba_games.yml +128 -0
- data/spec/cassettes/sports_data_api_nba_league_hierarchy.yml +545 -0
- data/spec/cassettes/sports_data_api_nba_player.yml +244 -0
- data/spec/cassettes/sports_data_api_nba_season.yml +18228 -0
- data/spec/cassettes/sports_data_api_nba_team.yml +1398 -0
- data/spec/cassettes/sports_data_api_nba_team_roster.yml +244 -0
- data/spec/cassettes/sports_data_api_nba_venue.yml +88 -0
- data/spec/cassettes/sports_data_api_nfl.yml +19105 -0
- data/spec/cassettes/sports_data_api_nfl_broadcast.yml +112 -0
- data/spec/cassettes/sports_data_api_nfl_game.yml +16139 -0
- data/spec/cassettes/sports_data_api_nfl_games.yml +912 -0
- data/spec/cassettes/sports_data_api_nfl_player_season_stats.yml +997 -0
- data/spec/cassettes/sports_data_api_nfl_season.yml +14100 -0
- data/spec/cassettes/sports_data_api_nfl_team.yml +783 -0
- data/spec/cassettes/sports_data_api_nfl_team_hierarchy.yml +909 -0
- data/spec/cassettes/sports_data_api_nfl_team_roster.yml +618 -0
- data/spec/cassettes/sports_data_api_nfl_team_season_stats.yml +981 -0
- data/spec/cassettes/sports_data_api_nfl_venue.yml +112 -0
- data/spec/cassettes/sports_data_api_nfl_weather.yml +112 -0
- data/spec/cassettes/sports_data_api_nfl_week.yml +14100 -0
- data/spec/lib/sports_data_api/mlb/boxscore_spec.rb +63 -0
- data/spec/lib/sports_data_api/mlb/game_spec.rb +24 -0
- data/spec/lib/sports_data_api/mlb/game_stats_spec.rb +25 -0
- data/spec/lib/sports_data_api/mlb/games_spec.rb +24 -0
- data/spec/lib/sports_data_api/mlb/player_spec.rb +103 -0
- data/spec/lib/sports_data_api/mlb/players_spec.rb +17 -0
- data/spec/lib/sports_data_api/mlb/season_spec.rb +19 -0
- data/spec/lib/sports_data_api/mlb/team_spec.rb +24 -0
- data/spec/lib/sports_data_api/mlb/teams_spec.rb +30 -0
- data/spec/lib/sports_data_api/mlb/venues_spec.rb +17 -0
- data/spec/lib/sports_data_api/nba/broadcast_spec.rb +18 -0
- data/spec/lib/sports_data_api/nba/game_spec.rb +87 -0
- data/spec/lib/sports_data_api/nba/games_spec.rb +19 -0
- data/spec/lib/sports_data_api/nba/player_spec.rb +72 -0
- data/spec/lib/sports_data_api/nba/season_spec.rb +41 -0
- data/spec/lib/sports_data_api/nba/team_spec.rb +185 -0
- data/spec/lib/sports_data_api/nba/teams_spec.rb +76 -0
- data/spec/lib/sports_data_api/nba/venue_spec.rb +24 -0
- data/spec/lib/sports_data_api/nba_spec.rb +41 -0
- data/spec/lib/sports_data_api/nfl/broadcast_spec.rb +19 -0
- data/spec/lib/sports_data_api/nfl/game_spec.rb +126 -0
- data/spec/lib/sports_data_api/nfl/games_spec.rb +21 -0
- data/spec/lib/sports_data_api/nfl/player_season_stats.rb +28 -0
- data/spec/lib/sports_data_api/nfl/season_spec.rb +41 -0
- data/spec/lib/sports_data_api/nfl/team_roster_spec.rb +28 -0
- data/spec/lib/sports_data_api/nfl/team_season_stats.rb +19 -0
- data/spec/lib/sports_data_api/nfl/team_spec.rb +52 -0
- data/spec/lib/sports_data_api/nfl/teams_spec.rb +77 -0
- data/spec/lib/sports_data_api/nfl/venue_spec.rb +26 -0
- data/spec/lib/sports_data_api/nfl/weather_spec.rb +21 -0
- data/spec/lib/sports_data_api/nfl/week_spec.rb +21 -0
- data/spec/lib/sports_data_api/nfl_spec.rb +113 -0
- data/spec/lib/sports_data_api_spec.rb +8 -5
- data/spec/spec_helper.rb +30 -9
- data/sports_data_api.gemspec +19 -15
- metadata +267 -76
- data/.rvmrc +0 -38
- data/lib/nfl.rb +0 -149
- data/spec/lib/nfl_spec.rb +0 -125
- data/spec/xml/boxscore.xml +0 -93
- data/spec/xml/schedule.xml +0 -4067
- data/spec/xml/teams.xml +0 -119
@@ -0,0 +1,185 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SportsDataApi::Nba::Team, vcr: {
|
4
|
+
cassette_name: 'sports_data_api_nba_team',
|
5
|
+
record: :new_episodes,
|
6
|
+
match_requests_on: [:host, :path]
|
7
|
+
} do
|
8
|
+
let(:teams) do
|
9
|
+
SportsDataApi.set_key(:nba, api_key(:nba))
|
10
|
+
SportsDataApi.set_access_level(:nba, 't')
|
11
|
+
SportsDataApi::Nba.teams
|
12
|
+
end
|
13
|
+
let(:roster) do
|
14
|
+
SportsDataApi.set_key(:nba, api_key(:nba))
|
15
|
+
SportsDataApi.set_access_level(:nba, 't')
|
16
|
+
SportsDataApi::Nba.team_roster('583ec825-fb46-11e1-82cb-f4ce4684ea4c')
|
17
|
+
end
|
18
|
+
let(:game_summary) do
|
19
|
+
SportsDataApi.set_key(:nba, api_key(:nba))
|
20
|
+
SportsDataApi.set_access_level(:nba, 't')
|
21
|
+
SportsDataApi::Nba.game_summary('e1dcf692-330d-46d3-8add-a241b388fbe2')
|
22
|
+
end
|
23
|
+
|
24
|
+
context 'results from teams fetch' do
|
25
|
+
subject { teams.first }
|
26
|
+
it { should be_an_instance_of(SportsDataApi::Nba::Team) }
|
27
|
+
its(:id) { should eq "583ec8d4-fb46-11e1-82cb-f4ce4684ea4c" }
|
28
|
+
its(:alias) { should eq 'WAS' }
|
29
|
+
its(:conference) { should eq 'EASTERN' }
|
30
|
+
its(:division) { should eq 'SOUTHEAST' }
|
31
|
+
its(:market) { should eq 'Washington' }
|
32
|
+
its(:name) { should eq 'Wizards' }
|
33
|
+
its(:players) { should eq [] }
|
34
|
+
its(:points) { should be_nil }
|
35
|
+
end
|
36
|
+
context 'results from team roster fetch' do
|
37
|
+
subject { roster }
|
38
|
+
it { should be_an_instance_of(SportsDataApi::Nba::Team) }
|
39
|
+
its(:id) { should eq "583ec825-fb46-11e1-82cb-f4ce4684ea4c" }
|
40
|
+
its(:alias) { should eq 'GSW' }
|
41
|
+
its(:market) { should eq 'Golden State' }
|
42
|
+
its(:name) { should eq 'Warriors' }
|
43
|
+
its(:players) { should be_an_instance_of(Array) }
|
44
|
+
its(:points) { should be_nil }
|
45
|
+
context 'players' do
|
46
|
+
subject { roster.players }
|
47
|
+
its(:count) { should eq 15 }
|
48
|
+
end
|
49
|
+
end
|
50
|
+
context 'results from game_summary fetch' do
|
51
|
+
subject { game_summary.home_team }
|
52
|
+
it { should be_an_instance_of(SportsDataApi::Nba::Team) }
|
53
|
+
its(:id) { should eq '583ec825-fb46-11e1-82cb-f4ce4684ea4c' }
|
54
|
+
its(:market) { should eq 'Golden State' }
|
55
|
+
its(:name) { should eq 'Warriors' }
|
56
|
+
its(:points) { should eq 125 }
|
57
|
+
its(:alias) { should be_nil }
|
58
|
+
its(:conference) { should be_nil }
|
59
|
+
its(:division) { should be_nil }
|
60
|
+
its(:players) { should be_an_instance_of(Array) }
|
61
|
+
|
62
|
+
context 'players' do
|
63
|
+
subject { game_summary.home_team.players }
|
64
|
+
its(:count) { should eq 14 }
|
65
|
+
end
|
66
|
+
|
67
|
+
context 'player' do
|
68
|
+
subject { game_summary.home_team.players.first }
|
69
|
+
it { should be_an_instance_of(SportsDataApi::Nba::Player) }
|
70
|
+
it 'should have an id' do
|
71
|
+
expect(subject.player[:id]).to eq "e4bd8c65-a40b-42e3-8327-6913045bf008"
|
72
|
+
end
|
73
|
+
it 'should have a full_name' do
|
74
|
+
expect(subject.player[:full_name]).to eq "Marreese Speights"
|
75
|
+
end
|
76
|
+
it 'should have a first_name' do
|
77
|
+
expect(subject.player[:first_name]).to eq "Marreese"
|
78
|
+
end
|
79
|
+
it 'should have a last_name' do
|
80
|
+
expect(subject.player[:last_name]).to eq "Speights"
|
81
|
+
end
|
82
|
+
it 'should have a position' do
|
83
|
+
expect(subject.player[:position]).to eq "F-C"
|
84
|
+
end
|
85
|
+
it 'should have a primary_position' do
|
86
|
+
expect(subject.player[:primary_position]).to eq "PF"
|
87
|
+
end
|
88
|
+
it 'should have a jersey_number' do
|
89
|
+
expect(subject.player[:jersey_number]).to eq "5"
|
90
|
+
end
|
91
|
+
it 'should have a played' do
|
92
|
+
expect(subject.player[:played]).to eq "true"
|
93
|
+
end
|
94
|
+
it 'should have an active' do
|
95
|
+
expect(subject.player[:active]).to eq "true"
|
96
|
+
end
|
97
|
+
its(:stats){ should be_an_instance_of(SportsDataApi::Stats) }
|
98
|
+
|
99
|
+
context 'stats' do
|
100
|
+
subject { game_summary.home_team.players.first.stats.statistics }
|
101
|
+
it 'should have minutes' do
|
102
|
+
expect(subject[:minutes]).to eql '19:45'
|
103
|
+
end
|
104
|
+
it 'should have field_goals_made' do
|
105
|
+
expect(subject[:field_goals_made]).to eql '2'
|
106
|
+
end
|
107
|
+
it 'should have field_goals_made' do
|
108
|
+
expect(subject[:field_goals_att]).to eql '10'
|
109
|
+
end
|
110
|
+
it 'should have field_goals_pct' do
|
111
|
+
expect(subject[:field_goals_pct]).to eql '20.0'
|
112
|
+
end
|
113
|
+
it 'should have two_points_made' do
|
114
|
+
expect(subject[:two_points_made]).to eql '1'
|
115
|
+
end
|
116
|
+
it 'should have two_points_att' do
|
117
|
+
expect(subject[:two_points_att]).to eql '8'
|
118
|
+
end
|
119
|
+
it 'should have two_points_pct' do
|
120
|
+
expect(subject[:two_points_pct]).to eql '0.125'
|
121
|
+
end
|
122
|
+
it 'should have three_points_made' do
|
123
|
+
expect(subject[:three_points_made]).to eql '1'
|
124
|
+
end
|
125
|
+
it 'should have three_points_att' do
|
126
|
+
expect(subject[:three_points_att]).to eql '2'
|
127
|
+
end
|
128
|
+
it 'should have three_points_pct' do
|
129
|
+
expect(subject[:three_points_pct]).to eql '50.0'
|
130
|
+
end
|
131
|
+
it 'should have blocked_att' do
|
132
|
+
expect(subject[:blocked_att]).to eql '2'
|
133
|
+
end
|
134
|
+
it 'should have free_throws_made' do
|
135
|
+
expect(subject[:free_throws_made]).to eql '2'
|
136
|
+
end
|
137
|
+
it 'should have free_throws_att' do
|
138
|
+
expect(subject[:free_throws_att]).to eql '2'
|
139
|
+
end
|
140
|
+
it 'should have free_throws_pct' do
|
141
|
+
expect(subject[:free_throws_pct]).to eql '100.0'
|
142
|
+
end
|
143
|
+
it 'should have offensive_rebounds' do
|
144
|
+
expect(subject[:offensive_rebounds]).to eql '1'
|
145
|
+
end
|
146
|
+
it 'should have defensive_rebounds' do
|
147
|
+
expect(subject[:defensive_rebounds]).to eql '7'
|
148
|
+
end
|
149
|
+
it 'should have rebounds' do
|
150
|
+
expect(subject[:rebounds]).to eql '8'
|
151
|
+
end
|
152
|
+
it 'should have assists' do
|
153
|
+
expect(subject[:assists]).to eql '3'
|
154
|
+
end
|
155
|
+
it 'should have turnovers' do
|
156
|
+
expect(subject[:turnovers]).to eql '0'
|
157
|
+
end
|
158
|
+
it 'should have steals' do
|
159
|
+
expect(subject[:steals]).to eql '1'
|
160
|
+
end
|
161
|
+
it 'should have blocks' do
|
162
|
+
expect(subject[:blocks]).to eql '0'
|
163
|
+
end
|
164
|
+
it 'should have assists_turnover_ratio' do
|
165
|
+
expect(subject[:assists_turnover_ratio]).to eql '0'
|
166
|
+
end
|
167
|
+
it 'should have personal_fouls' do
|
168
|
+
expect(subject[:personal_fouls]).to eql '2'
|
169
|
+
end
|
170
|
+
it 'should have tech_fouls' do
|
171
|
+
expect(subject[:tech_fouls]).to eql '0'
|
172
|
+
end
|
173
|
+
it 'should have flagrant_fouls' do
|
174
|
+
expect(subject[:flagrant_fouls]).to eql '0'
|
175
|
+
end
|
176
|
+
it 'should have pls_min' do
|
177
|
+
expect(subject[:pls_min]).to eql '3'
|
178
|
+
end
|
179
|
+
it 'should have points' do
|
180
|
+
expect(subject[:points]).to eql '7'
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SportsDataApi::Nba::Teams, vcr: {
|
4
|
+
cassette_name: 'sports_data_api_nba_league_hierarchy',
|
5
|
+
record: :new_episodes,
|
6
|
+
match_requests_on: [:host, :path]
|
7
|
+
} do
|
8
|
+
let(:teams) do
|
9
|
+
SportsDataApi.set_key(:nba, api_key(:nba))
|
10
|
+
SportsDataApi.set_access_level(:nba, 't')
|
11
|
+
SportsDataApi::Nba.teams
|
12
|
+
end
|
13
|
+
|
14
|
+
let(:url) { 'http://api.sportsdatallc.org/nba-t3/league/hierarchy.xml' }
|
15
|
+
|
16
|
+
let(:warriors_xml) do
|
17
|
+
str = RestClient.get(url, params: { api_key: api_key(:nba) }).to_s
|
18
|
+
xml = Nokogiri::XML(str)
|
19
|
+
xml.remove_namespaces!
|
20
|
+
xml.xpath('/league/conference/division/team[@alias=\'GSW\']')
|
21
|
+
end
|
22
|
+
|
23
|
+
let(:warriors) { SportsDataApi::Nba::Team.new(warriors_xml) }
|
24
|
+
|
25
|
+
subject { teams }
|
26
|
+
its(:conferences) { should eq %w(EASTERN WESTERN).map { |str| str.to_sym } }
|
27
|
+
its(:divisions) { should eq %w(SOUTHEAST ATLANTIC CENTRAL NORTHWEST SOUTHWEST PACIFIC).map { |str| str.to_sym } }
|
28
|
+
its(:count) { should eq 30 }
|
29
|
+
|
30
|
+
it { subject[:"583ec825-fb46-11e1-82cb-f4ce4684ea4c"].should eq warriors }
|
31
|
+
|
32
|
+
describe 'meta methods' do
|
33
|
+
it { should respond_to :EASTERN }
|
34
|
+
it { should respond_to :WESTERN }
|
35
|
+
it { should respond_to :eastern }
|
36
|
+
it { should respond_to :western }
|
37
|
+
it { should respond_to :ATLANTIC }
|
38
|
+
it { should respond_to :atlantic }
|
39
|
+
it { should respond_to :PACIFIC }
|
40
|
+
|
41
|
+
its(:EASTERN) { should be_a Array }
|
42
|
+
its(:WESTERN) { should be_a Array }
|
43
|
+
|
44
|
+
context '#EASTERN' do
|
45
|
+
subject { teams.EASTERN }
|
46
|
+
its(:count) { should eq 15 }
|
47
|
+
end
|
48
|
+
|
49
|
+
context '#eastern' do
|
50
|
+
subject { teams.eastern }
|
51
|
+
its(:count) { should eq 15 }
|
52
|
+
end
|
53
|
+
|
54
|
+
context '#WESTERN' do
|
55
|
+
subject { teams.WESTERN }
|
56
|
+
its(:count) { should eq 15 }
|
57
|
+
end
|
58
|
+
|
59
|
+
context '#western' do
|
60
|
+
subject { teams.western }
|
61
|
+
its(:count) { should eq 15 }
|
62
|
+
end
|
63
|
+
|
64
|
+
context '#pacific' do
|
65
|
+
subject { teams.pacific }
|
66
|
+
its(:count) { should eq 5 }
|
67
|
+
it { should include warriors }
|
68
|
+
end
|
69
|
+
|
70
|
+
context '#PACIFIC' do
|
71
|
+
subject { teams.PACIFIC }
|
72
|
+
its(:count) { should eq 5 }
|
73
|
+
it { should include warriors }
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SportsDataApi::Nba::Venue, vcr: {
|
4
|
+
cassette_name: 'sports_data_api_nba_venue',
|
5
|
+
record: :new_episodes,
|
6
|
+
match_requests_on: [:host, :path]
|
7
|
+
} do
|
8
|
+
let(:daily_schedule) do
|
9
|
+
SportsDataApi.set_access_level(:nba, 't')
|
10
|
+
SportsDataApi.set_key(:nba, api_key(:nba))
|
11
|
+
SportsDataApi::Nba.daily(2013, 12, 12)
|
12
|
+
end
|
13
|
+
context 'results from weekly schedule fetch' do
|
14
|
+
subject { daily_schedule.first.venue }
|
15
|
+
its(:id) { should eq '7a330bcd-ac0f-50ca-bc29-2460e5c476b3' }
|
16
|
+
its(:name) { should eq 'Barclays Center' }
|
17
|
+
its(:address) { should eq '620 Atlantic Avenue.' }
|
18
|
+
its(:city) { should eq 'Brooklyn' }
|
19
|
+
its(:state) { should eq 'NY' }
|
20
|
+
its(:zip) { '11217' }
|
21
|
+
its(:country) { should eq 'USA' }
|
22
|
+
its(:capacity) { should eq '18200' }
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SportsDataApi::Nba, vcr: {
|
4
|
+
cassette_name: 'sports_data_api_nba',
|
5
|
+
record: :new_episodes,
|
6
|
+
match_requests_on: [:uri]
|
7
|
+
} do
|
8
|
+
|
9
|
+
context 'invalid API key' do
|
10
|
+
before(:each) do
|
11
|
+
SportsDataApi.set_key(:nba, 'invalid_key')
|
12
|
+
SportsDataApi.set_access_level(:nba, 't')
|
13
|
+
end
|
14
|
+
describe '.schedule' do
|
15
|
+
it { expect { subject.schedule(2013, :REG) }.to raise_error(SportsDataApi::Exception) }
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'no response from the api' do
|
20
|
+
before(:each) { stub_request(:any, /api\.sportsdatallc\.org.*/).to_timeout }
|
21
|
+
describe '.schedule' do
|
22
|
+
it { expect { subject.schedule(2013, :REG) }.to raise_error(SportsDataApi::Exception) }
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context 'create valid URLs' do
|
27
|
+
let(:schedule_url) { 'http://api.sportsdatallc.org/nba-t3/games/2013/REG/schedule.xml' }
|
28
|
+
before(:each) do
|
29
|
+
SportsDataApi.set_key(:nba, 'invalid_key')
|
30
|
+
SportsDataApi.set_access_level(:nba, 't')
|
31
|
+
@schedule_xml = RestClient.get("#{schedule_url}?api_key=#{api_key(:nba)}")
|
32
|
+
end
|
33
|
+
describe '.schedule' do
|
34
|
+
it 'creates a valid Sports Data LLC url' do
|
35
|
+
params = { params: { api_key: SportsDataApi.key(:nba) } }
|
36
|
+
RestClient.should_receive(:get).with(schedule_url, params).and_return(@schedule_xml)
|
37
|
+
subject.schedule(2013, :REG)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SportsDataApi::Nfl::Broadcast, vcr: {
|
4
|
+
cassette_name: 'sports_data_api_nfl_broadcast',
|
5
|
+
record: :new_episodes,
|
6
|
+
match_requests_on: [:host, :path]
|
7
|
+
} do
|
8
|
+
let(:weekly_schedule) do
|
9
|
+
SportsDataApi.set_access_level(:nfl, 't')
|
10
|
+
SportsDataApi.set_key(:nfl, api_key(:nfl))
|
11
|
+
SportsDataApi::Nfl.weekly(2011, :PST, 4)
|
12
|
+
end
|
13
|
+
context 'results from weekly schedule fetch' do
|
14
|
+
subject { weekly_schedule.first.broadcast }
|
15
|
+
its(:network) { should eq 'NBC' }
|
16
|
+
its(:satellite) { should eq '' }
|
17
|
+
its(:internet) { should eq 'NFL Redzone' }
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,126 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SportsDataApi::Nfl::Game, vcr: {
|
4
|
+
cassette_name: 'sports_data_api_nfl_game',
|
5
|
+
record: :new_episodes,
|
6
|
+
match_requests_on: [:host, :path]
|
7
|
+
} do
|
8
|
+
let(:season) do
|
9
|
+
SportsDataApi.set_key(:nfl, api_key(:nfl))
|
10
|
+
SportsDataApi.set_access_level(:nfl, 't')
|
11
|
+
SportsDataApi::Nfl.schedule(2012, :REG)
|
12
|
+
end
|
13
|
+
let(:boxscore) do
|
14
|
+
SportsDataApi.set_key(:nfl, api_key(:nfl))
|
15
|
+
SportsDataApi.set_access_level(:nfl, 't')
|
16
|
+
SportsDataApi::Nfl.boxscore(2012, :REG, 9, 'IND', 'MIA')
|
17
|
+
end
|
18
|
+
let(:weekly_schedule) do
|
19
|
+
SportsDataApi.set_access_level(:nfl, 't')
|
20
|
+
SportsDataApi.set_key(:nfl, api_key(:nfl))
|
21
|
+
SportsDataApi::Nfl.weekly(2012, :PRE, 1)
|
22
|
+
end
|
23
|
+
context 'results from schedule fetch' do
|
24
|
+
subject { season.weeks.first.games.first }
|
25
|
+
it { should be_an_instance_of(SportsDataApi::Nfl::Game) }
|
26
|
+
its(:id) { should eq '8c0bce5a-7ca2-41e5-9838-d1b8c356ddc3' }
|
27
|
+
its(:scheduled) { should eq Time.new(2012, 9, 5, 19, 30, 00, '-05:00') }
|
28
|
+
its(:home) { should eq 'NYG' }
|
29
|
+
its(:away) { should eq 'DAL' }
|
30
|
+
its(:status) { should eq 'closed' }
|
31
|
+
its(:home_team) { should be_an_instance_of(SportsDataApi::Nfl::Team) }
|
32
|
+
its(:away_team) { should be_an_instance_of(SportsDataApi::Nfl::Team) }
|
33
|
+
its(:venue) { should be_an_instance_of(SportsDataApi::Nfl::Venue) }
|
34
|
+
its(:broadcast) { should be_an_instance_of(SportsDataApi::Nfl::Broadcast) }
|
35
|
+
its(:weather) { should be_an_instance_of(SportsDataApi::Nfl::Weather) }
|
36
|
+
it '#statistics' do
|
37
|
+
expect { subject.statistics }.to raise_error(NotImplementedError)
|
38
|
+
end
|
39
|
+
it '#summary' do
|
40
|
+
expect { subject.summary }.to raise_error(NotImplementedError)
|
41
|
+
end
|
42
|
+
it '#pbp' do
|
43
|
+
expect { subject.pbp }.to raise_error(NotImplementedError)
|
44
|
+
end
|
45
|
+
it '#roster' do
|
46
|
+
expect { subject.roster }.to raise_error(NotImplementedError)
|
47
|
+
end
|
48
|
+
it '#injuries' do
|
49
|
+
expect { subject.injuries }.to raise_error(NotImplementedError)
|
50
|
+
end
|
51
|
+
it '#depthchart' do
|
52
|
+
expect { subject.depthchart }.to raise_error(NotImplementedError)
|
53
|
+
end
|
54
|
+
its(:boxscore) { should be_an_instance_of(SportsDataApi::Nfl::Game) }
|
55
|
+
end
|
56
|
+
context 'results from boxscore fetch' do
|
57
|
+
subject { boxscore }
|
58
|
+
it { should be_an_instance_of(SportsDataApi::Nfl::Game) }
|
59
|
+
its(:id) { should eq '55d0b262-98ff-49fa-95c8-5ab8ec8cbd34' }
|
60
|
+
its(:scheduled) { should eq Time.new(2012, 11, 4, 18, 00, 00, '+00:00') }
|
61
|
+
its(:home) { should eq 'IND' }
|
62
|
+
its(:away) { should eq 'MIA' }
|
63
|
+
its(:status) { should eq 'closed' }
|
64
|
+
its(:quarter) { should eq 4 }
|
65
|
+
its(:clock) { should eq ':00' }
|
66
|
+
its(:home_team) { should be_an_instance_of(SportsDataApi::Nfl::Team) }
|
67
|
+
its(:away_team) { should be_an_instance_of(SportsDataApi::Nfl::Team) }
|
68
|
+
its(:venue) { should be_an_instance_of(SportsDataApi::Nfl::Venue) }
|
69
|
+
its(:broadcast) { should be_an_instance_of(SportsDataApi::Nfl::Broadcast) }
|
70
|
+
its(:weather) { should be_an_instance_of(SportsDataApi::Nfl::Weather) }
|
71
|
+
it '#statistics' do
|
72
|
+
expect { subject.statistics }.to raise_error(NotImplementedError)
|
73
|
+
end
|
74
|
+
it '#summary' do
|
75
|
+
expect { subject.summary }.to raise_error(NotImplementedError)
|
76
|
+
end
|
77
|
+
it '#pbp' do
|
78
|
+
expect { subject.pbp }.to raise_error(NotImplementedError)
|
79
|
+
end
|
80
|
+
it '#roster' do
|
81
|
+
expect { subject.roster }.to raise_error(NotImplementedError)
|
82
|
+
end
|
83
|
+
it '#injuries' do
|
84
|
+
expect { subject.injuries }.to raise_error(NotImplementedError)
|
85
|
+
end
|
86
|
+
it '#depthchart' do
|
87
|
+
expect { subject.depthchart }.to raise_error(NotImplementedError)
|
88
|
+
end
|
89
|
+
its(:boxscore) { should be_an_instance_of(SportsDataApi::Nfl::Game) }
|
90
|
+
end
|
91
|
+
context 'results from weekly schedule fetch' do
|
92
|
+
subject { weekly_schedule.first }
|
93
|
+
it { should be_an_instance_of(SportsDataApi::Nfl::Game) }
|
94
|
+
its(:id) { should eq '433d3222-e82d-4f14-97e2-4115579473f6' }
|
95
|
+
its(:scheduled) { should eq Time.new(2012, 8, 9, 23, 00, 00, '+00:00') }
|
96
|
+
its(:home) { should eq 'BUF' }
|
97
|
+
its(:away) { should eq 'WAS' }
|
98
|
+
its(:status) { should eq 'closed' }
|
99
|
+
its(:quarter) { should eq 0 }
|
100
|
+
its(:clock) { should eq nil }
|
101
|
+
its(:home_team) { should be_an_instance_of(SportsDataApi::Nfl::Team) }
|
102
|
+
its(:away_team) { should be_an_instance_of(SportsDataApi::Nfl::Team) }
|
103
|
+
its(:venue) { should be_an_instance_of(SportsDataApi::Nfl::Venue) }
|
104
|
+
its(:broadcast) { should be_an_instance_of(SportsDataApi::Nfl::Broadcast) }
|
105
|
+
its(:weather) { should be_an_instance_of(SportsDataApi::Nfl::Weather) }
|
106
|
+
it '#statistics' do
|
107
|
+
expect { subject.statistics }.to raise_error(NotImplementedError)
|
108
|
+
end
|
109
|
+
it '#summary' do
|
110
|
+
expect { subject.summary }.to raise_error(NotImplementedError)
|
111
|
+
end
|
112
|
+
it '#pbp' do
|
113
|
+
expect { subject.pbp }.to raise_error(NotImplementedError)
|
114
|
+
end
|
115
|
+
it '#roster' do
|
116
|
+
expect { subject.roster }.to raise_error(NotImplementedError)
|
117
|
+
end
|
118
|
+
it '#injuries' do
|
119
|
+
expect { subject.injuries }.to raise_error(NotImplementedError)
|
120
|
+
end
|
121
|
+
it '#depthchart' do
|
122
|
+
expect { subject.depthchart }.to raise_error(NotImplementedError)
|
123
|
+
end
|
124
|
+
its(:boxscore) { should be_an_instance_of(SportsDataApi::Nfl::Game) }
|
125
|
+
end
|
126
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SportsDataApi::Nfl::Games, vcr: {
|
4
|
+
cassette_name: 'sports_data_api_nfl_games',
|
5
|
+
record: :new_episodes,
|
6
|
+
match_requests_on: [:host, :path]
|
7
|
+
} do
|
8
|
+
context 'results from weekly schedule fetch' do
|
9
|
+
let(:games) do
|
10
|
+
SportsDataApi.set_access_level(:nfl, 't')
|
11
|
+
SportsDataApi.set_key(:nfl, api_key(:nfl))
|
12
|
+
SportsDataApi::Nfl.weekly(2012, :PRE, 1)
|
13
|
+
end
|
14
|
+
subject { games }
|
15
|
+
it { should be_an_instance_of(SportsDataApi::Nfl::Games) }
|
16
|
+
its(:year) { should eq 2012 }
|
17
|
+
its(:season) { should eq :PRE }
|
18
|
+
its(:week) { should eq 1 }
|
19
|
+
its(:count) { should eq 16 }
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SportsDataApi::Nfl::PlayerSeasonStats, vcr: {
|
4
|
+
cassette_name: 'sports_data_api_nfl_player_season_stats',
|
5
|
+
record: :new_episodes,
|
6
|
+
match_requests_on: [:host, :path]
|
7
|
+
} do
|
8
|
+
before do
|
9
|
+
SportsDataApi.set_key(:nfl, api_key(:nfl))
|
10
|
+
SportsDataApi.set_access_level(:nfl, 't')
|
11
|
+
end
|
12
|
+
let(:player_stats) { SportsDataApi::Nfl.player_season_stats("BUF", 2013, "REG") }
|
13
|
+
subject { player_stats }
|
14
|
+
describe 'meta methods' do
|
15
|
+
it { should respond_to :players }
|
16
|
+
it { subject.players.kind_of?(Array).should be true }
|
17
|
+
end
|
18
|
+
|
19
|
+
describe ".players" do
|
20
|
+
it "has key id" do
|
21
|
+
expect(subject.players.first.has_key?(:id)).to be true
|
22
|
+
end
|
23
|
+
|
24
|
+
it "has key stats" do
|
25
|
+
expect(subject.players.first.has_key?(:stats)).to be true
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SportsDataApi::Nfl::Season, vcr: {
|
4
|
+
cassette_name: 'sports_data_api_nfl_season',
|
5
|
+
record: :new_episodes,
|
6
|
+
match_requests_on: [:host, :path]
|
7
|
+
} do
|
8
|
+
subject { SportsDataApi::Nfl::Season }
|
9
|
+
describe '.season?' do
|
10
|
+
context :PRE do
|
11
|
+
it { SportsDataApi::Nfl::Season.valid?(:PRE).should be_true }
|
12
|
+
end
|
13
|
+
context :REG do
|
14
|
+
it { subject.valid?(:REG).should be_true }
|
15
|
+
end
|
16
|
+
context :PST do
|
17
|
+
it { subject.valid?(:PST).should be_true }
|
18
|
+
end
|
19
|
+
context :pre do
|
20
|
+
it { subject.valid?(:pre).should be_false }
|
21
|
+
end
|
22
|
+
context :reg do
|
23
|
+
it { subject.valid?(:reg).should be_false }
|
24
|
+
end
|
25
|
+
context :pst do
|
26
|
+
it { subject.valid?(:pst).should be_false }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
context 'results from schedule fetch' do
|
30
|
+
let(:season) do
|
31
|
+
SportsDataApi.set_access_level(:nfl, 't')
|
32
|
+
SportsDataApi.set_key(:nfl, api_key(:nfl))
|
33
|
+
SportsDataApi::Nfl.schedule(2012, :REG)
|
34
|
+
end
|
35
|
+
subject { season }
|
36
|
+
it { should be_an_instance_of(SportsDataApi::Nfl::Season) }
|
37
|
+
its(:year) { should eq 2012 }
|
38
|
+
its(:type) { should eq :REG }
|
39
|
+
its(:weeks) { should have(17).weeks }
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SportsDataApi::Nfl::TeamRoster, vcr: {
|
4
|
+
cassette_name: 'sports_data_api_nfl_team_roster',
|
5
|
+
record: :new_episodes,
|
6
|
+
match_requests_on: [:host, :path]
|
7
|
+
} do
|
8
|
+
before do
|
9
|
+
SportsDataApi.set_key(:nfl, api_key(:nfl))
|
10
|
+
SportsDataApi.set_access_level(:nfl, 't')
|
11
|
+
end
|
12
|
+
let(:roster) { SportsDataApi::Nfl.team_roster('MIA').players.first }
|
13
|
+
|
14
|
+
describe 'player' do
|
15
|
+
it "responds to id attribute" do
|
16
|
+
expect(roster.player.has_key?(:id)).to be true
|
17
|
+
expect(roster.player[:id]).not_to be nil
|
18
|
+
end
|
19
|
+
it "responds to position attribute" do
|
20
|
+
expect(roster.player.has_key?(:position)).to be true
|
21
|
+
expect(roster.player[:position]).not_to be nil
|
22
|
+
end
|
23
|
+
it "responds to status attribute" do
|
24
|
+
expect(roster.player.has_key?(:status)).to be true
|
25
|
+
expect(roster.player[:status]).not_to be nil
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SportsDataApi::Nfl::TeamSeasonStats, vcr: {
|
4
|
+
cassette_name: 'sports_data_api_nfl_team_season_stats',
|
5
|
+
record: :new_episodes,
|
6
|
+
match_requests_on: [:host, :path]
|
7
|
+
} do
|
8
|
+
before do
|
9
|
+
SportsDataApi.set_key(:nfl, api_key(:nfl))
|
10
|
+
SportsDataApi.set_access_level(:nfl, 't')
|
11
|
+
end
|
12
|
+
let(:team_stats) { SportsDataApi::Nfl.team_season_stats("BUF", 2013, "REG") }
|
13
|
+
subject { team_stats }
|
14
|
+
describe 'meta methods' do
|
15
|
+
it { should respond_to :id }
|
16
|
+
it { should respond_to :stats }
|
17
|
+
it { subject.stats.kind_of?(Array).should be true }
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SportsDataApi::Nfl::Team, vcr: {
|
4
|
+
cassette_name: 'sports_data_api_nfl_team',
|
5
|
+
record: :new_episodes,
|
6
|
+
match_requests_on: [:host, :path]
|
7
|
+
} do
|
8
|
+
let(:boxscore) do
|
9
|
+
SportsDataApi.set_key(:nfl, api_key(:nfl))
|
10
|
+
SportsDataApi.set_access_level(:nfl, 't')
|
11
|
+
SportsDataApi::Nfl.boxscore(2012, :REG, 9, 'IND', 'MIA')
|
12
|
+
end
|
13
|
+
describe 'home team' do
|
14
|
+
subject { boxscore.home_team }
|
15
|
+
it { should be_an_instance_of(SportsDataApi::Nfl::Team) }
|
16
|
+
its(:id) { should eq 'IND' }
|
17
|
+
its(:name) { should eq 'Colts' }
|
18
|
+
its(:market) { should eq 'Indianapolis' }
|
19
|
+
its(:remaining_challenges) { should eq 1 }
|
20
|
+
its(:remaining_timeouts) { should eq 2 }
|
21
|
+
its(:score) { should eq 23 }
|
22
|
+
its(:quarters) { should have(4).scores }
|
23
|
+
its(:quarters) { should eq [7, 6, 7, 3] }
|
24
|
+
end
|
25
|
+
describe 'away team' do
|
26
|
+
subject { boxscore.away_team }
|
27
|
+
it { should be_an_instance_of(SportsDataApi::Nfl::Team) }
|
28
|
+
its(:id) { should eq 'MIA' }
|
29
|
+
its(:name) { should eq 'Dolphins' }
|
30
|
+
its(:market) { should eq 'Miami' }
|
31
|
+
its(:remaining_challenges) { should eq 2 }
|
32
|
+
its(:remaining_timeouts) { should eq 2 }
|
33
|
+
its(:score) { should eq 20 }
|
34
|
+
its(:quarters) { should have(4).scores }
|
35
|
+
its(:quarters) { should eq [3, 14, 0, 3] }
|
36
|
+
end
|
37
|
+
describe 'eql' do
|
38
|
+
let(:url) { 'http://api.sportsdatallc.org/nfl-t1/teams/hierarchy.xml' }
|
39
|
+
|
40
|
+
let(:dolphins_xml) do
|
41
|
+
str = RestClient.get(url, params: { api_key: api_key(:nfl) }).to_s
|
42
|
+
xml = Nokogiri::XML(str)
|
43
|
+
xml.remove_namespaces!
|
44
|
+
xml.xpath('/league/conference/division/team[@id=\'MIA\']')
|
45
|
+
end
|
46
|
+
|
47
|
+
let(:dolphins1) { SportsDataApi::Nfl::Team.new(dolphins_xml) }
|
48
|
+
let(:dolphins2) { SportsDataApi::Nfl::Team.new(dolphins_xml) }
|
49
|
+
|
50
|
+
it { (dolphins1 == dolphins2).should be_true }
|
51
|
+
end
|
52
|
+
end
|