fantasydata 0.0.1
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.
- data/.gitignore +19 -0
- data/.travis.yml +13 -0
- data/Gemfile +17 -0
- data/Guardfile +70 -0
- data/LICENSE +22 -0
- data/README.md +32 -0
- data/Rakefile +2 -0
- data/fantasydata.gemspec +22 -0
- data/lib/fantasydata.rb +47 -0
- data/lib/fantasydata/api/box_score.rb +104 -0
- data/lib/fantasydata/api/bye_weeks.rb +24 -0
- data/lib/fantasydata/api/fantasy.rb +68 -0
- data/lib/fantasydata/api/game.rb +31 -0
- data/lib/fantasydata/api/news.rb +22 -0
- data/lib/fantasydata/api/player_details.rb +26 -0
- data/lib/fantasydata/api/player_stat.rb +33 -0
- data/lib/fantasydata/api/schedule.rb +13 -0
- data/lib/fantasydata/api/stadium.rb +14 -0
- data/lib/fantasydata/api/standings.rb +14 -0
- data/lib/fantasydata/api/team.rb +18 -0
- data/lib/fantasydata/api/utils.rb +65 -0
- data/lib/fantasydata/api/week.rb +22 -0
- data/lib/fantasydata/base.rb +91 -0
- data/lib/fantasydata/bye_week.rb +8 -0
- data/lib/fantasydata/client.rb +77 -0
- data/lib/fantasydata/configurable.rb +79 -0
- data/lib/fantasydata/daily_fantasy_player.rb +11 -0
- data/lib/fantasydata/daily_fantasy_player_stats.rb +35 -0
- data/lib/fantasydata/daily_fantasy_points.rb +8 -0
- data/lib/fantasydata/default.rb +82 -0
- data/lib/fantasydata/error.rb +33 -0
- data/lib/fantasydata/error/bad_gateway.rb +11 -0
- data/lib/fantasydata/error/bad_request.rb +10 -0
- data/lib/fantasydata/error/client_error.rb +24 -0
- data/lib/fantasydata/error/configuration_error.rb +8 -0
- data/lib/fantasydata/error/forbidden.rb +10 -0
- data/lib/fantasydata/error/gateway_timeout.rb +11 -0
- data/lib/fantasydata/error/internal_server_error.rb +11 -0
- data/lib/fantasydata/error/not_acceptable.rb +10 -0
- data/lib/fantasydata/error/not_found.rb +10 -0
- data/lib/fantasydata/error/server_error.rb +28 -0
- data/lib/fantasydata/error/service_unavailable.rb +11 -0
- data/lib/fantasydata/error/too_many_requests.rb +12 -0
- data/lib/fantasydata/error/unauthorized.rb +10 -0
- data/lib/fantasydata/error/unprocessable_entity.rb +10 -0
- data/lib/fantasydata/fantasy_player_adp.rb +10 -0
- data/lib/fantasydata/game_stat.rb +93 -0
- data/lib/fantasydata/news.rb +8 -0
- data/lib/fantasydata/player_detail.rb +27 -0
- data/lib/fantasydata/player_game_stat.rb +46 -0
- data/lib/fantasydata/player_season_stat.rb +54 -0
- data/lib/fantasydata/response/parse_json.rb +25 -0
- data/lib/fantasydata/response/raise_error.rb +32 -0
- data/lib/fantasydata/schedule.rb +14 -0
- data/lib/fantasydata/scoring_detail.rb +10 -0
- data/lib/fantasydata/stadium.rb +9 -0
- data/lib/fantasydata/standings.rb +13 -0
- data/lib/fantasydata/team_detail.rb +20 -0
- data/lib/fantasydata/version.rb +3 -0
- data/spec/fantasydata/api/box_score_spec.rb +17 -0
- data/spec/fantasydata/api/bye_weeks_spec.rb +31 -0
- data/spec/fantasydata/api/daily_fantasy_spec.rb +189 -0
- data/spec/fantasydata/api/game_spec.rb +84 -0
- data/spec/fantasydata/api/news_spec.rb +66 -0
- data/spec/fantasydata/api/player_details_spec.rb +107 -0
- data/spec/fantasydata/api/player_stat_spec.rb +138 -0
- data/spec/fantasydata/api/schedule_spec.rb +37 -0
- data/spec/fantasydata/api/stadium_spec.rb +32 -0
- data/spec/fantasydata/api/standings_spec.rb +30 -0
- data/spec/fantasydata/api/team_spec.rb +56 -0
- data/spec/fantasydata/api/week_spec.rb +69 -0
- data/spec/fantasydata/box_score_spec.rb +64 -0
- data/spec/fantasydata/client_spec.rb +77 -0
- data/spec/fantasydata/error_spec.rb +37 -0
- data/spec/fantasydata_spec.rb +64 -0
- data/spec/fixtures/bye_weeks/bye_weeks.json +1 -0
- data/spec/fixtures/daily_fantasy/adp.json +1 -0
- data/spec/fixtures/daily_fantasy/daily_defense_game.json +1 -0
- data/spec/fixtures/daily_fantasy/daily_defense_seasons_proj.json +1 -0
- data/spec/fixtures/daily_fantasy/daily_defense_seasons_stats.json +1 -0
- data/spec/fixtures/daily_fantasy/daily_players.json +1 -0
- data/spec/fixtures/daily_fantasy/daily_points.json +1 -0
- data/spec/fixtures/daily_fantasy/defense_game_stats_projected.json +1 -0
- data/spec/fixtures/error_response.json +4 -0
- data/spec/fixtures/game/game_stats_by_season.json +1 -0
- data/spec/fixtures/game/game_stats_by_week.json +1 -0
- data/spec/fixtures/game/in_progress.json +1 -0
- data/spec/fixtures/game/in_progress_false.json +1 -0
- data/spec/fixtures/game/in_progress_true.json +1 -0
- data/spec/fixtures/news/by_player.json +1 -0
- data/spec/fixtures/news/by_team.json +1 -0
- data/spec/fixtures/news/recent.json +1 -0
- data/spec/fixtures/player_details/active.json +1 -0
- data/spec/fixtures/player_details/by_team.json +1 -0
- data/spec/fixtures/player_details/free_agents.json +1 -0
- data/spec/fixtures/player_details/player_find.json +1 -0
- data/spec/fixtures/player_stat/stat_by_delta.json +1 -0
- data/spec/fixtures/player_stat/stat_by_game_projection.json +1 -0
- data/spec/fixtures/player_stat/stat_by_player_id.json +1 -0
- data/spec/fixtures/player_stat/stat_by_week.json +1 -0
- data/spec/fixtures/player_stat/stat_by_week_and_team.json +1 -0
- data/spec/fixtures/player_stat/stat_by_week_and_team_projected.json +1 -0
- data/spec/fixtures/schedule/for_year.json +1 -0
- data/spec/fixtures/stadium/index.json +1 -0
- data/spec/fixtures/standings/by_year.json +1 -0
- data/spec/fixtures/team/active.json +1 -0
- data/spec/fixtures/team/by_year.json +1 -0
- data/spec/fixtures/week/current.json +1 -0
- data/spec/fixtures/week/last_completed.json +1 -0
- data/spec/fixtures/week/upcoming.json +1 -0
- data/spec/helper.rb +42 -0
- metadata +242 -0
@@ -0,0 +1,84 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Fantasydata::API::Game do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@client = new_test_client
|
7
|
+
end
|
8
|
+
|
9
|
+
describe '#in_progress_false' do
|
10
|
+
before do
|
11
|
+
stub_get("/nfl/v2/JSON/AreAnyGamesInProgress").
|
12
|
+
to_return(:body => fixture("game/in_progress_false.json"),
|
13
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
14
|
+
end
|
15
|
+
|
16
|
+
it "requests correct resource" do
|
17
|
+
@client.games_in_progress?
|
18
|
+
expect(a_get("/nfl/v2/JSON/AreAnyGamesInProgress")).to have_been_made
|
19
|
+
end
|
20
|
+
|
21
|
+
it "returns false" do
|
22
|
+
in_progress = @client.games_in_progress?
|
23
|
+
expect(in_progress).to eq false
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe '#in_progress_true' do
|
28
|
+
before do
|
29
|
+
stub_get("/nfl/v2/JSON/AreAnyGamesInProgress").
|
30
|
+
to_return(:body => fixture("game/in_progress_true.json"),
|
31
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
32
|
+
end
|
33
|
+
|
34
|
+
it "returns true" do
|
35
|
+
in_progress = @client.games_in_progress?
|
36
|
+
expect(in_progress).to eq true
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe '#game_stats_by_week' do
|
41
|
+
before do
|
42
|
+
stub_get("/nfl/v2/JSON/GameStatsByWeek/2014/12").
|
43
|
+
to_return(:body => fixture("game/game_stats_by_week.json"),
|
44
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
45
|
+
end
|
46
|
+
|
47
|
+
it "requests correct resource" do
|
48
|
+
@client.game_stats_by_week(2014, 12)
|
49
|
+
expect(a_get("/nfl/v2/JSON/GameStatsByWeek/2014/12")).to have_been_made
|
50
|
+
end
|
51
|
+
|
52
|
+
it "returns game stats" do
|
53
|
+
game_stats = @client.game_stats_by_week(2014, 12)
|
54
|
+
expect(game_stats).to be_an Array
|
55
|
+
expect(game_stats.first.game_key).to eq '201411225'
|
56
|
+
expect(game_stats.first.home_punt_net_yards).to eq 245
|
57
|
+
expect(game_stats.first.stadium).to be_an Fantasydata::Stadium
|
58
|
+
expect(game_stats.first.stadium.stadium_id).to eq 16
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe '#game_stats_by_season' do
|
63
|
+
before do
|
64
|
+
stub_get("/nfl/v2/JSON/GameStats/2014").
|
65
|
+
to_return(:body => fixture("game/game_stats_by_season.json"),
|
66
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
67
|
+
end
|
68
|
+
|
69
|
+
it "requests correct resource" do
|
70
|
+
@client.game_stats_by_season(2014)
|
71
|
+
expect(a_get("/nfl/v2/JSON/GameStats/2014")).to have_been_made
|
72
|
+
end
|
73
|
+
|
74
|
+
it "returns game stats" do
|
75
|
+
game_stats = @client.game_stats_by_season(2014)
|
76
|
+
expect(game_stats).to be_an Array
|
77
|
+
expect(game_stats.first.game_key).to eq '201410130'
|
78
|
+
expect(game_stats.first.home_punt_net_yards).to eq 66
|
79
|
+
expect(game_stats.first.stadium).to be_an Fantasydata::Stadium
|
80
|
+
expect(game_stats.first.stadium.stadium_id).to eq 31
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Fantasydata::API::News do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@client = new_test_client
|
7
|
+
end
|
8
|
+
|
9
|
+
describe '#news_by_player_id' do
|
10
|
+
before do
|
11
|
+
stub_get("/nfl/v2/JSON/NewsByPlayerID/1326").
|
12
|
+
to_return(:body => fixture("news/by_player.json"),
|
13
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
14
|
+
end
|
15
|
+
|
16
|
+
it "requests correct resource" do
|
17
|
+
@client.news_by_player_id(1326)
|
18
|
+
expect(a_get("/nfl/v2/JSON/NewsByPlayerID/1326")).to have_been_made
|
19
|
+
end
|
20
|
+
|
21
|
+
it "returns returns news" do
|
22
|
+
news = @client.news_by_player_id(1326)
|
23
|
+
expect(news).to be_an Array
|
24
|
+
expect(news.first.news_id).to eq 36084
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe '#news_by_team' do
|
29
|
+
before do
|
30
|
+
stub_get("/nfl/v2/JSON/NewsByTeam/MIN").
|
31
|
+
to_return(:body => fixture("news/by_team.json"),
|
32
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
33
|
+
end
|
34
|
+
|
35
|
+
it "requests correct resource" do
|
36
|
+
@client.news_by_team('MIN')
|
37
|
+
expect(a_get("/nfl/v2/JSON/NewsByTeam/MIN")).to have_been_made
|
38
|
+
end
|
39
|
+
|
40
|
+
it "returns returns news" do
|
41
|
+
news = @client.news_by_team('MIN')
|
42
|
+
expect(news).to be_an Array
|
43
|
+
expect(news.first.news_id).to eq 35043
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe '#news_recent' do
|
48
|
+
before do
|
49
|
+
stub_get("/nfl/v2/JSON/News").
|
50
|
+
to_return(:body => fixture("news/recent.json"),
|
51
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
52
|
+
end
|
53
|
+
|
54
|
+
it "requests correct resource" do
|
55
|
+
@client.news_recent
|
56
|
+
expect(a_get("/nfl/v2/JSON/News")).to have_been_made
|
57
|
+
end
|
58
|
+
|
59
|
+
it "returns returns news" do
|
60
|
+
news = @client.news_recent
|
61
|
+
expect(news).to be_an Array
|
62
|
+
expect(news.first.news_id).to eq 36084
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Fantasydata::API::Stadium do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@client = new_test_client
|
7
|
+
end
|
8
|
+
|
9
|
+
describe '#player_details_available_spec' do
|
10
|
+
before do
|
11
|
+
stub_get("/nfl/v2/JSON/Players").
|
12
|
+
to_return(:body => fixture("player_details/active.json"),
|
13
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
14
|
+
end
|
15
|
+
|
16
|
+
it "requests correct resource - pass string" do
|
17
|
+
@client.player_details_available
|
18
|
+
expect(a_get("/nfl/v2/JSON/Players")).to have_been_made
|
19
|
+
end
|
20
|
+
|
21
|
+
it "returns player details" do
|
22
|
+
players = @client.player_details_available
|
23
|
+
|
24
|
+
expect(players).to be_an Array
|
25
|
+
expect(players.first.player_id).to eq 17065
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe '#player_details_freeagents_spec' do
|
30
|
+
before do
|
31
|
+
stub_get("/nfl/v2/JSON/FreeAgents").
|
32
|
+
to_return(:body => fixture("player_details/free_agents.json"),
|
33
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
34
|
+
end
|
35
|
+
|
36
|
+
it "requests correct resource - pass string" do
|
37
|
+
@client.player_details_free_agents
|
38
|
+
expect(a_get("/nfl/v2/JSON/FreeAgents")).to have_been_made
|
39
|
+
end
|
40
|
+
|
41
|
+
it "returns player details" do
|
42
|
+
players = @client.player_details_free_agents
|
43
|
+
|
44
|
+
expect(players).to be_an Array
|
45
|
+
expect(players.first.player_id).to eq 3
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe '#player_details_freeagents_spec' do
|
50
|
+
before do
|
51
|
+
stub_get("/nfl/v2/JSON/Player/7328").
|
52
|
+
to_return(:body => fixture("player_details/player_find.json"),
|
53
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
54
|
+
end
|
55
|
+
|
56
|
+
it "requests correct resource - pass string" do
|
57
|
+
@client.player_details_by_player_id(7328)
|
58
|
+
expect(a_get("/nfl/v2/JSON/Player/7328")).to have_been_made
|
59
|
+
end
|
60
|
+
|
61
|
+
it "returns player details and related data" do
|
62
|
+
player = @client.player_details_by_player_id(7328)
|
63
|
+
|
64
|
+
expect(player).to be_an Fantasydata::PlayerDetail
|
65
|
+
expect(player.player_id).to eq 7328
|
66
|
+
|
67
|
+
expect(player.season_stats).to be_an Fantasydata::PlayerSeasonStat
|
68
|
+
expect(player.season_stats.fumbles).to eq 5
|
69
|
+
|
70
|
+
expect(player.season_stats.scoring_details).to be_an Array
|
71
|
+
expect(player.season_stats.scoring_details.first.game_key).to eq '201410110'
|
72
|
+
|
73
|
+
expect(player.latest_news).to be_an Array
|
74
|
+
expect(player.latest_news.first.news_id).to eq 34904
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe '#player_details_freeagents_spec' do
|
79
|
+
before do
|
80
|
+
stub_get("/nfl/v2/JSON/Players/MIN").
|
81
|
+
to_return(:body => fixture("player_details/by_team.json"),
|
82
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
83
|
+
end
|
84
|
+
|
85
|
+
it "requests correct resource - pass string" do
|
86
|
+
@client.player_details_by_team('MIN')
|
87
|
+
expect(a_get("/nfl/v2/JSON/Players/MIN")).to have_been_made
|
88
|
+
end
|
89
|
+
|
90
|
+
it "returns player details and related data" do
|
91
|
+
player = @client.player_details_by_team('MIN')
|
92
|
+
|
93
|
+
expect(player).to be_an Array
|
94
|
+
expect(player.first.player_id).to eq 11323
|
95
|
+
|
96
|
+
expect(player.first.season_stats).to be_an Fantasydata::PlayerSeasonStat
|
97
|
+
expect(player.first.season_stats.fumbles).to eq 0
|
98
|
+
|
99
|
+
expect(player.first.season_stats.scoring_details).to be_an Array
|
100
|
+
expect(player.first.season_stats.scoring_details.count).to eq 0
|
101
|
+
|
102
|
+
expect(player.first.latest_news).to be_an Array
|
103
|
+
expect(player.first.latest_news.first.news_id).to eq 5812
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
end
|
@@ -0,0 +1,138 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Fantasydata::API::PlayerStat do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@client = new_test_client
|
7
|
+
end
|
8
|
+
|
9
|
+
describe '#player_game_stat_by_player' do
|
10
|
+
before do
|
11
|
+
stub_get("/nfl/v2/JSON/PlayerGameStatsByPlayerID/2014/12/7328").
|
12
|
+
to_return(:body => fixture("player_stat/stat_by_player_id.json"),
|
13
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
14
|
+
end
|
15
|
+
|
16
|
+
it "requests correct resource" do
|
17
|
+
@client.player_game_stat_by_player(2014, 12, 7328)
|
18
|
+
expect(a_get("/nfl/v2/JSON/PlayerGameStatsByPlayerID/2014/12/7328")).to have_been_made
|
19
|
+
end
|
20
|
+
|
21
|
+
it "returns player details" do
|
22
|
+
stat = @client.player_game_stat_by_player(2014, 12, 7328)
|
23
|
+
|
24
|
+
expect(stat).to be_an Fantasydata::PlayerGameStat
|
25
|
+
expect(stat.player_id).to eq 7328
|
26
|
+
expect(stat.scoring_details).to be_an Array
|
27
|
+
expect(stat.scoring_details.first.game_key).to eq '201411210'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '#player_stat_by_week_projected' do
|
32
|
+
before do
|
33
|
+
stub_get("/nfl/v2/JSON/PlayerGameProjectionStatsByPlayerID/2014/12/7328").
|
34
|
+
to_return(:body => fixture("player_stat/stat_by_game_projection.json"),
|
35
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
36
|
+
end
|
37
|
+
|
38
|
+
it "requests correct resource" do
|
39
|
+
@client.player_game_stat_by_player_projection(2014, 12, 7328)
|
40
|
+
expect(a_get("/nfl/v2/JSON/PlayerGameProjectionStatsByPlayerID/2014/12/7328")).to have_been_made
|
41
|
+
end
|
42
|
+
|
43
|
+
it "returns player details" do
|
44
|
+
stat = @client.player_game_stat_by_player_projection(2014, 12, 7328)
|
45
|
+
|
46
|
+
expect(stat).to be_an Fantasydata::PlayerGameStat
|
47
|
+
expect(stat.player_id).to eq 7328
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe '#player_game_stats_by_week_and_team' do
|
52
|
+
before do
|
53
|
+
stub_get("/nfl/v2/JSON/PlayerGameStatsByTeam/2014/12/MIN").
|
54
|
+
to_return(:body => fixture("player_stat/stat_by_week_and_team.json"),
|
55
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
56
|
+
end
|
57
|
+
|
58
|
+
it "requests correct resource" do
|
59
|
+
@client.player_game_stats_by_week_and_team(2014, 12, 'MIN')
|
60
|
+
expect(a_get("/nfl/v2/JSON/PlayerGameStatsByTeam/2014/12/MIN")).to have_been_made
|
61
|
+
end
|
62
|
+
|
63
|
+
it "returns player details" do
|
64
|
+
stat = @client.player_game_stats_by_week_and_team(2014, 12, 'MIN')
|
65
|
+
|
66
|
+
expect(stat).to be_an Array
|
67
|
+
expect(stat.first).to be_an Fantasydata::PlayerGameStat
|
68
|
+
expect(stat.first.player_id).to eq 14463
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe '#player_game_stats_by_week_and_team_projection' do
|
73
|
+
before do
|
74
|
+
stub_get("/nfl/v2/JSON/PlayerGameProjectionStatsByTeam/2014/12/MIN").
|
75
|
+
to_return(:body => fixture("player_stat/stat_by_week_and_team_projected.json"),
|
76
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
77
|
+
end
|
78
|
+
|
79
|
+
it "requests correct resource" do
|
80
|
+
@client.player_game_stats_by_week_and_team_projection(2014, 12, 'MIN')
|
81
|
+
expect(a_get("/nfl/v2/JSON/PlayerGameProjectionStatsByTeam/2014/12/MIN")).to have_been_made
|
82
|
+
end
|
83
|
+
|
84
|
+
it "returns player details" do
|
85
|
+
stat = @client.player_game_stats_by_week_and_team_projection(2014, 12, 'MIN')
|
86
|
+
|
87
|
+
expect(stat).to be_an Array
|
88
|
+
expect(stat.first).to be_an Fantasydata::PlayerGameStat
|
89
|
+
expect(stat.first.player_id).to eq 14463
|
90
|
+
expect(stat.first.field_goals_attempted).to eq 2
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
describe '#player_game_stats_by_week' do
|
95
|
+
before do
|
96
|
+
stub_get("/nfl/v2/JSON/PlayerGameStatsByWeek/2014/13").
|
97
|
+
to_return(:body => fixture("player_stat/stat_by_week.json"),
|
98
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
99
|
+
end
|
100
|
+
|
101
|
+
it "requests correct resource" do
|
102
|
+
@client.player_game_stats_by_week(2014, 13)
|
103
|
+
expect(a_get("/nfl/v2/JSON/PlayerGameStatsByWeek/2014/13")).to have_been_made
|
104
|
+
end
|
105
|
+
|
106
|
+
it "returns player details" do
|
107
|
+
stat = @client.player_game_stats_by_week(2014, 13)
|
108
|
+
|
109
|
+
expect(stat).to be_an Array
|
110
|
+
expect(stat.first).to be_an Fantasydata::PlayerGameStat
|
111
|
+
expect(stat.first.player_id).to eq 7295
|
112
|
+
expect(stat.first.stadium).to eq "Lucas Oil Stadium"
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
describe '#player_game_stat_by_delta' do
|
117
|
+
before do
|
118
|
+
stub_get("/nfl/v2/JSON/PlayerGameStatsDelta/4").
|
119
|
+
to_return(:body => fixture("player_stat/stat_by_delta.json"),
|
120
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
121
|
+
end
|
122
|
+
|
123
|
+
it "requests correct resource" do
|
124
|
+
@client.player_game_stats_by_delta(4)
|
125
|
+
expect(a_get("/nfl/v2/JSON/PlayerGameStatsDelta/4")).to have_been_made
|
126
|
+
end
|
127
|
+
|
128
|
+
it "returns player details" do
|
129
|
+
stat = @client.player_game_stats_by_delta(4)
|
130
|
+
|
131
|
+
expect(stat).to be_an Array
|
132
|
+
expect(stat.first).to be_an Fantasydata::PlayerGameStat
|
133
|
+
expect(stat.first.player_id).to eq 7295
|
134
|
+
expect(stat.first.stadium).to eq "Lucas Oil Stadium"
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Fantasydata::API::Schedule do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@client = new_test_client
|
7
|
+
end
|
8
|
+
|
9
|
+
describe '#schedule_by_year' do
|
10
|
+
before do
|
11
|
+
stub_get("/nfl/v2/JSON/Schedules/2014").
|
12
|
+
to_return(:body => fixture("schedule/for_year.json"),
|
13
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
14
|
+
end
|
15
|
+
|
16
|
+
it "requests correct resource" do
|
17
|
+
@client.schedule_by_year(2014)
|
18
|
+
expect(a_get("/nfl/v2/JSON/Schedules/2014")).to have_been_made
|
19
|
+
end
|
20
|
+
|
21
|
+
it "returns player details" do
|
22
|
+
schedule_items = @client.schedule_by_year(2014)
|
23
|
+
|
24
|
+
expect(schedule_items).to be_an Array
|
25
|
+
expect(schedule_items.first).to be_an Fantasydata::Schedule
|
26
|
+
|
27
|
+
expect(schedule_items.first.game_key).to eq "201410130"
|
28
|
+
expect(schedule_items.first.season).to eq 2014
|
29
|
+
|
30
|
+
expect(schedule_items.first.stadium).to be_an Fantasydata::Stadium
|
31
|
+
expect(schedule_items.first.stadium.name).to eq "CenturyLink Field"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Fantasydata::API::Stadium do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@client = new_test_client
|
7
|
+
end
|
8
|
+
|
9
|
+
describe '#stadiums' do
|
10
|
+
before do
|
11
|
+
stub_get("/nfl/v2/JSON/Stadiums").
|
12
|
+
to_return(:body => fixture("stadium/index.json"),
|
13
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
14
|
+
end
|
15
|
+
|
16
|
+
it "requests correct resource" do
|
17
|
+
@client.stadiums
|
18
|
+
expect(a_get("/nfl/v2/JSON/Stadiums")).to have_been_made
|
19
|
+
end
|
20
|
+
|
21
|
+
it "returns player details" do
|
22
|
+
stadiums = @client.stadiums
|
23
|
+
|
24
|
+
expect(stadiums).to be_an Array
|
25
|
+
expect(stadiums.first.stadium_id).to eq 1
|
26
|
+
expect(stadiums.first.capacity).to eq 73079
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
|