sports_data_api 0.11.6 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +1 -0
- data/lib/sports_data_api/nba/broadcast.rb +1 -9
- data/lib/sports_data_api/nba/game.rb +56 -37
- data/lib/sports_data_api/nba/games.rb +16 -13
- data/lib/sports_data_api/nba/player.rb +4 -16
- data/lib/sports_data_api/nba/season.rb +15 -10
- data/lib/sports_data_api/nba/stats.rb +6 -0
- data/lib/sports_data_api/nba/team.rb +29 -17
- data/lib/sports_data_api/nba/teams.rb +14 -65
- data/lib/sports_data_api/nba/venue.rb +10 -12
- data/lib/sports_data_api/nba.rb +10 -9
- data/lib/sports_data_api/version.rb +1 -1
- data/spec/cassettes/sports_data_api_nba.yml +66434 -112102
- data/spec/cassettes/sports_data_api_nba_broadcast.yml +67 -56
- data/spec/cassettes/sports_data_api_nba_game.yml +31079 -21019
- data/spec/cassettes/sports_data_api_nba_games.yml +112 -68
- data/spec/cassettes/sports_data_api_nba_league_hierarchy.yml +553 -469
- data/spec/cassettes/sports_data_api_nba_player.yml +1173 -212
- data/spec/cassettes/sports_data_api_nba_season.yml +18253 -18195
- data/spec/cassettes/sports_data_api_nba_team.yml +1429 -1284
- data/spec/cassettes/sports_data_api_nba_venue.yml +438 -56
- data/spec/lib/sports_data_api/nba/broadcast_spec.rb +8 -4
- data/spec/lib/sports_data_api/nba/game_spec.rb +32 -41
- data/spec/lib/sports_data_api/nba/games_spec.rb +10 -6
- data/spec/lib/sports_data_api/nba/player_spec.rb +86 -56
- data/spec/lib/sports_data_api/nba/season_spec.rb +4 -3
- data/spec/lib/sports_data_api/nba/team_spec.rb +44 -48
- data/spec/lib/sports_data_api/nba/teams_spec.rb +12 -63
- data/spec/lib/sports_data_api/nba/venue_spec.rb +23 -6
- data/spec/lib/sports_data_api/nba_spec.rb +97 -15
- metadata +4 -3
@@ -5,45 +5,35 @@ describe SportsDataApi::Nba::Game, vcr: {
|
|
5
5
|
record: :new_episodes,
|
6
6
|
match_requests_on: [:host, :path]
|
7
7
|
} do
|
8
|
-
|
8
|
+
before do
|
9
9
|
SportsDataApi.set_key(:nba, api_key(:nba))
|
10
|
-
SportsDataApi.set_access_level(:nba, '
|
11
|
-
SportsDataApi::Nba.schedule(2013, :REG)
|
10
|
+
SportsDataApi.set_access_level(:nba, 'trial')
|
12
11
|
end
|
13
|
-
|
14
|
-
|
15
|
-
SportsDataApi.
|
16
|
-
SportsDataApi::Nba.game_summary('e1dcf692-330d-46d3-8add-a241b388fbe2')
|
17
|
-
end
|
18
|
-
let(:daily_schedule) do
|
19
|
-
SportsDataApi.set_access_level(:nba, 't')
|
20
|
-
SportsDataApi.set_key(:nba, api_key(:nba))
|
21
|
-
SportsDataApi::Nba.daily(2013, 12, 12)
|
22
|
-
end
|
23
|
-
context 'results from schedule fetch' do
|
12
|
+
|
13
|
+
context 'when from schedule' do
|
14
|
+
let(:season) { SportsDataApi::Nba.schedule(2017, :REG) }
|
24
15
|
subject { season.games.first }
|
16
|
+
|
25
17
|
it { should be_an_instance_of(SportsDataApi::Nba::Game) }
|
26
|
-
its(:id) { should eq '
|
27
|
-
its(:scheduled) { should eq Time.new(
|
28
|
-
its(:
|
29
|
-
its(:
|
30
|
-
its(:home_team_id) { should eq '583ec7cd-fb46-11e1-82cb-f4ce4684ea4c' }
|
31
|
-
its(:away_team_id) { should eq '583ed157-fb46-11e1-82cb-f4ce4684ea4c' }
|
18
|
+
its(:id) { should eq '4c1b49cd-e114-4936-8a81-10b238cc5d45' }
|
19
|
+
its(:scheduled) { should eq Time.new(2017, 10, 18, 0, 0, 0, '+00:00') }
|
20
|
+
its(:home_team_id) { should eq '583ec773-fb46-11e1-82cb-f4ce4684ea4c' }
|
21
|
+
its(:away_team_id) { should eq '583eccfa-fb46-11e1-82cb-f4ce4684ea4c' }
|
32
22
|
its(:status) { should eq 'closed' }
|
33
23
|
its(:home_team) { should be_an_instance_of(SportsDataApi::Nba::Team) }
|
34
24
|
its(:away_team) { should be_an_instance_of(SportsDataApi::Nba::Team) }
|
35
25
|
describe 'parsing team info' do
|
36
26
|
it 'home team should have an name' do
|
37
|
-
subject.home_team.name.should eq '
|
27
|
+
subject.home_team.name.should eq 'Cleveland Cavaliers'
|
38
28
|
end
|
39
29
|
it 'away team should have an name' do
|
40
|
-
subject.away_team.name.should eq '
|
30
|
+
subject.away_team.name.should eq 'Boston Celtics'
|
41
31
|
end
|
42
32
|
it 'home team should have an alias' do
|
43
|
-
subject.home_team.alias.should eq '
|
33
|
+
subject.home_team.alias.should eq 'CLE'
|
44
34
|
end
|
45
35
|
it 'away team should have an alias' do
|
46
|
-
subject.away_team.alias.should eq '
|
36
|
+
subject.away_team.alias.should eq 'BOS'
|
47
37
|
end
|
48
38
|
end
|
49
39
|
its(:venue) { should be_an_instance_of(SportsDataApi::Nba::Venue) }
|
@@ -56,13 +46,13 @@ describe SportsDataApi::Nba::Game, vcr: {
|
|
56
46
|
expect { subject.pbp }.to raise_error(NotImplementedError)
|
57
47
|
end
|
58
48
|
end
|
59
|
-
|
60
|
-
|
49
|
+
|
50
|
+
context 'when from game_summary' do
|
51
|
+
subject { SportsDataApi::Nba.game_summary('e1dcf692-330d-46d3-8add-a241b388fbe2') }
|
52
|
+
|
61
53
|
it { should be_an_instance_of(SportsDataApi::Nba::Game) }
|
62
54
|
its(:id) { should eq 'e1dcf692-330d-46d3-8add-a241b388fbe2' }
|
63
55
|
its(:scheduled) { should eq Time.new(2013, 10, 30, 22, 30, 00, '-04:00') }
|
64
|
-
its(:home) { should eq '583ec825-fb46-11e1-82cb-f4ce4684ea4c' }
|
65
|
-
its(:away) { should eq '583ecae2-fb46-11e1-82cb-f4ce4684ea4c' }
|
66
56
|
its(:status) { should eq 'closed' }
|
67
57
|
its(:quarter) { should eq 4 }
|
68
58
|
its(:clock) { should eq '00:00' }
|
@@ -83,7 +73,7 @@ describe SportsDataApi::Nba::Game, vcr: {
|
|
83
73
|
end
|
84
74
|
end
|
85
75
|
its(:venue) { should be_an_instance_of(SportsDataApi::Nba::Venue) }
|
86
|
-
its(:broadcast) { should
|
76
|
+
its(:broadcast) { should be_nil }
|
87
77
|
its(:summary) { should be_an_instance_of(SportsDataApi::Nba::Game) }
|
88
78
|
it '#boxscore' do
|
89
79
|
expect { subject.boxscore }.to raise_error(NotImplementedError)
|
@@ -92,15 +82,16 @@ describe SportsDataApi::Nba::Game, vcr: {
|
|
92
82
|
expect { subject.pbp }.to raise_error(NotImplementedError)
|
93
83
|
end
|
94
84
|
end
|
95
|
-
|
96
|
-
|
85
|
+
|
86
|
+
context 'when from daily' do
|
87
|
+
let(:daily) { SportsDataApi::Nba.daily(2018, 1, 1) }
|
88
|
+
subject { daily.find { |g| g.id == '3e4d96b7-ac9b-4ad9-889d-08e894d07e59' } }
|
89
|
+
|
97
90
|
it { should be_an_instance_of(SportsDataApi::Nba::Game) }
|
98
|
-
its(:id) { should eq '
|
99
|
-
its(:scheduled) { should eq Time.new(
|
100
|
-
its(:
|
101
|
-
its(:
|
102
|
-
its(:home_team_id) { should eq '583ec9d6-fb46-11e1-82cb-f4ce4684ea4c' }
|
103
|
-
its(:away_team_id) { should eq '583ecdfb-fb46-11e1-82cb-f4ce4684ea4c' }
|
91
|
+
its(:id) { should eq '3e4d96b7-ac9b-4ad9-889d-08e894d07e59' }
|
92
|
+
its(:scheduled) { should eq Time.new(2018, 1, 2, 00, 30, 00, '+00:00') }
|
93
|
+
its(:home_team_id) { should eq '583ecda6-fb46-11e1-82cb-f4ce4684ea4c' }
|
94
|
+
its(:away_team_id) { should eq '583ecefd-fb46-11e1-82cb-f4ce4684ea4c' }
|
104
95
|
its(:status) { should eq 'closed' }
|
105
96
|
its(:quarter) { should eq nil }
|
106
97
|
its(:clock) { should eq nil }
|
@@ -108,16 +99,16 @@ describe SportsDataApi::Nba::Game, vcr: {
|
|
108
99
|
its(:away_team) { should be_an_instance_of(SportsDataApi::Nba::Team) }
|
109
100
|
describe 'parsing team info' do
|
110
101
|
it 'home team should have an name' do
|
111
|
-
subject.home_team.name.should eq '
|
102
|
+
subject.home_team.name.should eq 'Toronto Raptors'
|
112
103
|
end
|
113
104
|
it 'away team should have an name' do
|
114
|
-
subject.away_team.name.should eq '
|
105
|
+
subject.away_team.name.should eq 'Milwaukee Bucks'
|
115
106
|
end
|
116
107
|
it 'home team should have an alias' do
|
117
|
-
subject.home_team.alias.should eq '
|
108
|
+
subject.home_team.alias.should eq 'TOR'
|
118
109
|
end
|
119
110
|
it 'away team should have an alias' do
|
120
|
-
subject.away_team.alias.should eq '
|
111
|
+
subject.away_team.alias.should eq 'MIL'
|
121
112
|
end
|
122
113
|
end
|
123
114
|
its(:venue) { should be_an_instance_of(SportsDataApi::Nba::Venue) }
|
@@ -6,14 +6,18 @@ describe SportsDataApi::Nba::Games, vcr: {
|
|
6
6
|
match_requests_on: [:host, :path]
|
7
7
|
} do
|
8
8
|
context 'results from daily schedule fetch' do
|
9
|
-
|
10
|
-
SportsDataApi.set_access_level(:nba, '
|
9
|
+
before do
|
10
|
+
SportsDataApi.set_access_level(:nba, 'trial')
|
11
11
|
SportsDataApi.set_key(:nba, api_key(:nba))
|
12
|
-
SportsDataApi::Nba.daily(2013, 12, 12)
|
13
12
|
end
|
14
|
-
subject {
|
13
|
+
subject { SportsDataApi::Nba.daily(2018, 1, 1) }
|
15
14
|
it { should be_an_instance_of(SportsDataApi::Nba::Games) }
|
16
|
-
its(:date) { should eq
|
17
|
-
its(:count) { should eq
|
15
|
+
its(:date) { should eq '2018-01-01' }
|
16
|
+
its(:count) { should eq 4 }
|
17
|
+
|
18
|
+
it 'is enumerable' do
|
19
|
+
games = subject.map { |g| g.id }
|
20
|
+
expect(games).to match_array(%w[3e4d96b7-ac9b-4ad9-889d-08e894d07e59 97f525d9-0aee-4297-9b3c-b474166d8c79 c0f6a26d-8cdc-4eaa-be07-d1eb16324b45 effe3c21-395e-42c8-a036-1e14d6b332b9])
|
21
|
+
end
|
18
22
|
end
|
19
23
|
end
|
@@ -7,66 +7,96 @@ describe SportsDataApi::Nba::Player, vcr: {
|
|
7
7
|
} do
|
8
8
|
before do
|
9
9
|
SportsDataApi.set_key(:nba, api_key(:nba))
|
10
|
-
SportsDataApi.set_access_level(:nba, '
|
10
|
+
SportsDataApi.set_access_level(:nba, 'trial')
|
11
11
|
end
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
expect(
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
expect(
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
expect(
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
expect(
|
34
|
-
|
35
|
-
|
36
|
-
it 'should have an abbr_name' do
|
37
|
-
expect(subject[:abbr_name]).to eql 'F.Ezeli'
|
38
|
-
end
|
39
|
-
|
40
|
-
it 'should have a height' do
|
41
|
-
expect(subject[:height]).to eql '83'
|
42
|
-
end
|
43
|
-
|
44
|
-
it 'should have a weight' do
|
45
|
-
expect(subject[:weight]).to eql '255'
|
46
|
-
end
|
47
|
-
|
48
|
-
it 'should have a position' do
|
49
|
-
expect(subject[:position]).to eql 'C'
|
50
|
-
end
|
51
|
-
|
52
|
-
it 'should have a primary_position' do
|
53
|
-
expect(subject[:primary_position]).to eql 'C'
|
54
|
-
end
|
55
|
-
|
56
|
-
it 'should have a jersey_number' do
|
57
|
-
expect(subject[:jersey_number]).to eql '31'
|
58
|
-
end
|
59
|
-
|
60
|
-
it 'should have an experience' do
|
61
|
-
expect(subject[:experience]).to eql '1'
|
12
|
+
context 'when from team_roster' do
|
13
|
+
let(:roster) { SportsDataApi::Nba.team_roster('583ec825-fb46-11e1-82cb-f4ce4684ea4c') }
|
14
|
+
let(:players) { roster.players }
|
15
|
+
it 'parses out the data' do
|
16
|
+
player = players.find do |x|
|
17
|
+
x.player[:id] == '8ec91366-faea-4196-bbfd-b8fab7434795'
|
18
|
+
end
|
19
|
+
expect(player[:status]).to eq 'ACT'
|
20
|
+
expect(player[:full_name]).to eq 'Stephen Curry'
|
21
|
+
expect(player[:first_name]).to eq 'Stephen'
|
22
|
+
expect(player[:last_name]).to eq 'Curry'
|
23
|
+
expect(player[:abbr_name]).to eq 'S.Curry'
|
24
|
+
expect(player[:height]).to eq 75
|
25
|
+
expect(player[:weight]).to eq 190
|
26
|
+
expect(player[:position]).to eq 'G'
|
27
|
+
expect(player[:primary_position]).to eq 'PG'
|
28
|
+
expect(player[:jersey_number]).to eq '30'
|
29
|
+
expect(player[:experience]).to eq '8'
|
30
|
+
expect(player[:college]).to eq 'Davidson'
|
31
|
+
expect(player[:birth_place]).to eq 'Akron, OH, USA'
|
32
|
+
expect(player[:birthdate]).to eq '1988-03-14'
|
33
|
+
expect(player[:updated]).to eq '2017-10-17T19:37:08+00:00'
|
34
|
+
expect(player[:reference]).to eq '201939'
|
35
|
+
expect(player.stats).to be_nil
|
62
36
|
end
|
37
|
+
end
|
63
38
|
|
64
|
-
|
65
|
-
|
66
|
-
|
39
|
+
context 'when from .game_summary' do
|
40
|
+
let(:game_summary) { SportsDataApi::Nba.game_summary('e1dcf692-330d-46d3-8add-a241b388fbe2') }
|
41
|
+
let(:team) { game_summary.home_team }
|
42
|
+
let(:players) { team.players }
|
67
43
|
|
68
|
-
it '
|
69
|
-
|
44
|
+
it 'parses out the data' do
|
45
|
+
player = players.find do |x|
|
46
|
+
x.player[:id] == '8ec91366-faea-4196-bbfd-b8fab7434795'
|
47
|
+
end
|
48
|
+
expect(player[:status]).to be_nil
|
49
|
+
expect(player[:full_name]).to eq 'Stephen Curry'
|
50
|
+
expect(player[:first_name]).to eq 'Stephen'
|
51
|
+
expect(player[:last_name]).to eq 'Curry'
|
52
|
+
expect(player[:position]).to eq 'G'
|
53
|
+
expect(player[:primary_position]).to eq 'PG'
|
54
|
+
expect(player[:jersey_number]).to eq '30'
|
55
|
+
expect(player[:starter]).to eq true
|
56
|
+
expect(player[:active]).to eq true
|
57
|
+
expect(player.stats).to be_a SportsDataApi::Nba::Stats
|
58
|
+
expect(player.stats[:minutes]).to eq "23:57"
|
59
|
+
expect(player.stats[:field_goals_made]).to eq 4
|
60
|
+
expect(player.stats[:field_goals_att]).to eq 10
|
61
|
+
expect(player.stats[:field_goals_pct]).to eq 40.0
|
62
|
+
expect(player.stats[:three_points_made]).to eq 2
|
63
|
+
expect(player.stats[:three_points_att]).to eq 5
|
64
|
+
expect(player.stats[:three_points_pct]).to eq 40.0
|
65
|
+
expect(player.stats[:two_points_made]).to eq 2
|
66
|
+
expect(player.stats[:two_points_att]).to eq 5
|
67
|
+
expect(player.stats[:two_points_pct]).to eq 40.0
|
68
|
+
expect(player.stats[:blocked_att]).to eq 0
|
69
|
+
expect(player.stats[:free_throws_made]).to eq 0
|
70
|
+
expect(player.stats[:free_throws_att]).to eq 0
|
71
|
+
expect(player.stats[:free_throws_pct]).to eq 0.0
|
72
|
+
expect(player.stats[:offensive_rebounds]).to eq 0
|
73
|
+
expect(player.stats[:defensive_rebounds]).to eq 4
|
74
|
+
expect(player.stats[:rebounds]).to eq 4
|
75
|
+
expect(player.stats[:assists]).to eq 6
|
76
|
+
expect(player.stats[:turnovers]).to eq 1
|
77
|
+
expect(player.stats[:steals]).to eq 1
|
78
|
+
expect(player.stats[:blocks]).to eq 0
|
79
|
+
expect(player.stats[:assists_turnover_ratio]).to eq 6.0
|
80
|
+
expect(player.stats[:personal_fouls]).to eq 4
|
81
|
+
expect(player.stats[:tech_fouls]).to eq 0
|
82
|
+
expect(player.stats[:flagrant_fouls]).to eq 0
|
83
|
+
expect(player.stats[:pls_min]).to eq 28
|
84
|
+
expect(player.stats[:points]).to eq 10
|
85
|
+
expect(player.stats[:double_double]).to eq false
|
86
|
+
expect(player.stats[:triple_double]).to eq false
|
87
|
+
expect(player.stats[:effective_fg_pct]).to eq 50.0
|
88
|
+
expect(player.stats[:efficiency]).to eq 10
|
89
|
+
expect(player.stats[:efficiency_game_score]).to eq 8.4
|
90
|
+
expect(player.stats[:points_in_paint]).to eq 0
|
91
|
+
expect(player.stats[:points_in_paint_att]).to eq 0
|
92
|
+
expect(player.stats[:points_in_paint_made]).to eq 0
|
93
|
+
expect(player.stats[:points_in_paint_pct]).to eq 0.0
|
94
|
+
expect(player.stats[:true_shooting_att]).to eq 10.0
|
95
|
+
expect(player.stats[:true_shooting_pct]).to eq 50.0
|
96
|
+
expect(player.stats[:fouls_drawn]).to eq 0
|
97
|
+
expect(player.stats[:offensive_fouls]).to eq 0
|
98
|
+
expect(player.stats[:points_off_turnovers]).to eq 0
|
99
|
+
expect(player.stats[:second_chance_pts]).to eq 0
|
70
100
|
end
|
71
101
|
end
|
72
102
|
end
|
@@ -28,13 +28,14 @@ describe SportsDataApi::Nba::Season, vcr: {
|
|
28
28
|
end
|
29
29
|
context 'results from schedule fetch' do
|
30
30
|
let(:season) do
|
31
|
-
SportsDataApi.set_access_level(:nba, '
|
31
|
+
SportsDataApi.set_access_level(:nba, 'trial')
|
32
32
|
SportsDataApi.set_key(:nba, api_key(:nba))
|
33
|
-
SportsDataApi::Nba.schedule(
|
33
|
+
SportsDataApi::Nba.schedule(2017, :reg)
|
34
34
|
end
|
35
35
|
subject { season }
|
36
36
|
it { should be_an_instance_of(SportsDataApi::Nba::Season) }
|
37
|
-
its(:
|
37
|
+
its(:id) { should eq '7dcb5184-ab33-49fe-bd18-c4ca2b1cfc08' }
|
38
|
+
its(:year) { should eq 2017 }
|
38
39
|
its(:type) { should eq :REG }
|
39
40
|
its(:games) { should have(1230).games }
|
40
41
|
end
|
@@ -5,27 +5,17 @@ describe SportsDataApi::Nba::Team, vcr: {
|
|
5
5
|
record: :new_episodes,
|
6
6
|
match_requests_on: [:host, :path]
|
7
7
|
} do
|
8
|
-
|
8
|
+
before do
|
9
9
|
SportsDataApi.set_key(:nba, api_key(:nba))
|
10
|
-
SportsDataApi.set_access_level(:nba, '
|
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')
|
10
|
+
SportsDataApi.set_access_level(:nba, 'trial')
|
22
11
|
end
|
23
12
|
|
24
13
|
context 'results from teams fetch' do
|
25
|
-
|
14
|
+
let(:teams) { SportsDataApi::Nba.teams }
|
15
|
+
subject { teams.find { |t| t.alias == 'WAS' } }
|
16
|
+
|
26
17
|
it { should be_an_instance_of(SportsDataApi::Nba::Team) }
|
27
18
|
its(:id) { should eq "583ec8d4-fb46-11e1-82cb-f4ce4684ea4c" }
|
28
|
-
its(:alias) { should eq 'WAS' }
|
29
19
|
its(:conference) { should eq 'EASTERN' }
|
30
20
|
its(:division) { should eq 'SOUTHEAST' }
|
31
21
|
its(:market) { should eq 'Washington' }
|
@@ -33,8 +23,11 @@ describe SportsDataApi::Nba::Team, vcr: {
|
|
33
23
|
its(:players) { should eq [] }
|
34
24
|
its(:points) { should be_nil }
|
35
25
|
end
|
26
|
+
|
36
27
|
context 'results from team roster fetch' do
|
28
|
+
let(:roster) { SportsDataApi::Nba.team_roster('583ec825-fb46-11e1-82cb-f4ce4684ea4c') }
|
37
29
|
subject { roster }
|
30
|
+
|
38
31
|
it { should be_an_instance_of(SportsDataApi::Nba::Team) }
|
39
32
|
its(:id) { should eq "583ec825-fb46-11e1-82cb-f4ce4684ea4c" }
|
40
33
|
its(:alias) { should eq 'GSW' }
|
@@ -44,11 +37,14 @@ describe SportsDataApi::Nba::Team, vcr: {
|
|
44
37
|
its(:points) { should be_nil }
|
45
38
|
context 'players' do
|
46
39
|
subject { roster.players }
|
47
|
-
its(:count) { should eq
|
40
|
+
its(:count) { should eq 17 }
|
48
41
|
end
|
49
42
|
end
|
43
|
+
|
50
44
|
context 'results from game_summary fetch' do
|
45
|
+
let(:game_summary) { SportsDataApi::Nba.game_summary('e1dcf692-330d-46d3-8add-a241b388fbe2') }
|
51
46
|
subject { game_summary.home_team }
|
47
|
+
|
52
48
|
it { should be_an_instance_of(SportsDataApi::Nba::Team) }
|
53
49
|
its(:id) { should eq '583ec825-fb46-11e1-82cb-f4ce4684ea4c' }
|
54
50
|
its(:market) { should eq 'Golden State' }
|
@@ -58,7 +54,7 @@ describe SportsDataApi::Nba::Team, vcr: {
|
|
58
54
|
its(:conference) { should be_nil }
|
59
55
|
its(:division) { should be_nil }
|
60
56
|
its(:players) { should be_an_instance_of(Array) }
|
61
|
-
|
57
|
+
|
62
58
|
context 'players' do
|
63
59
|
subject { game_summary.home_team.players }
|
64
60
|
its(:count) { should eq 14 }
|
@@ -89,95 +85,95 @@ describe SportsDataApi::Nba::Team, vcr: {
|
|
89
85
|
expect(subject.player[:jersey_number]).to eq "5"
|
90
86
|
end
|
91
87
|
it 'should have a played' do
|
92
|
-
expect(subject.player[:played]).to eq
|
88
|
+
expect(subject.player[:played]).to eq true
|
93
89
|
end
|
94
90
|
it 'should have an active' do
|
95
|
-
expect(subject.player[:active]).to eq
|
91
|
+
expect(subject.player[:active]).to eq true
|
96
92
|
end
|
97
|
-
its(:stats){ should be_an_instance_of(SportsDataApi::Stats) }
|
93
|
+
its(:stats){ should be_an_instance_of(SportsDataApi::Nba::Stats) }
|
98
94
|
|
99
95
|
context 'stats' do
|
100
|
-
subject { game_summary.home_team.players.first.stats
|
96
|
+
subject { game_summary.home_team.players.first.stats }
|
101
97
|
it 'should have minutes' do
|
102
|
-
expect(subject[:minutes]).to
|
98
|
+
expect(subject[:minutes]).to eq '19:45'
|
103
99
|
end
|
104
100
|
it 'should have field_goals_made' do
|
105
|
-
expect(subject[:field_goals_made]).to
|
101
|
+
expect(subject[:field_goals_made]).to eq 2
|
106
102
|
end
|
107
103
|
it 'should have field_goals_made' do
|
108
|
-
expect(subject[:field_goals_att]).to
|
104
|
+
expect(subject[:field_goals_att]).to eq 10
|
109
105
|
end
|
110
106
|
it 'should have field_goals_pct' do
|
111
|
-
expect(subject[:field_goals_pct]).to
|
107
|
+
expect(subject[:field_goals_pct]).to eq 20.0
|
112
108
|
end
|
113
109
|
it 'should have two_points_made' do
|
114
|
-
expect(subject[:two_points_made]).to
|
110
|
+
expect(subject[:two_points_made]).to eq 1
|
115
111
|
end
|
116
112
|
it 'should have two_points_att' do
|
117
|
-
expect(subject[:two_points_att]).to
|
113
|
+
expect(subject[:two_points_att]).to eq 8
|
118
114
|
end
|
119
115
|
it 'should have two_points_pct' do
|
120
|
-
expect(subject[:two_points_pct]).to
|
116
|
+
expect(subject[:two_points_pct]).to eq 12.5
|
121
117
|
end
|
122
118
|
it 'should have three_points_made' do
|
123
|
-
expect(subject[:three_points_made]).to
|
119
|
+
expect(subject[:three_points_made]).to eq 1
|
124
120
|
end
|
125
121
|
it 'should have three_points_att' do
|
126
|
-
expect(subject[:three_points_att]).to
|
122
|
+
expect(subject[:three_points_att]).to eq 2
|
127
123
|
end
|
128
124
|
it 'should have three_points_pct' do
|
129
|
-
expect(subject[:three_points_pct]).to
|
125
|
+
expect(subject[:three_points_pct]).to eq 50.0
|
130
126
|
end
|
131
127
|
it 'should have blocked_att' do
|
132
|
-
expect(subject[:blocked_att]).to
|
128
|
+
expect(subject[:blocked_att]).to eq 2
|
133
129
|
end
|
134
130
|
it 'should have free_throws_made' do
|
135
|
-
expect(subject[:free_throws_made]).to
|
131
|
+
expect(subject[:free_throws_made]).to eq 2
|
136
132
|
end
|
137
133
|
it 'should have free_throws_att' do
|
138
|
-
expect(subject[:free_throws_att]).to
|
134
|
+
expect(subject[:free_throws_att]).to eq 2
|
139
135
|
end
|
140
136
|
it 'should have free_throws_pct' do
|
141
|
-
expect(subject[:free_throws_pct]).to
|
137
|
+
expect(subject[:free_throws_pct]).to eq 100.0
|
142
138
|
end
|
143
139
|
it 'should have offensive_rebounds' do
|
144
|
-
expect(subject[:offensive_rebounds]).to
|
140
|
+
expect(subject[:offensive_rebounds]).to eq 1
|
145
141
|
end
|
146
142
|
it 'should have defensive_rebounds' do
|
147
|
-
expect(subject[:defensive_rebounds]).to
|
143
|
+
expect(subject[:defensive_rebounds]).to eq 7
|
148
144
|
end
|
149
145
|
it 'should have rebounds' do
|
150
|
-
expect(subject[:rebounds]).to
|
146
|
+
expect(subject[:rebounds]).to eq 8
|
151
147
|
end
|
152
148
|
it 'should have assists' do
|
153
|
-
expect(subject[:assists]).to
|
149
|
+
expect(subject[:assists]).to eq 3
|
154
150
|
end
|
155
151
|
it 'should have turnovers' do
|
156
|
-
expect(subject[:turnovers]).to
|
152
|
+
expect(subject[:turnovers]).to eq 0
|
157
153
|
end
|
158
154
|
it 'should have steals' do
|
159
|
-
expect(subject[:steals]).to
|
155
|
+
expect(subject[:steals]).to eq 1
|
160
156
|
end
|
161
157
|
it 'should have blocks' do
|
162
|
-
expect(subject[:blocks]).to
|
158
|
+
expect(subject[:blocks]).to eq 0
|
163
159
|
end
|
164
160
|
it 'should have assists_turnover_ratio' do
|
165
|
-
expect(subject[:assists_turnover_ratio]).to
|
161
|
+
expect(subject[:assists_turnover_ratio]).to eq 0
|
166
162
|
end
|
167
163
|
it 'should have personal_fouls' do
|
168
|
-
expect(subject[:personal_fouls]).to
|
164
|
+
expect(subject[:personal_fouls]).to eq 2
|
169
165
|
end
|
170
166
|
it 'should have tech_fouls' do
|
171
|
-
expect(subject[:tech_fouls]).to
|
167
|
+
expect(subject[:tech_fouls]).to eq 0
|
172
168
|
end
|
173
169
|
it 'should have flagrant_fouls' do
|
174
|
-
expect(subject[:flagrant_fouls]).to
|
170
|
+
expect(subject[:flagrant_fouls]).to eq 0
|
175
171
|
end
|
176
172
|
it 'should have pls_min' do
|
177
|
-
expect(subject[:pls_min]).to
|
173
|
+
expect(subject[:pls_min]).to eq 3
|
178
174
|
end
|
179
175
|
it 'should have points' do
|
180
|
-
expect(subject[:points]).to
|
176
|
+
expect(subject[:points]).to eq 7
|
181
177
|
end
|
182
178
|
end
|
183
179
|
end
|
@@ -5,72 +5,21 @@ describe SportsDataApi::Nba::Teams, vcr: {
|
|
5
5
|
record: :new_episodes,
|
6
6
|
match_requests_on: [:host, :path]
|
7
7
|
} do
|
8
|
-
|
8
|
+
before do
|
9
9
|
SportsDataApi.set_key(:nba, api_key(:nba))
|
10
|
-
SportsDataApi.set_access_level(:nba, '
|
11
|
-
SportsDataApi::Nba.teams
|
10
|
+
SportsDataApi.set_access_level(:nba, 'trial')
|
12
11
|
end
|
12
|
+
subject { SportsDataApi::Nba.teams }
|
13
13
|
|
14
|
-
let(:url) { 'https://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
14
|
its(:count) { should eq 30 }
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
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
|
15
|
+
it 'parses outs the specific team' do
|
16
|
+
pistons = subject.find { |t| t.name == 'Pistons' }
|
17
|
+
expect(pistons.id).to eq '583ec928-fb46-11e1-82cb-f4ce4684ea4c'
|
18
|
+
expect(pistons.market).to eq 'Detroit'
|
19
|
+
expect(pistons.alias).to eq 'DET'
|
20
|
+
expect(pistons.conference).to eq 'EASTERN'
|
21
|
+
expect(pistons.division).to eq 'CENTRAL'
|
22
|
+
expect(pistons.venue).to be_a SportsDataApi::Nba::Venue
|
23
|
+
expect(pistons.players).to be_empty
|
75
24
|
end
|
76
25
|
end
|
@@ -5,20 +5,37 @@ describe SportsDataApi::Nba::Venue, vcr: {
|
|
5
5
|
record: :new_episodes,
|
6
6
|
match_requests_on: [:host, :path]
|
7
7
|
} do
|
8
|
-
|
9
|
-
SportsDataApi.set_access_level(:nba, '
|
8
|
+
before do
|
9
|
+
SportsDataApi.set_access_level(:nba, 'trial')
|
10
10
|
SportsDataApi.set_key(:nba, api_key(:nba))
|
11
|
-
SportsDataApi::Nba.daily(2013, 12, 12)
|
12
11
|
end
|
12
|
+
|
13
13
|
context 'results from weekly schedule fetch' do
|
14
|
-
|
14
|
+
let(:daily) { SportsDataApi::Nba.daily(2013, 12, 12) }
|
15
|
+
subject { daily.first.venue }
|
16
|
+
|
17
|
+
its(:id) { should eq '7a330bcd-ac0f-50ca-bc29-2460e5c476b3' }
|
18
|
+
its(:name) { should eq 'Barclays Center' }
|
19
|
+
its(:address) { should eq '620 Atlantic Avenue.' }
|
20
|
+
its(:city) { should eq 'Brooklyn' }
|
21
|
+
its(:state) { should eq 'NY' }
|
22
|
+
its(:zip) { should eq '11217' }
|
23
|
+
its(:country) { should eq 'USA' }
|
24
|
+
its(:capacity) { should eq 17732 }
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'from teams' do
|
28
|
+
let(:teams) { SportsDataApi::Nba.teams }
|
29
|
+
let(:nets) { teams.find { |t| t.name == 'Nets' } }
|
30
|
+
subject { nets.venue }
|
31
|
+
|
15
32
|
its(:id) { should eq '7a330bcd-ac0f-50ca-bc29-2460e5c476b3' }
|
16
33
|
its(:name) { should eq 'Barclays Center' }
|
17
34
|
its(:address) { should eq '620 Atlantic Avenue.' }
|
18
35
|
its(:city) { should eq 'Brooklyn' }
|
19
36
|
its(:state) { should eq 'NY' }
|
20
|
-
its(:zip) { '11217' }
|
37
|
+
its(:zip) { should eq '11217' }
|
21
38
|
its(:country) { should eq 'USA' }
|
22
|
-
its(:capacity) { should eq
|
39
|
+
its(:capacity) { should eq 17732 }
|
23
40
|
end
|
24
41
|
end
|