chgk_rating 2.1.0 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/Gemfile +3 -1
- data/LICENSE +1 -1
- data/README.md +4 -4
- data/Rakefile +4 -2
- data/chgk_rating.gemspec +19 -12
- data/lib/chgk_rating/attribute_mappings.rb +107 -108
- data/lib/chgk_rating/chgk_object.rb +5 -1
- data/lib/chgk_rating/client.rb +4 -2
- data/lib/chgk_rating/collections/base.rb +20 -15
- data/lib/chgk_rating/collections/players.rb +3 -1
- data/lib/chgk_rating/collections/ratings/player_ratings.rb +3 -1
- data/lib/chgk_rating/collections/ratings/team_ratings.rb +3 -1
- data/lib/chgk_rating/collections/recaps.rb +4 -2
- data/lib/chgk_rating/collections/teams.rb +3 -1
- data/lib/chgk_rating/collections/tournaments/player_tournaments.rb +12 -8
- data/lib/chgk_rating/collections/tournaments/tournament_team_players.rb +3 -1
- data/lib/chgk_rating/collections/tournaments/tournament_team_results.rb +3 -1
- data/lib/chgk_rating/collections/tournaments/tournament_teams.rb +4 -1
- data/lib/chgk_rating/collections/tournaments/tournaments.rb +12 -8
- data/lib/chgk_rating/concerns/searching.rb +10 -9
- data/lib/chgk_rating/connection.rb +10 -8
- data/lib/chgk_rating/error.rb +7 -5
- data/lib/chgk_rating/models/base.rb +23 -16
- data/lib/chgk_rating/models/player.rb +3 -1
- data/lib/chgk_rating/models/rating/player_rating.rb +3 -1
- data/lib/chgk_rating/models/rating/rating.rb +3 -1
- data/lib/chgk_rating/models/rating/team_rating.rb +3 -1
- data/lib/chgk_rating/models/recap.rb +3 -1
- data/lib/chgk_rating/models/team.rb +3 -1
- data/lib/chgk_rating/models/tournament/player_tournament.rb +3 -1
- data/lib/chgk_rating/models/tournament/tournament.rb +3 -1
- data/lib/chgk_rating/models/tournament/tournament_team.rb +3 -1
- data/lib/chgk_rating/models/tournament/tournament_team_player.rb +3 -1
- data/lib/chgk_rating/models/tournament/tournament_team_result.rb +3 -1
- data/lib/chgk_rating/request.rb +10 -9
- data/lib/chgk_rating/utils/snakecase.rb +9 -7
- data/lib/chgk_rating/utils/transformations.rb +42 -36
- data/lib/chgk_rating/version.rb +4 -2
- data/lib/chgk_rating.rb +3 -1
- data/lib/ext/date.rb +6 -8
- data/lib/ext/date_time.rb +4 -2
- data/lib/ext/uri.rb +6 -6
- metadata +61 -80
- data/spec/lib/chgk_rating/client_spec.rb +0 -247
- data/spec/lib/chgk_rating/collections/player_ratings_spec.rb +0 -15
- data/spec/lib/chgk_rating/collections/players_spec.rb +0 -45
- data/spec/lib/chgk_rating/collections/recaps_spec.rb +0 -21
- data/spec/lib/chgk_rating/collections/team_ratings_spec.rb +0 -25
- data/spec/lib/chgk_rating/collections/teams_spec.rb +0 -42
- data/spec/lib/chgk_rating/collections/tournaments/player_tournaments_spec.rb +0 -38
- data/spec/lib/chgk_rating/collections/tournaments/tournament_team_players_spec.rb +0 -18
- data/spec/lib/chgk_rating/collections/tournaments/tournament_team_results_spec.rb +0 -17
- data/spec/lib/chgk_rating/collections/tournaments/tournament_teams_spec.rb +0 -58
- data/spec/lib/chgk_rating/collections/tournaments/tournaments_spec.rb +0 -62
- data/spec/lib/chgk_rating/models/base_spec.rb +0 -34
- data/spec/lib/chgk_rating/models/player_rating_spec.rb +0 -22
- data/spec/lib/chgk_rating/models/player_spec.rb +0 -62
- data/spec/lib/chgk_rating/models/recap_spec.rb +0 -35
- data/spec/lib/chgk_rating/models/team_rating_spec.rb +0 -27
- data/spec/lib/chgk_rating/models/team_spec.rb +0 -97
- data/spec/lib/chgk_rating/models/tournament/tournament_spec.rb +0 -95
- data/spec/lib/chgk_rating/models/tournament/tournament_team_player_spec.rb +0 -21
- data/spec/lib/chgk_rating/models/tournament/tournament_team_result_spec.rb +0 -19
- data/spec/lib/chgk_rating/models/tournament/tournament_team_spec.rb +0 -36
- data/spec/lib/chgk_rating/utils/snakecase_spec.rb +0 -12
- data/spec/lib/chgk_rating/utils/transformations_spec.rb +0 -16
- data/spec/lib/chgk_rating_spec.rb +0 -5
- data/spec/lib/ext/date_spec.rb +0 -7
- data/spec/lib/ext/date_time_spec.rb +0 -11
- data/spec/lib/ext/uri_spec.rb +0 -7
- data/spec/spec_helper.rb +0 -15
- data/spec/support/shared_examples.rb +0 -63
- data/spec/support/test_client.rb +0 -6
- data/spec/support/vcr.rb +0 -11
@@ -1,17 +0,0 @@
|
|
1
|
-
RSpec.describe ChgkRating::Collections::TournamentTeamResults do
|
2
|
-
subject do
|
3
|
-
VCR.use_cassette 'team_results_at_tournament' do
|
4
|
-
described_class.new(tournament: 3506, team: 52853)
|
5
|
-
end
|
6
|
-
end
|
7
|
-
|
8
|
-
it_behaves_like 'tournament team result' do
|
9
|
-
let(:team_result) { subject[0] }
|
10
|
-
end
|
11
|
-
it_behaves_like 'not a hash'
|
12
|
-
it_behaves_like 'an array'
|
13
|
-
|
14
|
-
specify '#to_a' do
|
15
|
-
expect(subject.to_a[2]['tour']).to eq '3'
|
16
|
-
end
|
17
|
-
end
|
@@ -1,58 +0,0 @@
|
|
1
|
-
RSpec.describe ChgkRating::Collections::TournamentTeams do
|
2
|
-
subject do
|
3
|
-
VCR.use_cassette 'teams_at_tournament' do
|
4
|
-
described_class.new(tournament: 3506)
|
5
|
-
end
|
6
|
-
end
|
7
|
-
let(:team) { subject[0] }
|
8
|
-
let(:tournament_team_h) { team.to_h }
|
9
|
-
|
10
|
-
it_behaves_like 'not a hash'
|
11
|
-
it_behaves_like 'an array'
|
12
|
-
|
13
|
-
specify('#id') { expect(team.id).to eq '2124' }
|
14
|
-
specify('#current_name') { expect(team.current_name).to eq 'Полосатый мамонт' }
|
15
|
-
specify('#base_name') { expect(team.base_name).to eq 'Полосатый мамонт' }
|
16
|
-
specify('#position') { expect(team.position).to eq 3 }
|
17
|
-
specify('#questions_total') { expect(team.questions_total).to eq 34 }
|
18
|
-
specify('#bonus_b') { expect(team.bonus_b).to eq 421 }
|
19
|
-
specify('#tech_rating_rt') { expect(team.tech_rating_rt).to eq 2583 }
|
20
|
-
specify('#tech_rating_rg') { expect(team.tech_rating_rg).to eq 2583 }
|
21
|
-
specify('#tech_rating_rb') { expect(team.tech_rating_rb).to eq 2525 }
|
22
|
-
specify('#predicted_position') { expect(team.predicted_position).to eq 2 }
|
23
|
-
specify('#diff_bonus') { expect(team.diff_bonus).to eq -48 }
|
24
|
-
specify('#included_in_rating') { expect(team.included_in_rating).to eq true }
|
25
|
-
specify('#result') { expect(team.result).to eq [true, true, true, false, true, true,
|
26
|
-
true, true, true, true, true,
|
27
|
-
true, true, false, false, false, false,
|
28
|
-
true, true, true, true, true, false, true,
|
29
|
-
true, true, false, false, true, false,
|
30
|
-
true, true, false, true, true, false, true,
|
31
|
-
false, true, false, true, true, true,
|
32
|
-
false, true, true, true, true] }
|
33
|
-
|
34
|
-
specify '#to_a' do
|
35
|
-
expect(subject.to_a[2]['idteam']).to eq '28434'
|
36
|
-
end
|
37
|
-
|
38
|
-
# to_h for a fully loaded model
|
39
|
-
specify '#to_h for a model' do
|
40
|
-
expect(tournament_team_h['idteam']).to eq '2124'
|
41
|
-
expect(tournament_team_h['position']).to eq '3.0'
|
42
|
-
expect(tournament_team_h['questions_total']).to eq '34'
|
43
|
-
expect(tournament_team_h['mask']).to eq ["1", "1", "1", "0", "1", "1", "1", "1", "1", "1", "1",
|
44
|
-
"1", "1", "0", "0", "0", "0", "1", "1", "1", "1", "1",
|
45
|
-
"0", "1", "1", "1", "0", "0", "1", "0", "1", "1", "0",
|
46
|
-
"1", "1", "0", "1", "0", "1", "0", "1", "1", "1", "0",
|
47
|
-
"1", "1", "1", "1"]
|
48
|
-
expect(tournament_team_h['bonus_b']).to eq '421'
|
49
|
-
expect(tournament_team_h['tech_rating_rt']).to eq '2583'
|
50
|
-
expect(tournament_team_h['tech_rating_rg']).to eq '2583'
|
51
|
-
expect(tournament_team_h['tech_rating_rb']).to eq '2525'
|
52
|
-
expect(tournament_team_h['diff_bonus']).to eq '-48'
|
53
|
-
expect(tournament_team_h['predicted_position']).to eq '2'
|
54
|
-
expect(tournament_team_h['included_in_rating']).to eq '1'
|
55
|
-
expect(tournament_team_h['current_name']).to eq 'Полосатый мамонт'
|
56
|
-
expect(tournament_team_h['base_name']).to eq 'Полосатый мамонт'
|
57
|
-
end
|
58
|
-
end
|
@@ -1,62 +0,0 @@
|
|
1
|
-
RSpec.describe ChgkRating::Collections::Tournaments do
|
2
|
-
context 'all tournaments for a team by season' do
|
3
|
-
subject do
|
4
|
-
VCR.use_cassette 'team_tournaments_season' do
|
5
|
-
described_class.new(team: 1, season_id: 4)
|
6
|
-
end
|
7
|
-
end
|
8
|
-
|
9
|
-
it_behaves_like 'not a hash'
|
10
|
-
it_behaves_like 'an array'
|
11
|
-
|
12
|
-
specify '#to_a' do
|
13
|
-
tournaments_arr = subject.to_a
|
14
|
-
expect(tournaments_arr[2]['idtournament']).to eq '150'
|
15
|
-
end
|
16
|
-
specify('#id') { expect(subject[0].id).to eq '188' }
|
17
|
-
specify('#team') { expect(subject.team.id).to eq 1 }
|
18
|
-
specify('#season_id') { expect(subject.season_id).to eq 4 }
|
19
|
-
end
|
20
|
-
|
21
|
-
context 'all tournaments' do
|
22
|
-
subject do
|
23
|
-
VCR.use_cassette 'tournaments' do
|
24
|
-
described_class.new
|
25
|
-
end
|
26
|
-
end
|
27
|
-
let(:tournament) { subject[0] }
|
28
|
-
|
29
|
-
it_behaves_like 'not a hash'
|
30
|
-
it_behaves_like 'an array'
|
31
|
-
|
32
|
-
specify '#to_a' do
|
33
|
-
tournaments_arr = subject.to_a
|
34
|
-
expect(tournaments_arr[10]['idtournament']).to eq '1538'
|
35
|
-
end
|
36
|
-
specify('#id') { expect(tournament.id).to eq '1908' }
|
37
|
-
specify('#name') { expect(tournament.name).to eq 'Фестиваль в Мариуполе' }
|
38
|
-
specify('#date_start') { expect(tournament.date_start).to eq DateTime.parse('1989-09-01 00:00:00') }
|
39
|
-
specify('#date_end') { expect(tournament.date_end).to eq DateTime.parse('1989-09-03 00:00:00') }
|
40
|
-
specify('#type_name') { expect(tournament.type_name).to eq 'Обычный' }
|
41
|
-
end
|
42
|
-
|
43
|
-
context 'tournaments for a team' do
|
44
|
-
subject do
|
45
|
-
VCR.use_cassette 'team_tournaments' do
|
46
|
-
described_class.new(team: 1)
|
47
|
-
end
|
48
|
-
end
|
49
|
-
let(:tournament) { subject['8'][0] }
|
50
|
-
|
51
|
-
it_behaves_like 'a hash'
|
52
|
-
it_behaves_like 'not an array'
|
53
|
-
|
54
|
-
specify '#to_h' do
|
55
|
-
subject_h = subject.to_h['7']
|
56
|
-
expect(subject_h['tournaments'][0]['idtournament']).to eq '367'
|
57
|
-
expect(subject_h['idseason']).to eq '7'
|
58
|
-
expect(subject_h['idteam']).to eq '1'
|
59
|
-
end
|
60
|
-
specify('#id') { expect(tournament.id).to eq '424' }
|
61
|
-
end
|
62
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
RSpec.describe ChgkRating::Models::Base do
|
2
|
-
describe '.no_lazy_support!' do
|
3
|
-
let!(:klass) do
|
4
|
-
Class.new(described_class) do
|
5
|
-
no_lazy_support!
|
6
|
-
def initialize ; end
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
subject { klass.new }
|
11
|
-
|
12
|
-
it { is_expected.not_to respond_to(:lazy) }
|
13
|
-
|
14
|
-
it 'should define NO_LAZY_SUPPORT constant' do
|
15
|
-
expect(klass::NO_LAZY_SUPPORT).to eq(true)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
describe '.no_eager_loading!' do
|
20
|
-
let!(:klass) do
|
21
|
-
Class.new(described_class) do
|
22
|
-
no_eager_loading!
|
23
|
-
def initialize ; end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
subject { klass.new }
|
28
|
-
|
29
|
-
it 'should raise an EagerLoadingNotSupported error' do
|
30
|
-
expect( -> { subject.eager_load! }).to raise_error(ChgkRating::Error::EagerLoadingNotSupported).
|
31
|
-
with_message 'Eager loading is not supported for this resource.'
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
RSpec.describe ChgkRating::Models::PlayerRating do
|
2
|
-
subject do
|
3
|
-
VCR.use_cassette 'rating_player_release' do
|
4
|
-
described_class.new 1336, player: 1000
|
5
|
-
end
|
6
|
-
end
|
7
|
-
|
8
|
-
let(:rating_h) { subject.to_h }
|
9
|
-
|
10
|
-
specify('#player') { expect(subject.player.id).to eq '1000' }
|
11
|
-
specify('#release_id') { expect(subject.release_id).to eq '1336' }
|
12
|
-
specify('#rating') { expect(subject.rating).to eq 7674 }
|
13
|
-
specify('#rating_position') { expect(subject.rating_position).to eq 1417 }
|
14
|
-
specify('#date') { expect(subject.date).to eq Date.new(2018, 04, 12) }
|
15
|
-
specify('#tournaments_in_year') { expect(subject.tournaments_in_year).to eq 15 }
|
16
|
-
specify('#tournament_count_total') { expect(subject.tournament_count_total).to eq 284 }
|
17
|
-
specify '#to_h' do
|
18
|
-
expect(rating_h['idplayer']).to eq '1000'
|
19
|
-
expect(rating_h['tournaments_in_year']).to eq '15'
|
20
|
-
expect(rating_h['tournament_count_total']).to eq '284'
|
21
|
-
end
|
22
|
-
end
|
@@ -1,62 +0,0 @@
|
|
1
|
-
RSpec.describe ChgkRating::Models::Player do
|
2
|
-
subject do
|
3
|
-
VCR.use_cassette 'player' do
|
4
|
-
described_class.new 42511
|
5
|
-
end
|
6
|
-
end
|
7
|
-
let(:player_h) { subject.to_h }
|
8
|
-
let(:lazy_player) { described_class.new 42511, lazy: true }
|
9
|
-
|
10
|
-
it_behaves_like 'model with eager loading'
|
11
|
-
it_behaves_like 'model with lazy support'
|
12
|
-
|
13
|
-
specify('#id') { expect(subject.id).to eq '42511' }
|
14
|
-
specify('#surname') { expect(subject.surname).to eq 'Некрылов' }
|
15
|
-
specify('#name') { expect(subject.name).to eq 'Николай' }
|
16
|
-
specify('#patronymic') { expect(subject.patronymic).to eq 'Андреевич' }
|
17
|
-
specify('#db_chgk_info_tag') { expect(subject.db_chgk_info_tag).to eq 'nnekrylov' }
|
18
|
-
specify('#comment') { expect(subject.comment).to eq '' }
|
19
|
-
|
20
|
-
specify '#to_h' do
|
21
|
-
expect(player_h['idplayer']).to eq '42511'
|
22
|
-
expect(player_h['name']).to eq 'Николай'
|
23
|
-
expect(player_h['surname']).to eq 'Некрылов'
|
24
|
-
expect(player_h['patronymic']).to eq 'Андреевич'
|
25
|
-
expect(player_h['comment']).to eq ''
|
26
|
-
expect(player_h['db_chgk_info_tag']).to eq 'nnekrylov'
|
27
|
-
end
|
28
|
-
|
29
|
-
specify '#eager_load!' do
|
30
|
-
VCR.use_cassette 'player' do
|
31
|
-
lazy_player.eager_load!
|
32
|
-
end
|
33
|
-
expect(lazy_player.name).to eq 'Николай'
|
34
|
-
end
|
35
|
-
|
36
|
-
describe '#rating' do
|
37
|
-
let(:player_rating) do
|
38
|
-
VCR.use_cassette 'player_rating_release' do
|
39
|
-
subject.rating 1000
|
40
|
-
end
|
41
|
-
end
|
42
|
-
it { expect(player_rating).to be_an_instance_of ChgkRating::Models::PlayerRating }
|
43
|
-
end
|
44
|
-
|
45
|
-
describe '#ratings' do
|
46
|
-
let(:player_ratings) do
|
47
|
-
VCR.use_cassette 'player_ratings_all_releases' do
|
48
|
-
subject.ratings
|
49
|
-
end
|
50
|
-
end
|
51
|
-
it { expect(player_ratings).to be_an_instance_of ChgkRating::Collections::PlayerRatings }
|
52
|
-
end
|
53
|
-
|
54
|
-
describe '#tournaments' do
|
55
|
-
let(:player_tournaments) do
|
56
|
-
VCR.use_cassette 'player_tournaments2' do
|
57
|
-
subject.tournaments
|
58
|
-
end
|
59
|
-
end
|
60
|
-
it { expect(player_tournaments).to be_an_instance_of ChgkRating::Collections::PlayerTournaments }
|
61
|
-
end
|
62
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
RSpec.describe ChgkRating::Models::Recap do
|
2
|
-
subject do
|
3
|
-
VCR.use_cassette 'recap_last_season' do
|
4
|
-
described_class.new :last, team: 7931
|
5
|
-
end
|
6
|
-
end
|
7
|
-
let(:recap_h) { subject.to_h }
|
8
|
-
|
9
|
-
it_behaves_like 'model without eager loading'
|
10
|
-
it_behaves_like 'model without lazy support'
|
11
|
-
|
12
|
-
specify('#season_id') { expect(subject.season_id).to eq '51' }
|
13
|
-
specify('#team') { expect(subject.team.id).to eq '7931' }
|
14
|
-
specify('#captain') { expect(subject.captain.id).to eq '23539' }
|
15
|
-
specify('#players') { expect(subject.players.first.id).to eq '2668' }
|
16
|
-
specify '#to_h' do
|
17
|
-
expect(recap_h['idseason']).to eq '51'
|
18
|
-
expect(recap_h['idteam']).to eq '7931'
|
19
|
-
expect(recap_h['captain']).to eq '23539'
|
20
|
-
expect(recap_h['players']).to eq %w(2668 6654 23539 53735 94783 98697 115867 149858)
|
21
|
-
end
|
22
|
-
|
23
|
-
context 'with season number' do
|
24
|
-
subject do
|
25
|
-
VCR.use_cassette 'recap' do
|
26
|
-
described_class.new 9, team: 1
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
specify('#season_id') { expect(subject.season_id).to eq '9' }
|
31
|
-
specify('#team') { expect(subject.team.id).to eq '1' }
|
32
|
-
specify('#captain') { expect(subject.captain.id).to eq '2935' }
|
33
|
-
specify('#players') { expect(subject.players.first.id).to eq '2935' }
|
34
|
-
end
|
35
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
RSpec.describe ChgkRating::Models::TeamRating do
|
2
|
-
subject do
|
3
|
-
VCR.use_cassette 'rating_release' do
|
4
|
-
described_class.new 24, team: 1
|
5
|
-
end
|
6
|
-
end
|
7
|
-
let(:rating_h) { subject.to_h }
|
8
|
-
|
9
|
-
it_behaves_like 'model without eager loading'
|
10
|
-
it_behaves_like 'model without lazy support'
|
11
|
-
|
12
|
-
specify('#team') { expect(subject.team.id).to eq '1' }
|
13
|
-
specify('#release_id') { expect(subject.release_id).to eq '24' }
|
14
|
-
specify('#rating') { expect(subject.rating).to eq 9071 }
|
15
|
-
specify('#rating_position') { expect(subject.rating_position).to eq 9 }
|
16
|
-
specify('#date') { expect(subject.date).to eq Date.new(1999, 01, 07) }
|
17
|
-
specify('#formula') { expect(subject.formula).to eq :b }
|
18
|
-
|
19
|
-
specify '#to_h' do
|
20
|
-
expect(rating_h['idteam']).to eq '1'
|
21
|
-
expect(rating_h['idrelease']).to eq '24'
|
22
|
-
expect(rating_h['rating']).to eq '9071'
|
23
|
-
expect(rating_h['rating_position']).to eq '9'
|
24
|
-
expect(rating_h['date']).to eq '1999-01-07'
|
25
|
-
expect(rating_h['formula']).to eq 'b'
|
26
|
-
end
|
27
|
-
end
|
@@ -1,97 +0,0 @@
|
|
1
|
-
RSpec.describe ChgkRating::Models::Team do
|
2
|
-
subject do
|
3
|
-
VCR.use_cassette 'team' do
|
4
|
-
described_class.new 1
|
5
|
-
end
|
6
|
-
end
|
7
|
-
let(:team_h) { subject.to_h }
|
8
|
-
let(:lazy_team) { described_class.new 1, lazy: true }
|
9
|
-
|
10
|
-
it_behaves_like 'model with eager loading'
|
11
|
-
it_behaves_like 'model with lazy support'
|
12
|
-
|
13
|
-
specify('#id') { expect(subject.id).to eq '1' }
|
14
|
-
specify('#town') { expect(subject.town).to eq 'Москва' }
|
15
|
-
specify('#region_name') { expect(subject.region_name).to eq 'Москва' }
|
16
|
-
specify('#country_name') { expect(subject.country_name).to eq 'Россия' }
|
17
|
-
specify('#tournaments_total') { expect(subject.tournaments_total).to eq 101 }
|
18
|
-
specify('#tournaments_this_season') { expect(subject.tournaments_this_season).to eq 0 }
|
19
|
-
specify('#name') { expect(subject.name).to eq 'Неспроста' }
|
20
|
-
specify('#comment') { expect(subject.comment).to eq '' }
|
21
|
-
|
22
|
-
specify '#tournaments' do
|
23
|
-
tournaments = VCR.use_cassette 'team_tournaments' do
|
24
|
-
subject.tournaments['2']
|
25
|
-
end
|
26
|
-
|
27
|
-
expect(tournaments[0].id).to eq '54'
|
28
|
-
expect(tournaments[1].id).to eq '25'
|
29
|
-
end
|
30
|
-
|
31
|
-
specify '#to_h' do
|
32
|
-
expect(team_h['idteam']).to eq '1'
|
33
|
-
expect(team_h['name']).to eq 'Неспроста'
|
34
|
-
expect(team_h['town']).to eq 'Москва'
|
35
|
-
expect(team_h['region_name']).to eq 'Москва'
|
36
|
-
expect(team_h['country_name']).to eq 'Россия'
|
37
|
-
expect(team_h['tournaments_total']).to eq '101'
|
38
|
-
expect(team_h['tournaments_this_season']).to eq '0'
|
39
|
-
expect(team_h['comment']).to eq ''
|
40
|
-
end
|
41
|
-
|
42
|
-
specify '#eager_load!' do
|
43
|
-
VCR.use_cassette 'team' do
|
44
|
-
lazy_team.eager_load!
|
45
|
-
end
|
46
|
-
expect(lazy_team.name).to eq 'Неспроста'
|
47
|
-
end
|
48
|
-
|
49
|
-
describe '#at_tournament' do
|
50
|
-
it { expect(subject.at_tournament('1000')).to be_an_instance_of ChgkRating::Models::TournamentTeam }
|
51
|
-
end
|
52
|
-
|
53
|
-
describe '#rating' do
|
54
|
-
let(:team_rating) do
|
55
|
-
VCR.use_cassette 'rating_release' do
|
56
|
-
subject.rating 24
|
57
|
-
end
|
58
|
-
end
|
59
|
-
it { expect(team_rating).to be_an_instance_of ChgkRating::Models::TeamRating }
|
60
|
-
end
|
61
|
-
|
62
|
-
describe '#recap' do
|
63
|
-
let(:team_recap) do
|
64
|
-
VCR.use_cassette 'recap' do
|
65
|
-
subject.recap 9
|
66
|
-
end
|
67
|
-
end
|
68
|
-
it { expect(team_recap).to be_an_instance_of ChgkRating::Models::Recap }
|
69
|
-
end
|
70
|
-
|
71
|
-
describe '#recaps' do
|
72
|
-
let(:team_recaps) do
|
73
|
-
VCR.use_cassette 'recaps' do
|
74
|
-
subject.recaps
|
75
|
-
end
|
76
|
-
end
|
77
|
-
it { expect(team_recaps).to be_an_instance_of ChgkRating::Collections::Recaps }
|
78
|
-
end
|
79
|
-
|
80
|
-
describe '#tournaments' do
|
81
|
-
let(:team_tournaments) do
|
82
|
-
VCR.use_cassette 'team_tournaments' do
|
83
|
-
subject.tournaments
|
84
|
-
end
|
85
|
-
end
|
86
|
-
it { expect(team_tournaments).to be_an_instance_of ChgkRating::Collections::Tournaments }
|
87
|
-
end
|
88
|
-
|
89
|
-
describe '#ratings' do
|
90
|
-
let(:team_ratings) do
|
91
|
-
VCR.use_cassette 'team_ratings' do
|
92
|
-
subject.ratings
|
93
|
-
end
|
94
|
-
end
|
95
|
-
it { expect(team_ratings).to be_an_instance_of ChgkRating::Collections::TeamRatings }
|
96
|
-
end
|
97
|
-
end
|
@@ -1,95 +0,0 @@
|
|
1
|
-
RSpec.describe ChgkRating::Models::Tournament do
|
2
|
-
subject do
|
3
|
-
VCR.use_cassette 'tournament' do
|
4
|
-
described_class.new 3506
|
5
|
-
end
|
6
|
-
end
|
7
|
-
let(:lazy_tournament) { described_class.new 3506, lazy: true }
|
8
|
-
let(:tournament_h) { subject.to_h }
|
9
|
-
|
10
|
-
it_behaves_like 'model with eager loading'
|
11
|
-
it_behaves_like 'model with lazy support'
|
12
|
-
|
13
|
-
specify('#id') { expect(subject.id).to eq '3506' }
|
14
|
-
specify('#name') { expect(subject.name).to eq 'Чемпионат Перми и Пермского края' }
|
15
|
-
specify('#long_name') { expect(subject.long_name).to eq 'XV Чемпионат Перми и Пермского края по игре "Что? Где? Когда?"' }
|
16
|
-
specify('#date_start') { expect(subject.date_start).to eq DateTime.parse('2015-11-08 14:00:00') }
|
17
|
-
specify('#date_end') { expect(subject.date_end).to eq DateTime.parse('2015-11-08 18:00:00') }
|
18
|
-
specify('#tour_count') { expect(subject.tour_count).to eq 4 }
|
19
|
-
specify('#tour_questions') { expect(subject.tour_questions).to eq 12 }
|
20
|
-
specify('#tour_ques_per_tour') { expect(subject.tour_ques_per_tour).to be_nil }
|
21
|
-
specify('#questions_total') { expect(subject.questions_total).to eq 48 }
|
22
|
-
specify('#type_name') { expect(subject.type_name).to eq 'Обычный' }
|
23
|
-
specify('#main_payment_value') { expect(subject.main_payment_value).to eq 660 }
|
24
|
-
specify('#main_payment_currency') { expect(subject.main_payment_currency).to eq 'руб' }
|
25
|
-
specify('#discounted_payment_value') { expect(subject.discounted_payment_value).to eq 360 }
|
26
|
-
specify('#discounted_payment_currency') { expect(subject.discounted_payment_currency).to eq 'руб' }
|
27
|
-
specify('#discounted_payment_reason') { expect(subject.discounted_payment_reason).to eq 'для детских команд; 480 - для студенческих' }
|
28
|
-
specify('#tournament_in_rating') { expect(subject.tournament_in_rating).to eq true }
|
29
|
-
specify('#date_requests_allowed_to') { expect(subject.date_requests_allowed_to).to be_nil }
|
30
|
-
specify('#comment') { expect(subject.comment).to be_nil }
|
31
|
-
specify('#town') { expect(subject.town).to eq 'Пермь' }
|
32
|
-
specify('#site_url') { expect(subject.site_url).to eq URI.parse('https://vk.com/chgk.perm.championship') }
|
33
|
-
specify '#to_h' do
|
34
|
-
expect(tournament_h['idtournament']).to eq '3506'
|
35
|
-
expect(tournament_h['date_start']).to eq '2015-11-08T14:00:00+00:00'
|
36
|
-
expect(tournament_h['date_end']).to eq '2015-11-08T18:00:00+00:00'
|
37
|
-
expect(tournament_h['tour_count']).to eq '4'
|
38
|
-
expect(tournament_h['tour_questions']).to eq '12'
|
39
|
-
expect(tournament_h['tour_ques_per_tour']).to eq ''
|
40
|
-
expect(tournament_h['questions_total']).to eq '48'
|
41
|
-
expect(tournament_h['main_payment_value']).to eq '660.0'
|
42
|
-
expect(tournament_h['discounted_payment_value']).to eq '360.0'
|
43
|
-
expect(tournament_h['date_requests_allowed_to']).to eq ''
|
44
|
-
expect(tournament_h['site_url']).to eq 'https://vk.com/chgk.perm.championship'
|
45
|
-
expect(tournament_h['name']).to eq 'Чемпионат Перми и Пермского края'
|
46
|
-
expect(tournament_h['town']).to eq 'Пермь'
|
47
|
-
expect(tournament_h['long_name']).to eq 'XV Чемпионат Перми и Пермского края по игре "Что? Где? Когда?"'
|
48
|
-
expect(tournament_h['type_name']).to eq 'Обычный'
|
49
|
-
expect(tournament_h['discounted_payment_reason']).to eq 'для детских команд; 480 - для студенческих'
|
50
|
-
expect(tournament_h['comment']).to be_nil
|
51
|
-
end
|
52
|
-
|
53
|
-
specify '#eager_load!' do
|
54
|
-
VCR.use_cassette 'tournament' do
|
55
|
-
lazy_tournament.eager_load!
|
56
|
-
end
|
57
|
-
expect(lazy_tournament.name).to eq 'Чемпионат Перми и Пермского края'
|
58
|
-
end
|
59
|
-
|
60
|
-
describe '#team_results' do
|
61
|
-
let(:team_results) do
|
62
|
-
VCR.use_cassette 'team_results_at_tournament' do
|
63
|
-
subject.team_results(52853)
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
it { expect(team_results).to be_an_instance_of ChgkRating::Collections::TournamentTeamResults }
|
68
|
-
end
|
69
|
-
|
70
|
-
describe '#team_players' do
|
71
|
-
let(:players) do
|
72
|
-
VCR.use_cassette 'team_players_at_tournament' do
|
73
|
-
subject.team_players(52853)
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
it { expect(players).to be_an_instance_of ChgkRating::Collections::TournamentTeamPlayers }
|
78
|
-
end
|
79
|
-
|
80
|
-
describe '#team_by' do
|
81
|
-
let(:team) { subject.team_by 52853 }
|
82
|
-
|
83
|
-
it { expect(team).to be_an_instance_of ChgkRating::Models::TournamentTeam }
|
84
|
-
end
|
85
|
-
|
86
|
-
describe '#team_list' do
|
87
|
-
let(:team_list) do
|
88
|
-
VCR.use_cassette 'teams_at_tournament' do
|
89
|
-
subject.team_list
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
it { expect(team_list).to be_an_instance_of ChgkRating::Collections::TournamentTeams }
|
94
|
-
end
|
95
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
RSpec.describe ChgkRating::Models::TournamentTeamPlayer do
|
2
|
-
subject do
|
3
|
-
VCR.use_cassette 'team_players_at_tournament' do
|
4
|
-
test_client.team_players_at_tournament(3506, 52853)[0]
|
5
|
-
end
|
6
|
-
end
|
7
|
-
let(:tournament_player_h) { subject.to_h }
|
8
|
-
|
9
|
-
it_behaves_like 'model without eager loading'
|
10
|
-
it_behaves_like 'model without lazy support'
|
11
|
-
it_behaves_like 'tournament team player' do
|
12
|
-
let(:player) { subject }
|
13
|
-
end
|
14
|
-
|
15
|
-
specify '#to_h' do
|
16
|
-
expect(tournament_player_h['idplayer']).to eq '51249'
|
17
|
-
expect(tournament_player_h['is_captain']).to eq '1'
|
18
|
-
expect(tournament_player_h['is_base']).to eq '1'
|
19
|
-
expect(tournament_player_h['is_foreign']).to eq '0'
|
20
|
-
end
|
21
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
RSpec.describe ChgkRating::Models::TournamentTeamResult do
|
2
|
-
subject do
|
3
|
-
VCR.use_cassette 'team_results_at_tournament' do
|
4
|
-
test_client.team_results_at_tournament(3506, 52853)[0]
|
5
|
-
end
|
6
|
-
end
|
7
|
-
let(:tournament_team_result_h) { subject.to_h }
|
8
|
-
|
9
|
-
it_behaves_like 'model without eager loading'
|
10
|
-
it_behaves_like 'model without lazy support'
|
11
|
-
it_behaves_like 'tournament team result' do
|
12
|
-
let(:team_result) { subject }
|
13
|
-
end
|
14
|
-
|
15
|
-
specify '#to_h' do
|
16
|
-
expect(tournament_team_result_h['tour']).to eq '1'
|
17
|
-
expect(tournament_team_result_h['mask']).to eq %w(0 0 0 0 1 1 1 0 0 1 0 0)
|
18
|
-
end
|
19
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
RSpec.describe ChgkRating::Models::TournamentTeam do
|
2
|
-
# this is always a lazily-loaded object as
|
3
|
-
# we cannot get info about a specific team participating in a tournament!
|
4
|
-
subject { described_class.new '52853', tournament: '3506', lazy: true }
|
5
|
-
let(:tournament_team_h) { subject.to_h }
|
6
|
-
|
7
|
-
it_behaves_like 'model without eager loading'
|
8
|
-
it_behaves_like 'model with lazy support'
|
9
|
-
|
10
|
-
specify('#tournament') { expect(subject.tournament.id).to eq '3506' }
|
11
|
-
specify('#team') { expect(subject.team.id).to eq '52853' }
|
12
|
-
specify('#id') { expect(subject.id).to eq '52853' }
|
13
|
-
specify '#to_h' do
|
14
|
-
expect(tournament_team_h['idteam']).to eq '52853'
|
15
|
-
end
|
16
|
-
|
17
|
-
describe '#players' do
|
18
|
-
let(:players) do
|
19
|
-
VCR.use_cassette 'team_players_at_tournament' do
|
20
|
-
subject.players
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
it { expect(players).to be_an_instance_of ChgkRating::Collections::TournamentTeamPlayers }
|
25
|
-
end
|
26
|
-
|
27
|
-
describe '#results' do
|
28
|
-
let(:results) do
|
29
|
-
VCR.use_cassette 'team_results_at_tournament' do
|
30
|
-
subject.results
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
it { expect(results).to be_an_instance_of ChgkRating::Collections::TournamentTeamResults }
|
35
|
-
end
|
36
|
-
end
|
@@ -1,12 +0,0 @@
|
|
1
|
-
RSpec.describe String do
|
2
|
-
describe '#snakecase_upcase' do
|
3
|
-
let(:result) { 'SNAKE_CASE' }
|
4
|
-
|
5
|
-
it 'should convert the string properly' do
|
6
|
-
expect('SnakeCase'.snakecase_upcase).to eq result
|
7
|
-
expect('Snake-Case'.snakecase_upcase).to eq result
|
8
|
-
expect('Snake Case'.snakecase_upcase).to eq result
|
9
|
-
expect('Snake - Case'.snakecase_upcase).to eq result
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
RSpec.describe ChgkRating::Utils::Transformations do
|
2
|
-
specify '.to_boolean' do
|
3
|
-
expect(described_class.send(:to_boolean).call('1')).to eq(true)
|
4
|
-
expect(described_class.send(:to_boolean).call('0')).to eq(false)
|
5
|
-
end
|
6
|
-
|
7
|
-
specify '.to_binary_boolean' do
|
8
|
-
expect(described_class.send(:to_binary_boolean).call(true)).to eq('1')
|
9
|
-
expect(described_class.send(:to_binary_boolean).call(false)).to eq('0')
|
10
|
-
end
|
11
|
-
|
12
|
-
specify '.to_star' do
|
13
|
-
expect(described_class.send(:to_star, :to_i).call('1')).to eq(1)
|
14
|
-
expect(described_class.send(:to_star, :to_sym, true).call(%w(one two apple))).to eq(%i(one two apple))
|
15
|
-
end
|
16
|
-
end
|
data/spec/lib/ext/date_spec.rb
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
RSpec.describe DateTime do
|
2
|
-
subject { DateTime.new(2018,01,24,16,58,34) }
|
3
|
-
|
4
|
-
specify '#to_s_chgk' do
|
5
|
-
expect(subject.to_s_chgk).to eq '2018-01-24 16:58:34'
|
6
|
-
end
|
7
|
-
|
8
|
-
specify '.parse_safely' do
|
9
|
-
expect(described_class.parse_safely('2017-09-28 12:00:33').to_s).to eq('2017-09-28T12:00:33+00:00')
|
10
|
-
end
|
11
|
-
end
|
data/spec/lib/ext/uri_spec.rb
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
RSpec.describe URI do
|
2
|
-
specify '.parse_safely' do
|
3
|
-
expect(described_class.parse_safely('http://example.com/test').to_s).to eq('http://example.com/test')
|
4
|
-
expect(described_class.parse_safely('gibberish').to_s).to eq 'gibberish'
|
5
|
-
expect(described_class.parse_safely(nil)).to be_nil
|
6
|
-
end
|
7
|
-
end
|