infostrada 0.1.26 → 0.1.27
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/.rspec +2 -0
- data/.rubocop.yml +2 -0
- data/.travis.yml +6 -0
- data/README.md +2 -0
- data/infostrada.gemspec +4 -1
- data/lib/infostrada.rb +6 -12
- data/lib/infostrada/call_refresh.rb +2 -1
- data/lib/infostrada/competition.rb +2 -1
- data/lib/infostrada/core_ext/hash.rb +14 -0
- data/lib/infostrada/core_ext/string.rb +19 -2
- data/lib/infostrada/match.rb +2 -2
- data/lib/infostrada/match_event.rb +1 -1
- data/lib/infostrada/mock.rb +76 -0
- data/lib/infostrada/nation.rb +2 -2
- data/lib/infostrada/person_info.rb +12 -12
- data/lib/infostrada/phase.rb +11 -13
- data/lib/infostrada/player.rb +11 -11
- data/lib/infostrada/squad.rb +3 -6
- data/lib/infostrada/team.rb +4 -4
- data/lib/infostrada/team_info.rb +1 -1
- data/lib/infostrada/team_request.rb +2 -5
- data/lib/infostrada/version.rb +1 -1
- data/spec/base_request_spec.rb +19 -0
- data/spec/competition_spec.rb +67 -0
- data/spec/edition_request_spec.rb +20 -0
- data/spec/edition_spec.rb +111 -0
- data/spec/endpoint_spec.rb +62 -0
- data/spec/formatter_spec.rb +12 -0
- data/spec/helpers/json_helper.rb +41 -0
- data/spec/json/competition.json +55 -0
- data/spec/json/edition.json +61 -0
- data/spec/json/edition_request.json +242 -0
- data/spec/json/endpoint.json +46 -0
- data/spec/json/match.json +945 -0
- data/spec/json/match_event.json +187 -0
- data/spec/json/match_event_list.json +411 -0
- data/spec/json/nation.json +302 -0
- data/spec/json/person_info.json +52 -0
- data/spec/json/phase.json +158 -0
- data/spec/json/player.json +93 -0
- data/spec/json/referee.json +184 -0
- data/spec/json/sample_responses/all_editions.json +243 -0
- data/spec/json/sample_responses/competition_edition_league_21594_serie_a.json +4 -0
- data/spec/json/sample_responses/competition_match_days_league_21594_serie_a.json +473 -0
- data/spec/json/sample_responses/competition_match_list_league_21594_serie_a.json +25465 -0
- data/spec/json/sample_responses/competition_phases_cup_21204_capital_one_cup.json +138 -0
- data/spec/json/sample_responses/competition_phases_league_21594_serie_a.json +24 -0
- data/spec/json/sample_responses/competition_table_phase_114165_serie_a_2015.json +585 -0
- data/spec/json/sample_responses/competition_teams_league_21594.json +165 -0
- data/spec/json/sample_responses/get_api_call_refresh_module.json +65 -0
- data/spec/json/sample_responses/match_events_1788734_real_atletico_final_champions.json +7960 -0
- data/spec/json/sample_responses/match_info_1788734_real_atletico_final_champions.json +96 -0
- data/spec/json/sample_responses/match_info_upcoming_1968820_serie_a.json +96 -0
- data/spec/json/sample_responses/person_info_611005_bale.json +55 -0
- data/spec/json/sample_responses/squad_100163_on_edition_21590.json +1355 -0
- data/spec/json/sample_responses/team_info_100163.json +28 -0
- data/spec/json/sample_responses/template_dummy_response.json +4 -0
- data/spec/json/squad.json +514 -0
- data/spec/json/team.json +10 -0
- data/spec/json/team_info.json +25 -0
- data/spec/json/team_request.json +68 -0
- data/spec/match_event_list_spec.rb +21 -0
- data/spec/match_event_spec.rb +159 -0
- data/spec/match_spec.rb +430 -0
- data/spec/nation_spec.rb +179 -0
- data/spec/person_info_spec.rb +69 -0
- data/spec/phase_spec.rb +183 -0
- data/spec/player_spec.rb +112 -0
- data/spec/referee_spec.rb +71 -0
- data/spec/spec_helper.rb +117 -0
- data/spec/squad_spec.rb +25 -0
- data/spec/team_info_spec.rb +77 -0
- data/spec/team_request_spec.rb +24 -0
- data/spec/team_spec.rb +76 -0
- metadata +213 -43
data/spec/json/team.json
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
{
|
2
|
+
"default": {
|
3
|
+
"c_OfficialName": "Club Atl\u00e9tico Mineiro",
|
4
|
+
"c_OfficialNameSort": "Club Atl\u00e9tico Mineiro",
|
5
|
+
"c_PublicName": "Atl\u00e9tico-MG",
|
6
|
+
"c_PublicNameSort": "Atl\u00e9tico-MG",
|
7
|
+
"c_PublicNameShort": "ATM",
|
8
|
+
"c_Nickname": null,
|
9
|
+
"n_NatioGeoID": 2235,
|
10
|
+
"c_Natio": "Brazil",
|
11
|
+
"c_NatioShort": "BRA",
|
12
|
+
"d_FoundationDate": "/Date(-1949360400000+0100)/",
|
13
|
+
"n_FoundationYear": 1908,
|
14
|
+
"n_StadiumGeoID": 10434,
|
15
|
+
"c_Stadium": "Est\u00e1dio Independ\u00eancia",
|
16
|
+
"c_StadiumOfficialName": "Est\u00e1dio Independ\u00eancia",
|
17
|
+
"n_StadiumCapacity": null,
|
18
|
+
"n_CityGeoID": 40862,
|
19
|
+
"c_City": "Belo Horizonte",
|
20
|
+
"n_CountryGeoID": 2235,
|
21
|
+
"c_Country": "Brazil",
|
22
|
+
"c_CountryShort": "BRA",
|
23
|
+
"c_URL": "http://www.atletico.com.br/"
|
24
|
+
}
|
25
|
+
}
|
@@ -0,0 +1,68 @@
|
|
1
|
+
{
|
2
|
+
"list":[
|
3
|
+
{
|
4
|
+
"n_TeamID": 100163,
|
5
|
+
"c_Team": "Atl\u00e9tico-MG",
|
6
|
+
"c_TeamShort": "ATM",
|
7
|
+
"n_TeamNatioGeoID": 2235,
|
8
|
+
"c_TeamNatio": "Brazil",
|
9
|
+
"c_TeamNatioShort": "BRA"
|
10
|
+
},
|
11
|
+
{
|
12
|
+
"n_TeamID": 104005,
|
13
|
+
"c_Team": "Atl\u00e9tico-PR",
|
14
|
+
"c_TeamShort": "ATP",
|
15
|
+
"n_TeamNatioGeoID": 2235,
|
16
|
+
"c_TeamNatio": "Brazil",
|
17
|
+
"c_TeamNatioShort": "BRA"
|
18
|
+
},
|
19
|
+
{
|
20
|
+
"n_TeamID": 113506,
|
21
|
+
"c_Team": "Ava\u00ed",
|
22
|
+
"c_TeamShort": "AFC",
|
23
|
+
"n_TeamNatioGeoID": 2235,
|
24
|
+
"c_TeamNatio": "Brazil",
|
25
|
+
"c_TeamNatioShort": "BRA"
|
26
|
+
},
|
27
|
+
{
|
28
|
+
"n_TeamID": 106816,
|
29
|
+
"c_Team": "Chapecoense",
|
30
|
+
"c_TeamShort": "ACF",
|
31
|
+
"n_TeamNatioGeoID": 2235,
|
32
|
+
"c_TeamNatio": "Brazil",
|
33
|
+
"c_TeamNatioShort": "BRA"
|
34
|
+
},
|
35
|
+
{
|
36
|
+
"n_TeamID": 103045,
|
37
|
+
"c_Team": "Corinthians",
|
38
|
+
"c_TeamShort": "COR",
|
39
|
+
"n_TeamNatioGeoID": 2235,
|
40
|
+
"c_TeamNatio": "Brazil",
|
41
|
+
"c_TeamNatioShort": "BRA"
|
42
|
+
},
|
43
|
+
{
|
44
|
+
"n_TeamID": 104004,
|
45
|
+
"c_Team": "Coritiba",
|
46
|
+
"c_TeamShort": "CRB",
|
47
|
+
"n_TeamNatioGeoID": 2235,
|
48
|
+
"c_TeamNatio": "Brazil",
|
49
|
+
"c_TeamNatioShort": "BRA"
|
50
|
+
},
|
51
|
+
{
|
52
|
+
"n_TeamID": 102310,
|
53
|
+
"c_Team": "Cruzeiro",
|
54
|
+
"c_TeamShort": "CRU",
|
55
|
+
"n_TeamNatioGeoID": 2235,
|
56
|
+
"c_TeamNatio": "Brazil",
|
57
|
+
"c_TeamNatioShort": "BRA"
|
58
|
+
},
|
59
|
+
{
|
60
|
+
"n_TeamID": 108038,
|
61
|
+
"c_Team": "Figueirense",
|
62
|
+
"c_TeamShort": "FFC",
|
63
|
+
"n_TeamNatioGeoID": 2235,
|
64
|
+
"c_TeamNatio": "Brazil",
|
65
|
+
"c_TeamNatioShort": "BRA"
|
66
|
+
}
|
67
|
+
]
|
68
|
+
}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Infostrada::MatchEventList do
|
4
|
+
let(:match_id) { 29 }
|
5
|
+
let(:default) { JSONHelper::MatchEventList.get(:default) }
|
6
|
+
let(:path) { 'GetMatchActionList_All' }
|
7
|
+
let(:uri) { "#{@base_url}/#{path}?#{@default_params}&&matchid=#{match_id}" }
|
8
|
+
|
9
|
+
before do
|
10
|
+
stub_request(:get, uri)
|
11
|
+
.to_return(status: 200, body: default.to_json)
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '.where' do
|
15
|
+
it 'creates list of events' do
|
16
|
+
results = Infostrada::MatchEventList.where(match_id: match_id)
|
17
|
+
expect(results).not_to be_empty
|
18
|
+
expect(results.count).to eq(default.count)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,159 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Infostrada::MatchEvent do
|
4
|
+
let(:event_1) { JSONHelper::MatchEvent.get(:event_1) }
|
5
|
+
let(:match_id) { rand(10) }
|
6
|
+
let(:event) { Infostrada::MatchEvent.new(match_id, event_1) }
|
7
|
+
|
8
|
+
describe '#initialize' do
|
9
|
+
it 'has match_id' do
|
10
|
+
expect(event.match_id).not_to be_nil
|
11
|
+
expect(event.match_id).to eq(match_id)
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'has id' do
|
15
|
+
expect(event.id).not_to be_nil
|
16
|
+
expect(event.id).to eq(event_1['n_ActionID'])
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'has description' do
|
20
|
+
expect(event.description).not_to be_nil
|
21
|
+
expect(event.description).to eq(event_1['c_Action'])
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'has short_description' do
|
25
|
+
expect(event.short_description).not_to be_nil
|
26
|
+
expect(event.short_description).to eq(event_1['c_ActionShort'])
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'has period' do
|
30
|
+
expect(event.period).not_to be_nil
|
31
|
+
expect(event.period).to eq(event_1['c_Period'])
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'has period_short' do
|
35
|
+
expect(event.period_short).not_to be_nil
|
36
|
+
expect(event.period_short).to eq(event_1['c_PeriodShort'])
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'has period_code' do
|
40
|
+
expect(event.period_code).not_to be_nil
|
41
|
+
expect(event.period_code).to eq(event_1['n_PeriodSort'])
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'has time' do
|
45
|
+
expect(event.time).not_to be_nil
|
46
|
+
expect(event.time).to eq(event_1['n_ActionTime'])
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'has home_goals' do
|
50
|
+
expect(event.home_goals).not_to be_nil
|
51
|
+
expect(event.home_goals).to eq(event_1['n_HomeGoals'])
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'has away_goals' do
|
55
|
+
expect(event.away_goals).not_to be_nil
|
56
|
+
expect(event.away_goals).to eq(event_1['n_AwayGoals'])
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'has home_event' do
|
60
|
+
expect(event.home_event).not_to be_nil
|
61
|
+
expect(event.home_event).to eq(event_1['n_HomeOrAway'] == 1)
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'has team_id' do
|
65
|
+
expect(event.team_id).not_to be_nil
|
66
|
+
expect(event.team_id).to eq(event_1['n_TeamID'])
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'has team_name' do
|
70
|
+
expect(event.team_name).not_to be_nil
|
71
|
+
expect(event.team_name).to eq(event_1['c_Team'])
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'has team_short_name' do
|
75
|
+
expect(event.team_short_name).not_to be_nil
|
76
|
+
expect(event.team_short_name).to eq(event_1['c_TeamShort'])
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'has person_id' do
|
80
|
+
expect(event.person_id).not_to be_nil
|
81
|
+
expect(event.person_id).to eq(event_1['n_PersonID'])
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'has person_name' do
|
85
|
+
expect(event.person_name).not_to be_nil
|
86
|
+
expect(event.person_name).to eq(event_1['c_Person'])
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'has person_short_name' do
|
90
|
+
expect(event.person_short_name).not_to be_nil
|
91
|
+
expect(event.person_short_name).to eq(event_1['c_PersonShort'])
|
92
|
+
end
|
93
|
+
|
94
|
+
it 'has reason' do
|
95
|
+
expect(event.reason).not_to be_nil
|
96
|
+
expect(event.reason).to eq(event_1['c_ActionReason'])
|
97
|
+
end
|
98
|
+
|
99
|
+
it 'has info' do
|
100
|
+
expect(event.info).not_to be_nil
|
101
|
+
expect(event.info).to eq(event_1['c_ActionInfo'])
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'has person2_id' do
|
105
|
+
expect(event.person2_id).not_to be_nil
|
106
|
+
expect(event.person2_id).to eq(event_1['n_SubPersonID'])
|
107
|
+
end
|
108
|
+
|
109
|
+
it 'has person2_name' do
|
110
|
+
expect(event.person2_name).not_to be_nil
|
111
|
+
expect(event.person2_name).to eq(event_1['c_SubPerson'])
|
112
|
+
end
|
113
|
+
|
114
|
+
it 'has person2_short_name' do
|
115
|
+
expect(event.person2_short_name).not_to be_nil
|
116
|
+
expect(event.person2_short_name).to eq(event_1['c_SubPersonShort'])
|
117
|
+
end
|
118
|
+
|
119
|
+
it 'has minute' do
|
120
|
+
expect(event.minute).not_to be_nil
|
121
|
+
expect(event.minute).to eq(event_1['c_ActionMinute'])
|
122
|
+
end
|
123
|
+
|
124
|
+
it 'has action_set' do
|
125
|
+
expect(event.action_set).not_to be_nil
|
126
|
+
expect(event.action_set).to eq(event_1['n_ActionSet'])
|
127
|
+
end
|
128
|
+
|
129
|
+
it 'has action_code' do
|
130
|
+
expect(event.action_code).not_to be_nil
|
131
|
+
expect(event.action_code).to eq(event_1['n_ActionCode'])
|
132
|
+
end
|
133
|
+
|
134
|
+
it 'has action_code_2' do
|
135
|
+
expect(event.action_code_2).not_to be_nil
|
136
|
+
expect(event.action_code_2).to eq(event_1['n_ActionCode2'])
|
137
|
+
end
|
138
|
+
|
139
|
+
it 'has action_code_3' do
|
140
|
+
expect(event.action_code_3).not_to be_nil
|
141
|
+
expect(event.action_code_3).to eq(event_1['n_ActionCode3'])
|
142
|
+
end
|
143
|
+
|
144
|
+
it 'has action_sort' do
|
145
|
+
expect(event.action_sort).not_to be_nil
|
146
|
+
expect(event.action_sort).to eq(event_1['n_ActionSort'])
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
context '#from_json' do
|
151
|
+
let(:event_from_json) { Infostrada::MatchEvent.from_json(event.as_json.clone) }
|
152
|
+
|
153
|
+
describe '#initialize' do
|
154
|
+
it 'has match_id' do
|
155
|
+
expect(event_from_json.match_id).not_to be_nil
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
data/spec/match_spec.rb
ADDED
@@ -0,0 +1,430 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Infostrada::Match do
|
4
|
+
context 'With Cup KnockOut Round Finished Json' do
|
5
|
+
let(:complete_match) { JSONHelper::Match.get(:cup_knock_out_finished_complete) }
|
6
|
+
let(:no_referee_match) { JSONHelper::Match.get(:cup_knock_out_finished_no_referee) }
|
7
|
+
let(:no_stadium_match) { JSONHelper::Match.get(:cup_knock_out_finished_no_stadium) }
|
8
|
+
|
9
|
+
describe '#initialize' do
|
10
|
+
context 'complete match' do
|
11
|
+
let(:match) { Infostrada::Match.new(complete_match.clone) }
|
12
|
+
|
13
|
+
it 'has id' do
|
14
|
+
expect(match.id).to be(complete_match['n_MatchID'])
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'has rescheduled' do
|
18
|
+
expect(match.rescheduled).to be(complete_match['b_RescheduledToBeResumed'])
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'has date' do
|
22
|
+
expect(match.date).not_to be(nil)
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'has round' do
|
26
|
+
expect(match.round).to be(complete_match['n_RoundNr'])
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'has time_unknown' do
|
30
|
+
expect(match.time_unknown).to be(false)
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'has date_unknown' do
|
34
|
+
expect(match.date_unknown).to be(false)
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'has aggregate_winner_id' do
|
38
|
+
expect(match.aggregate_winner_id).to be(complete_match['n_WinnerOnAggregateTeamID'])
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'not_has current_period_started_at' do
|
42
|
+
expect(match.current_period_started_at).to be(nil)
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'has status_code' do
|
46
|
+
expect(match.status_code).to be(complete_match['n_MatchStatusCode'])
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'has status' do
|
50
|
+
expect(match.status).to be(complete_match['c_MatchStatus'])
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'has status_short' do
|
54
|
+
expect(match.status_short).to be(complete_match['c_MatchStatusShort'])
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'has leg' do
|
58
|
+
expect(match.leg).to be(complete_match['n_Leg'])
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'has started_at' do
|
62
|
+
expect(match.started_at).not_to be(nil)
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'has knockout_phase_id' do
|
66
|
+
expect(match.knockout_phase_id).to be(complete_match['n_KnockoutPhaseID'])
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'has stadium_id' do
|
70
|
+
expect(match.stadium_id).to be(complete_match['n_StadiumGeoID'])
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'has stadium_name' do
|
74
|
+
expect(match.stadium_name).to be(complete_match['c_Stadium'])
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'has spectators' do
|
78
|
+
expect(match.spectators).to be(complete_match['n_Spectators'])
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'has city' do
|
82
|
+
expect(match.city).to be(complete_match['c_City'])
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'has live' do
|
86
|
+
expect(match.live).to be(complete_match['b_Live'])
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'has started' do
|
90
|
+
expect(match.started).to be(complete_match['b_Started'])
|
91
|
+
end
|
92
|
+
|
93
|
+
it 'has finished' do
|
94
|
+
expect(match.finished).to be(complete_match['b_Finished'])
|
95
|
+
end
|
96
|
+
|
97
|
+
it 'has awarded' do
|
98
|
+
expect(match.awarded).to be(complete_match['b_Awarded'])
|
99
|
+
end
|
100
|
+
|
101
|
+
it 'has live_score' do
|
102
|
+
expect(match.live_score).to be(complete_match['b_DataEntryLiveScore'])
|
103
|
+
end
|
104
|
+
|
105
|
+
it 'has live_goals' do
|
106
|
+
expect(match.live_goals).to be(complete_match['b_DataEntryLiveGoal'])
|
107
|
+
end
|
108
|
+
|
109
|
+
it 'has live_lineup' do
|
110
|
+
expect(match.live_lineup).to be(complete_match['b_DataEntryLiveLineup'])
|
111
|
+
end
|
112
|
+
|
113
|
+
it 'has lineup_provisional' do
|
114
|
+
expect(match.lineup_provisional).to be(complete_match['b_LineupProvisional'])
|
115
|
+
end
|
116
|
+
|
117
|
+
it 'has lineup_official' do
|
118
|
+
expect(match.lineup_official).to be(complete_match['b_LineupOfficial'])
|
119
|
+
end
|
120
|
+
|
121
|
+
it 'has period' do
|
122
|
+
expect(match.period).to be(complete_match['n_PeriodSort'])
|
123
|
+
end
|
124
|
+
|
125
|
+
it 'has referee' do
|
126
|
+
expect(match.referee.id).to be(complete_match['n_RefereeID'])
|
127
|
+
end
|
128
|
+
|
129
|
+
it 'has phase' do
|
130
|
+
expect(match.phase.id).to be(complete_match['n_PhaseID'])
|
131
|
+
end
|
132
|
+
|
133
|
+
it 'has home_team' do
|
134
|
+
expect(match.home_team.id).to be(complete_match['n_HomeTeamID'])
|
135
|
+
end
|
136
|
+
|
137
|
+
it 'has away_team' do
|
138
|
+
expect(match.away_team.id).to be(complete_match['n_AwayTeamID'])
|
139
|
+
end
|
140
|
+
|
141
|
+
it 'has goals' do
|
142
|
+
expect(match.goals).not_to be(nil)
|
143
|
+
end
|
144
|
+
|
145
|
+
it 'has edition' do
|
146
|
+
expect(match.edition.id).to be(complete_match['n_EditionID'])
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
context 'without referee' do
|
151
|
+
let(:match) { Infostrada::Match.new(no_referee_match.clone) }
|
152
|
+
|
153
|
+
it 'not_fails' do
|
154
|
+
expect(match).not_to be(nil)
|
155
|
+
end
|
156
|
+
|
157
|
+
it 'not_has referee' do
|
158
|
+
expect(match.referee).to be(nil)
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
context 'without stadium' do
|
163
|
+
let(:match) { Infostrada::Match.new(no_stadium_match.clone) }
|
164
|
+
|
165
|
+
it 'not_fails' do
|
166
|
+
expect(match).not_to be(nil)
|
167
|
+
end
|
168
|
+
|
169
|
+
it 'not_has stadium_id' do
|
170
|
+
expect(match.stadium_id).to be(nil)
|
171
|
+
end
|
172
|
+
|
173
|
+
it 'not_has stadium_name' do
|
174
|
+
expect(match.stadium_name).to be(nil)
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
describe '.from_json' do
|
180
|
+
let(:complete_match_serialized) { Infostrada::Match.new(complete_match.clone).as_json }
|
181
|
+
let(:no_referee_match_serialized) { Infostrada::Match.new(no_referee_match.clone).as_json }
|
182
|
+
let(:no_stadium_match_serialized) { Infostrada::Match.new(no_stadium_match.clone).as_json }
|
183
|
+
|
184
|
+
context 'complete match' do
|
185
|
+
let(:match) { Infostrada::Match.from_json(complete_match_serialized.clone) }
|
186
|
+
|
187
|
+
it 'has id' do
|
188
|
+
expect(match.id).to be(complete_match_serialized['id'])
|
189
|
+
end
|
190
|
+
|
191
|
+
it 'has rescheduled' do
|
192
|
+
expect(match.rescheduled).to be(complete_match_serialized['rescheduled'])
|
193
|
+
end
|
194
|
+
|
195
|
+
it 'has round' do
|
196
|
+
expect(match.round).to be(complete_match_serialized['round'])
|
197
|
+
end
|
198
|
+
|
199
|
+
it 'has date' do
|
200
|
+
expect(match.date).not_to be(nil)
|
201
|
+
end
|
202
|
+
|
203
|
+
it 'has time_unknown' do
|
204
|
+
expect(match.time_unknown).to be(false)
|
205
|
+
end
|
206
|
+
|
207
|
+
it 'has date_unknown' do
|
208
|
+
expect(match.date_unknown).to be(false)
|
209
|
+
end
|
210
|
+
|
211
|
+
it 'has aggregate_winner_id' do
|
212
|
+
expect(match.aggregate_winner_id).to be(complete_match_serialized['aggregate_winner_id'])
|
213
|
+
end
|
214
|
+
|
215
|
+
it 'not_has current_period_started_at' do
|
216
|
+
expect(match.current_period_started_at).to be(nil)
|
217
|
+
end
|
218
|
+
|
219
|
+
it 'has status_code' do
|
220
|
+
expect(match.status_code).to be(complete_match_serialized['status_code'])
|
221
|
+
end
|
222
|
+
|
223
|
+
it 'has status' do
|
224
|
+
expect(match.status).to be(complete_match_serialized['status'])
|
225
|
+
end
|
226
|
+
|
227
|
+
it 'has status_short' do
|
228
|
+
expect(match.status_short).to be(complete_match_serialized['status_short'])
|
229
|
+
end
|
230
|
+
|
231
|
+
it 'has leg' do
|
232
|
+
expect(match.leg).to be(complete_match_serialized['leg'])
|
233
|
+
end
|
234
|
+
|
235
|
+
it 'has started_at' do
|
236
|
+
expect(match.started_at).not_to be(nil)
|
237
|
+
end
|
238
|
+
|
239
|
+
it 'has knockout_phase_id' do
|
240
|
+
expect(match.knockout_phase_id).to be(complete_match_serialized['knockout_phase_id'])
|
241
|
+
end
|
242
|
+
|
243
|
+
it 'has stadium_id' do
|
244
|
+
expect(match.stadium_id).to be(complete_match_serialized['stadium_id'])
|
245
|
+
end
|
246
|
+
|
247
|
+
it 'has stadium_name' do
|
248
|
+
expect(match.stadium_name).to be(complete_match_serialized['stadium_name'])
|
249
|
+
end
|
250
|
+
|
251
|
+
it 'has spectators' do
|
252
|
+
expect(match.spectators).to be(complete_match_serialized['spectators'])
|
253
|
+
end
|
254
|
+
|
255
|
+
it 'has city' do
|
256
|
+
expect(match.city).to be(complete_match_serialized['city'])
|
257
|
+
end
|
258
|
+
|
259
|
+
it 'has live' do
|
260
|
+
expect(match.live).to be(complete_match_serialized['live'])
|
261
|
+
end
|
262
|
+
|
263
|
+
it 'has started' do
|
264
|
+
expect(match.started).to be(complete_match_serialized['started'])
|
265
|
+
end
|
266
|
+
|
267
|
+
it 'has finished' do
|
268
|
+
expect(match.finished).to be(complete_match_serialized['finished'])
|
269
|
+
end
|
270
|
+
|
271
|
+
it 'has awarded' do
|
272
|
+
expect(match.awarded).to be(complete_match_serialized['awarded'])
|
273
|
+
end
|
274
|
+
|
275
|
+
it 'has live_score' do
|
276
|
+
expect(match.live_score).to be(complete_match_serialized['live_score'])
|
277
|
+
end
|
278
|
+
|
279
|
+
it 'has live_goals' do
|
280
|
+
expect(match.live_goals).to be(complete_match_serialized['live_goals'])
|
281
|
+
end
|
282
|
+
|
283
|
+
it 'has live_lineup' do
|
284
|
+
expect(match.live_lineup).to be(complete_match_serialized['live_lineup'])
|
285
|
+
end
|
286
|
+
|
287
|
+
it 'has lineup_provisional' do
|
288
|
+
expect(match.lineup_provisional).to be(complete_match_serialized['lineup_provisional'])
|
289
|
+
end
|
290
|
+
|
291
|
+
it 'has lineup_official' do
|
292
|
+
expect(match.lineup_official).to be(complete_match_serialized['lineup_official'])
|
293
|
+
end
|
294
|
+
|
295
|
+
it 'has period' do
|
296
|
+
expect(match.period).to be(complete_match_serialized['period'])
|
297
|
+
end
|
298
|
+
|
299
|
+
it 'has referee' do
|
300
|
+
expect(match.referee).not_to be(nil)
|
301
|
+
end
|
302
|
+
|
303
|
+
it 'has phase' do
|
304
|
+
expect(match.phase).not_to be(nil)
|
305
|
+
end
|
306
|
+
|
307
|
+
it 'has home_team' do
|
308
|
+
expect(match.home_team).not_to be(nil)
|
309
|
+
end
|
310
|
+
|
311
|
+
it 'has away_team' do
|
312
|
+
expect(match.away_team).not_to be(nil)
|
313
|
+
end
|
314
|
+
|
315
|
+
it 'has goals' do
|
316
|
+
expect(match.goals).not_to be(nil)
|
317
|
+
end
|
318
|
+
|
319
|
+
it 'has edition' do
|
320
|
+
expect(match.edition).not_to be(nil)
|
321
|
+
end
|
322
|
+
end
|
323
|
+
|
324
|
+
context 'without referee' do
|
325
|
+
let(:match) { Infostrada::Match.from_json(no_referee_match_serialized.clone) }
|
326
|
+
|
327
|
+
it 'not_fails' do
|
328
|
+
expect(match).not_to be(nil)
|
329
|
+
end
|
330
|
+
|
331
|
+
it 'not_has referee' do
|
332
|
+
expect(match.referee).to be(nil)
|
333
|
+
end
|
334
|
+
end
|
335
|
+
|
336
|
+
context 'without stadium' do
|
337
|
+
let(:match) { Infostrada::Match.from_json(no_stadium_match_serialized.clone) }
|
338
|
+
|
339
|
+
it 'not_fails' do
|
340
|
+
expect(match).not_to be(nil)
|
341
|
+
end
|
342
|
+
|
343
|
+
it 'not_has stadium_id' do
|
344
|
+
expect(match.stadium_id).to be(nil)
|
345
|
+
end
|
346
|
+
|
347
|
+
it 'not_has stadium_name' do
|
348
|
+
expect(match.stadium_name).to be(nil)
|
349
|
+
end
|
350
|
+
end
|
351
|
+
end
|
352
|
+
end
|
353
|
+
|
354
|
+
context 'With two handed elimination' do
|
355
|
+
context 'First round upcoming' do
|
356
|
+
let(:match_json) { JSONHelper::Match.get(:two_handed_round_first_leg_upcoming) }
|
357
|
+
let(:match) { Infostrada::Match.new(match_json.clone) }
|
358
|
+
let(:match_serialized) { match.as_json }
|
359
|
+
describe '#initialize' do
|
360
|
+
it 'not_fails' do
|
361
|
+
expect(match).not_to be_nil
|
362
|
+
end
|
363
|
+
|
364
|
+
it 'is_first_leg' do
|
365
|
+
expect(match.leg).to be(1)
|
366
|
+
end
|
367
|
+
end
|
368
|
+
|
369
|
+
describe '#from_json' do
|
370
|
+
it 'has id' do
|
371
|
+
expect(match.id).to be(match_serialized['id'])
|
372
|
+
end
|
373
|
+
|
374
|
+
it 'is_first_leg' do
|
375
|
+
expect(match.leg).to be(match_serialized['leg'])
|
376
|
+
end
|
377
|
+
end
|
378
|
+
end
|
379
|
+
|
380
|
+
describe 'Second round upcoming' do
|
381
|
+
let(:match_json) { JSONHelper::Match.get(:two_handed_round_second_leg_upcoming) }
|
382
|
+
let(:match) {Infostrada::Match.new(match_json.clone)}
|
383
|
+
let(:match_serialized) { match.as_json }
|
384
|
+
describe '#initialize' do
|
385
|
+
it 'not_fails' do
|
386
|
+
expect(match).not_to be_nil
|
387
|
+
end
|
388
|
+
|
389
|
+
it 'is_second_leg' do
|
390
|
+
expect(match.leg).to be(2)
|
391
|
+
end
|
392
|
+
end
|
393
|
+
|
394
|
+
describe '#from_json' do
|
395
|
+
it 'has id' do
|
396
|
+
expect(match.id).to be(match_serialized['id'])
|
397
|
+
end
|
398
|
+
|
399
|
+
it 'is_second_leg' do
|
400
|
+
expect(match.leg).to be(match_serialized['leg'])
|
401
|
+
end
|
402
|
+
end
|
403
|
+
end
|
404
|
+
|
405
|
+
describe 'Second round finished' do
|
406
|
+
let(:match_json) { JSONHelper::Match.get(:two_handed_round_second_leg_finished) }
|
407
|
+
let(:match) {Infostrada::Match.new(match_json.clone)}
|
408
|
+
let(:match_serialized) { match.as_json }
|
409
|
+
describe '#initialize' do
|
410
|
+
it 'not_fails' do
|
411
|
+
expect(match).not_to be_nil
|
412
|
+
end
|
413
|
+
|
414
|
+
it 'has aggregate_winner' do
|
415
|
+
expect(match.aggregate_winner_id).not_to be_nil
|
416
|
+
end
|
417
|
+
end
|
418
|
+
|
419
|
+
describe '#from_json' do
|
420
|
+
it 'has id' do
|
421
|
+
expect(match.id).to be(match_serialized['id'])
|
422
|
+
end
|
423
|
+
|
424
|
+
it 'is_has_aggregate_winner' do
|
425
|
+
expect(match.aggregate_winner_id).to be(match_serialized['aggregate_winner_id'])
|
426
|
+
end
|
427
|
+
end
|
428
|
+
end
|
429
|
+
end
|
430
|
+
end
|