chgk_rating 1.0.0 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +32 -0
  3. data/Gemfile +3 -1
  4. data/LICENSE +1 -1
  5. data/README.md +10 -501
  6. data/Rakefile +4 -2
  7. data/chgk_rating.gemspec +23 -15
  8. data/lib/chgk_rating/attribute_mappings.rb +107 -80
  9. data/lib/chgk_rating/chgk_object.rb +6 -1
  10. data/lib/chgk_rating/client.rb +43 -10
  11. data/lib/chgk_rating/collections/base.rb +20 -15
  12. data/lib/chgk_rating/collections/players.rb +3 -1
  13. data/lib/chgk_rating/collections/ratings/player_ratings.rb +24 -0
  14. data/lib/chgk_rating/collections/{ratings.rb → ratings/team_ratings.rb} +5 -4
  15. data/lib/chgk_rating/collections/recaps.rb +4 -2
  16. data/lib/chgk_rating/collections/teams.rb +3 -1
  17. data/lib/chgk_rating/collections/tournaments/player_tournaments.rb +48 -0
  18. data/lib/chgk_rating/collections/{tournament_players.rb → tournaments/tournament_team_players.rb} +5 -3
  19. data/lib/chgk_rating/collections/{tournament_team_results.rb → tournaments/tournament_team_results.rb} +3 -1
  20. data/lib/chgk_rating/collections/{tournament_teams.rb → tournaments/tournament_teams.rb} +4 -1
  21. data/lib/chgk_rating/collections/{tournaments.rb → tournaments/tournaments.rb} +13 -8
  22. data/lib/chgk_rating/concerns/searching.rb +10 -9
  23. data/lib/chgk_rating/connection.rb +12 -7
  24. data/lib/chgk_rating/error.rb +7 -5
  25. data/lib/chgk_rating/models/base.rb +34 -15
  26. data/lib/chgk_rating/models/player.rb +28 -1
  27. data/lib/chgk_rating/models/rating/player_rating.rb +18 -0
  28. data/lib/chgk_rating/models/{tournament_player.rb → rating/rating.rb} +4 -2
  29. data/lib/chgk_rating/models/{rating.rb → rating/team_rating.rb} +4 -5
  30. data/lib/chgk_rating/models/recap.rb +3 -1
  31. data/lib/chgk_rating/models/team.rb +9 -7
  32. data/lib/chgk_rating/models/tournament/player_tournament.rb +10 -0
  33. data/lib/chgk_rating/models/{tournament.rb → tournament/tournament.rb} +7 -5
  34. data/lib/chgk_rating/models/{tournament_team.rb → tournament/tournament_team.rb} +6 -4
  35. data/lib/chgk_rating/models/tournament/tournament_team_player.rb +10 -0
  36. data/lib/chgk_rating/models/{tournament_team_result.rb → tournament/tournament_team_result.rb} +3 -1
  37. data/lib/chgk_rating/request.rb +10 -9
  38. data/lib/chgk_rating/utils/snakecase.rb +9 -7
  39. data/lib/chgk_rating/utils/transformations.rb +42 -35
  40. data/lib/chgk_rating/version.rb +4 -2
  41. data/lib/chgk_rating.rb +18 -11
  42. data/lib/ext/date.rb +6 -8
  43. data/lib/ext/date_time.rb +4 -2
  44. data/lib/ext/uri.rb +6 -6
  45. metadata +95 -90
  46. data/spec/lib/chgk_rating/client_spec.rb +0 -208
  47. data/spec/lib/chgk_rating/collections/players_spec.rb +0 -45
  48. data/spec/lib/chgk_rating/collections/ratings_spec.rb +0 -25
  49. data/spec/lib/chgk_rating/collections/recaps_spec.rb +0 -21
  50. data/spec/lib/chgk_rating/collections/teams_spec.rb +0 -42
  51. data/spec/lib/chgk_rating/collections/tournament_players_spec.rb +0 -18
  52. data/spec/lib/chgk_rating/collections/tournament_team_results_spec.rb +0 -17
  53. data/spec/lib/chgk_rating/collections/tournament_teams_spec.rb +0 -60
  54. data/spec/lib/chgk_rating/collections/tournaments_spec.rb +0 -62
  55. data/spec/lib/chgk_rating/models/base_spec.rb +0 -34
  56. data/spec/lib/chgk_rating/models/player_spec.rb +0 -35
  57. data/spec/lib/chgk_rating/models/rating_spec.rb +0 -27
  58. data/spec/lib/chgk_rating/models/recap_spec.rb +0 -35
  59. data/spec/lib/chgk_rating/models/team_spec.rb +0 -89
  60. data/spec/lib/chgk_rating/models/tournament_player_spec.rb +0 -21
  61. data/spec/lib/chgk_rating/models/tournament_spec.rb +0 -92
  62. data/spec/lib/chgk_rating/models/tournament_team_result_spec.rb +0 -19
  63. data/spec/lib/chgk_rating/models/tournament_team_spec.rb +0 -36
  64. data/spec/lib/chgk_rating/utils/snakecase_spec.rb +0 -12
  65. data/spec/lib/chgk_rating/utils/transformations_spec.rb +0 -16
  66. data/spec/lib/chgk_rating_spec.rb +0 -5
  67. data/spec/lib/ext/date_spec.rb +0 -7
  68. data/spec/lib/ext/date_time_spec.rb +0 -11
  69. data/spec/lib/ext/uri_spec.rb +0 -7
  70. data/spec/spec_helper.rb +0 -13
  71. data/spec/support/shared_examples.rb +0 -63
  72. data/spec/support/test_client.rb +0 -6
  73. data/spec/support/vcr.rb +0 -11
data/lib/chgk_rating.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'date'
2
4
  require 'uri'
3
5
  require 'faraday'
@@ -21,21 +23,26 @@ require 'chgk_rating/concerns/searching'
21
23
  require 'chgk_rating/chgk_object'
22
24
 
23
25
  require 'chgk_rating/models/base'
24
- require 'chgk_rating/models/tournament_team_result'
25
- require 'chgk_rating/models/tournament_player'
26
- require 'chgk_rating/models/tournament_team'
27
- require 'chgk_rating/models/rating'
28
- require 'chgk_rating/models/tournament'
26
+ require 'chgk_rating/models/tournament/tournament_team_result'
27
+ require 'chgk_rating/models/tournament/tournament_team_player'
28
+ require 'chgk_rating/models/tournament/tournament_team'
29
+ require 'chgk_rating/models/tournament/player_tournament'
30
+ require 'chgk_rating/models/tournament/tournament'
31
+ require 'chgk_rating/models/rating/rating'
32
+ require 'chgk_rating/models/rating/player_rating'
33
+ require 'chgk_rating/models/rating/team_rating'
29
34
  require 'chgk_rating/models/player'
30
35
  require 'chgk_rating/models/team'
31
36
  require 'chgk_rating/models/recap'
32
37
 
33
38
  require 'chgk_rating/collections/base'
34
- require 'chgk_rating/collections/tournament_team_results'
35
- require 'chgk_rating/collections/tournament_players'
36
- require 'chgk_rating/collections/tournament_teams'
37
- require 'chgk_rating/collections/ratings'
38
- require 'chgk_rating/collections/tournaments'
39
+ require 'chgk_rating/collections/tournaments/tournament_team_results'
40
+ require 'chgk_rating/collections/tournaments/tournament_team_players'
41
+ require 'chgk_rating/collections/tournaments/tournament_teams'
42
+ require 'chgk_rating/collections/tournaments/player_tournaments'
43
+ require 'chgk_rating/collections/tournaments/tournaments'
44
+ require 'chgk_rating/collections/ratings/player_ratings'
45
+ require 'chgk_rating/collections/ratings/team_ratings'
39
46
  require 'chgk_rating/collections/players'
40
47
  require 'chgk_rating/collections/teams'
41
48
  require 'chgk_rating/collections/recaps'
@@ -49,4 +56,4 @@ module ChgkRating
49
56
  def self.client
50
57
  @client ||= ChgkRating::Client.new
51
58
  end
52
- end
59
+ end
data/lib/ext/date.rb CHANGED
@@ -1,11 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Date
2
4
  def self.parse_safely(raw_date_time)
3
- begin
4
- self.parse raw_date_time
5
- rescue ArgumentError
6
- nil
7
- rescue TypeError
8
- nil
9
- end
5
+ parse raw_date_time
6
+ rescue ArgumentError, TypeError
7
+ nil
10
8
  end
11
- end
9
+ end
data/lib/ext/date_time.rb CHANGED
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class DateTime
2
4
  def to_s_chgk
3
- self.strftime('%Y-%m-%d %H:%M:%S')
5
+ strftime('%Y-%m-%d %H:%M:%S')
4
6
  end
5
- end
7
+ end
data/lib/ext/uri.rb CHANGED
@@ -1,9 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module URI
2
4
  def self.parse_safely(raw_uri)
3
- begin
4
- URI.parse raw_uri
5
- rescue URI::InvalidURIError
6
- nil
7
- end
5
+ URI.parse raw_uri
6
+ rescue URI::InvalidURIError
7
+ nil
8
8
  end
9
- end
9
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chgk_rating
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
- - Ilya Bodrov
8
- autorequire:
7
+ - Ilya Krukowski
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-23 00:00:00.000000000 Z
11
+ date: 2022-07-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -16,42 +16,70 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.13'
19
+ version: '2.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0.13'
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: faraday-follow_redirects
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.3'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.3'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: multi_json
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
45
  - - "~>"
32
46
  - !ruby/object:Gem::Version
33
- version: '1.12'
47
+ version: '1.15'
34
48
  type: :runtime
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
52
  - - "~>"
39
53
  - !ruby/object:Gem::Version
40
- version: '1.12'
54
+ version: '1.15'
55
+ - !ruby/object:Gem::Dependency
56
+ name: codecov
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.1'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.1'
41
69
  - !ruby/object:Gem::Dependency
42
70
  name: rake
43
71
  requirement: !ruby/object:Gem::Requirement
44
72
  requirements:
45
73
  - - "~>"
46
74
  - !ruby/object:Gem::Version
47
- version: '12.1'
75
+ version: '13.0'
48
76
  type: :development
49
77
  prerelease: false
50
78
  version_requirements: !ruby/object:Gem::Requirement
51
79
  requirements:
52
80
  - - "~>"
53
81
  - !ruby/object:Gem::Version
54
- version: '12.1'
82
+ version: '13.0'
55
83
  - !ruby/object:Gem::Dependency
56
84
  name: rspec
57
85
  requirement: !ruby/object:Gem::Requirement
@@ -67,33 +95,61 @@ dependencies:
67
95
  - !ruby/object:Gem::Version
68
96
  version: '3.6'
69
97
  - !ruby/object:Gem::Dependency
70
- name: vcr
98
+ name: rubocop
71
99
  requirement: !ruby/object:Gem::Requirement
72
100
  requirements:
73
101
  - - "~>"
74
102
  - !ruby/object:Gem::Version
75
- version: '4.0'
103
+ version: '1.31'
76
104
  type: :development
77
105
  prerelease: false
78
106
  version_requirements: !ruby/object:Gem::Requirement
79
107
  requirements:
80
108
  - - "~>"
81
109
  - !ruby/object:Gem::Version
82
- version: '4.0'
110
+ version: '1.31'
83
111
  - !ruby/object:Gem::Dependency
84
- name: codeclimate-test-reporter
112
+ name: rubocop-performance
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '1.5'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '1.5'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rubocop-rspec
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '2.11'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '2.11'
139
+ - !ruby/object:Gem::Dependency
140
+ name: vcr
85
141
  requirement: !ruby/object:Gem::Requirement
86
142
  requirements:
87
143
  - - "~>"
88
144
  - !ruby/object:Gem::Version
89
- version: '1.0'
145
+ version: '6.0'
90
146
  type: :development
91
147
  prerelease: false
92
148
  version_requirements: !ruby/object:Gem::Requirement
93
149
  requirements:
94
150
  - - "~>"
95
151
  - !ruby/object:Gem::Version
96
- version: '1.0'
152
+ version: '6.0'
97
153
  description: Opinionated Ruby client for the competitive What? Where? When? rating
98
154
  WebAPI (rating.chgk.info) that allows to work with data as with Ruby objects
99
155
  email:
@@ -119,25 +175,30 @@ files:
119
175
  - lib/chgk_rating/client.rb
120
176
  - lib/chgk_rating/collections/base.rb
121
177
  - lib/chgk_rating/collections/players.rb
122
- - lib/chgk_rating/collections/ratings.rb
178
+ - lib/chgk_rating/collections/ratings/player_ratings.rb
179
+ - lib/chgk_rating/collections/ratings/team_ratings.rb
123
180
  - lib/chgk_rating/collections/recaps.rb
124
181
  - lib/chgk_rating/collections/teams.rb
125
- - lib/chgk_rating/collections/tournament_players.rb
126
- - lib/chgk_rating/collections/tournament_team_results.rb
127
- - lib/chgk_rating/collections/tournament_teams.rb
128
- - lib/chgk_rating/collections/tournaments.rb
182
+ - lib/chgk_rating/collections/tournaments/player_tournaments.rb
183
+ - lib/chgk_rating/collections/tournaments/tournament_team_players.rb
184
+ - lib/chgk_rating/collections/tournaments/tournament_team_results.rb
185
+ - lib/chgk_rating/collections/tournaments/tournament_teams.rb
186
+ - lib/chgk_rating/collections/tournaments/tournaments.rb
129
187
  - lib/chgk_rating/concerns/searching.rb
130
188
  - lib/chgk_rating/connection.rb
131
189
  - lib/chgk_rating/error.rb
132
190
  - lib/chgk_rating/models/base.rb
133
191
  - lib/chgk_rating/models/player.rb
134
- - lib/chgk_rating/models/rating.rb
192
+ - lib/chgk_rating/models/rating/player_rating.rb
193
+ - lib/chgk_rating/models/rating/rating.rb
194
+ - lib/chgk_rating/models/rating/team_rating.rb
135
195
  - lib/chgk_rating/models/recap.rb
136
196
  - lib/chgk_rating/models/team.rb
137
- - lib/chgk_rating/models/tournament.rb
138
- - lib/chgk_rating/models/tournament_player.rb
139
- - lib/chgk_rating/models/tournament_team.rb
140
- - lib/chgk_rating/models/tournament_team_result.rb
197
+ - lib/chgk_rating/models/tournament/player_tournament.rb
198
+ - lib/chgk_rating/models/tournament/tournament.rb
199
+ - lib/chgk_rating/models/tournament/tournament_team.rb
200
+ - lib/chgk_rating/models/tournament/tournament_team_player.rb
201
+ - lib/chgk_rating/models/tournament/tournament_team_result.rb
141
202
  - lib/chgk_rating/request.rb
142
203
  - lib/chgk_rating/utils/snakecase.rb
143
204
  - lib/chgk_rating/utils/transformations.rb
@@ -145,39 +206,12 @@ files:
145
206
  - lib/ext/date.rb
146
207
  - lib/ext/date_time.rb
147
208
  - lib/ext/uri.rb
148
- - spec/lib/chgk_rating/client_spec.rb
149
- - spec/lib/chgk_rating/collections/players_spec.rb
150
- - spec/lib/chgk_rating/collections/ratings_spec.rb
151
- - spec/lib/chgk_rating/collections/recaps_spec.rb
152
- - spec/lib/chgk_rating/collections/teams_spec.rb
153
- - spec/lib/chgk_rating/collections/tournament_players_spec.rb
154
- - spec/lib/chgk_rating/collections/tournament_team_results_spec.rb
155
- - spec/lib/chgk_rating/collections/tournament_teams_spec.rb
156
- - spec/lib/chgk_rating/collections/tournaments_spec.rb
157
- - spec/lib/chgk_rating/models/base_spec.rb
158
- - spec/lib/chgk_rating/models/player_spec.rb
159
- - spec/lib/chgk_rating/models/rating_spec.rb
160
- - spec/lib/chgk_rating/models/recap_spec.rb
161
- - spec/lib/chgk_rating/models/team_spec.rb
162
- - spec/lib/chgk_rating/models/tournament_player_spec.rb
163
- - spec/lib/chgk_rating/models/tournament_spec.rb
164
- - spec/lib/chgk_rating/models/tournament_team_result_spec.rb
165
- - spec/lib/chgk_rating/models/tournament_team_spec.rb
166
- - spec/lib/chgk_rating/utils/snakecase_spec.rb
167
- - spec/lib/chgk_rating/utils/transformations_spec.rb
168
- - spec/lib/chgk_rating_spec.rb
169
- - spec/lib/ext/date_spec.rb
170
- - spec/lib/ext/date_time_spec.rb
171
- - spec/lib/ext/uri_spec.rb
172
- - spec/spec_helper.rb
173
- - spec/support/shared_examples.rb
174
- - spec/support/test_client.rb
175
- - spec/support/vcr.rb
176
- homepage: https://github.com/bodrovis/ChgkRating
209
+ homepage: http://chgk-rating.bodrovis.tech/
177
210
  licenses:
178
211
  - MIT
179
- metadata: {}
180
- post_install_message:
212
+ metadata:
213
+ rubygems_mfa_required: 'true'
214
+ post_install_message:
181
215
  rdoc_options: []
182
216
  require_paths:
183
217
  - lib
@@ -185,44 +219,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
185
219
  requirements:
186
220
  - - ">="
187
221
  - !ruby/object:Gem::Version
188
- version: 2.4.0
222
+ version: 2.6.0
189
223
  required_rubygems_version: !ruby/object:Gem::Requirement
190
224
  requirements:
191
225
  - - ">="
192
226
  - !ruby/object:Gem::Version
193
227
  version: '0'
194
228
  requirements: []
195
- rubyforge_project:
196
- rubygems_version: 2.7.6
197
- signing_key:
229
+ rubygems_version: 3.3.17
230
+ signing_key:
198
231
  specification_version: 4
199
232
  summary: Ruby interface to the competitive What? Where? When? rating API
200
- test_files:
201
- - spec/lib/chgk_rating/client_spec.rb
202
- - spec/lib/chgk_rating/collections/players_spec.rb
203
- - spec/lib/chgk_rating/collections/ratings_spec.rb
204
- - spec/lib/chgk_rating/collections/recaps_spec.rb
205
- - spec/lib/chgk_rating/collections/teams_spec.rb
206
- - spec/lib/chgk_rating/collections/tournaments_spec.rb
207
- - spec/lib/chgk_rating/collections/tournament_players_spec.rb
208
- - spec/lib/chgk_rating/collections/tournament_teams_spec.rb
209
- - spec/lib/chgk_rating/collections/tournament_team_results_spec.rb
210
- - spec/lib/chgk_rating/models/base_spec.rb
211
- - spec/lib/chgk_rating/models/player_spec.rb
212
- - spec/lib/chgk_rating/models/rating_spec.rb
213
- - spec/lib/chgk_rating/models/recap_spec.rb
214
- - spec/lib/chgk_rating/models/team_spec.rb
215
- - spec/lib/chgk_rating/models/tournament_player_spec.rb
216
- - spec/lib/chgk_rating/models/tournament_spec.rb
217
- - spec/lib/chgk_rating/models/tournament_team_result_spec.rb
218
- - spec/lib/chgk_rating/models/tournament_team_spec.rb
219
- - spec/lib/chgk_rating/utils/snakecase_spec.rb
220
- - spec/lib/chgk_rating/utils/transformations_spec.rb
221
- - spec/lib/chgk_rating_spec.rb
222
- - spec/lib/ext/date_spec.rb
223
- - spec/lib/ext/date_time_spec.rb
224
- - spec/lib/ext/uri_spec.rb
225
- - spec/spec_helper.rb
226
- - spec/support/shared_examples.rb
227
- - spec/support/test_client.rb
228
- - spec/support/vcr.rb
233
+ test_files: []
@@ -1,208 +0,0 @@
1
- RSpec.shared_examples 'lazy loaded' do
2
- it 'is lazy loaded' do
3
- expect(object.lazy).to eq(true)
4
- end
5
- end
6
-
7
- RSpec.describe ChgkRating::Client do
8
- let(:team_1) { test_client.team(1, true) }
9
- let(:team_52853) { test_client.team(52853, true) }
10
- let(:tournament_3506) { test_client.tournament(3506, true) }
11
-
12
- def with_erroneous_cassette
13
- VCR.use_cassette('erroneous_request') { yield }
14
- end
15
-
16
- context 'errors' do
17
- it 'should raise an error for an erroneous request' do
18
- expect do
19
- # That's a very strange bug that makes VCR raise UnhandledHTTPError
20
- # so for now disable VCR for Ruby 2.5+
21
- if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.5.0')
22
- test_client.tournament '/thats/an/error'
23
- else
24
- with_erroneous_cassette { test_client.tournament '/thats/an/error' }
25
- end
26
- end.to raise_error(ChgkRating::Error::NotFound)
27
- end
28
- end
29
-
30
- describe '#team_at_tournament' do
31
- subject { test_client.team_at_tournament tournament_3506, team_52853 }
32
-
33
- it { is_expected.to be_an_instance_of ChgkRating::Models::TournamentTeam }
34
-
35
- include_examples 'lazy loaded' do
36
- let(:object) { subject }
37
- end
38
- end
39
-
40
- describe '#tournament' do
41
- subject { test_client.tournament 3506, true }
42
-
43
- include_examples 'lazy loaded' do
44
- let(:object) { subject }
45
- end
46
-
47
- it { is_expected.to be_an_instance_of ChgkRating::Models::Tournament }
48
- end
49
-
50
- describe '#rating' do
51
- subject do
52
- VCR.use_cassette('rating_release') { test_client.rating team_1, 24 }
53
- end
54
-
55
- it { is_expected.to be_an_instance_of ChgkRating::Models::Rating }
56
- end
57
-
58
- describe '#recap' do
59
- subject do
60
- VCR.use_cassette 'recap_last_season' do
61
- test_client.recap test_client.team(7931, true), :last
62
- end
63
- end
64
-
65
- it { is_expected.to be_an_instance_of ChgkRating::Models::Recap }
66
- end
67
-
68
- describe '#team' do
69
- subject { test_client.team 1, true }
70
-
71
- it { is_expected.to be_an_instance_of ChgkRating::Models::Team }
72
-
73
- include_examples 'lazy loaded' do
74
- let(:object) { subject }
75
- end
76
- end
77
-
78
- describe '#player' do
79
- subject { test_client.player 42511, true }
80
-
81
- it { is_expected.to be_an_instance_of ChgkRating::Models::Player }
82
-
83
- include_examples 'lazy loaded' do
84
- let(:object) { subject }
85
- end
86
- end
87
-
88
- describe '#ratings' do
89
- subject do
90
- VCR.use_cassette 'team_ratings' do
91
- test_client.ratings team_1
92
- end
93
- end
94
- it { is_expected.to be_an_instance_of ChgkRating::Collections::Ratings }
95
- end
96
-
97
- describe '#team_players_at_tournament' do
98
- subject do
99
- VCR.use_cassette 'team_players_at_tournament' do
100
- test_client.team_players_at_tournament tournament_3506, team_52853
101
- end
102
- end
103
-
104
- it { is_expected.to be_an_instance_of ChgkRating::Collections::TournamentPlayers }
105
- end
106
-
107
- describe '#team_results_at_tournament' do
108
- subject do
109
- VCR.use_cassette 'team_results_at_tournament' do
110
- test_client.team_results_at_tournament tournament_3506, team_52853
111
- end
112
- end
113
-
114
- it { is_expected.to be_an_instance_of ChgkRating::Collections::TournamentTeamResults }
115
- end
116
-
117
- describe '#teams_at_tournament' do
118
- subject do
119
- VCR.use_cassette 'teams_at_tournament' do
120
- test_client.teams_at_tournament tournament_3506
121
- end
122
- end
123
-
124
- it { is_expected.to be_an_instance_of ChgkRating::Collections::TournamentTeams }
125
- end
126
-
127
- describe '#tournaments' do
128
- context 'all tournaments for a team by season' do
129
- subject do
130
- VCR.use_cassette 'team_tournaments_season' do
131
- test_client.tournaments team_or_id: team_1, season_id: 4
132
- end
133
- end
134
-
135
- it { is_expected.to be_an_instance_of ChgkRating::Collections::Tournaments }
136
- end
137
-
138
- context 'tournaments for a team' do
139
- subject do
140
- VCR.use_cassette 'team_tournaments' do
141
- test_client.tournaments team_or_id: team_1
142
- end
143
- end
144
-
145
- it { is_expected.to be_an_instance_of ChgkRating::Collections::Tournaments }
146
- end
147
-
148
- context 'all tournaments' do
149
- subject do
150
- VCR.use_cassette 'tournaments' do
151
- test_client.tournaments
152
- end
153
- end
154
-
155
- it { is_expected.to be_an_instance_of ChgkRating::Collections::Tournaments }
156
- end
157
- end
158
-
159
- describe '#recaps' do
160
- subject do
161
- VCR.use_cassette 'recaps' do
162
- test_client.recaps team_1
163
- end
164
- end
165
-
166
- it { is_expected.to be_an_instance_of ChgkRating::Collections::Recaps }
167
- end
168
-
169
- describe '#search_teams' do
170
- subject do
171
- VCR.use_cassette 'teams_searching' do
172
- test_client.search_teams name: 'э', town: 'мин'
173
- end
174
- end
175
-
176
- it { is_expected.to be_an_instance_of ChgkRating::Collections::Teams::Search }
177
- end
178
-
179
- describe '#teams' do
180
- subject do
181
- VCR.use_cassette 'teams' do
182
- test_client.teams
183
- end
184
- end
185
-
186
- it { is_expected.to be_an_instance_of ChgkRating::Collections::Teams }
187
- end
188
-
189
- describe '#search_players' do
190
- subject do
191
- VCR.use_cassette 'players_searching' do
192
- test_client.search_players name: 'вас', surname: 'а'
193
- end
194
- end
195
-
196
- it { is_expected.to be_an_instance_of ChgkRating::Collections::Players::Search }
197
- end
198
-
199
- describe '#players' do
200
- subject do
201
- VCR.use_cassette 'players' do
202
- test_client.players
203
- end
204
- end
205
-
206
- it { is_expected.to be_an_instance_of ChgkRating::Collections::Players }
207
- end
208
- end
@@ -1,45 +0,0 @@
1
- RSpec.describe ChgkRating::Collections::Players do
2
- let(:player) { subject[1] }
3
- subject do
4
- VCR.use_cassette 'players' do
5
- described_class.new
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
- players_arr = subject.to_a
14
- expect(players_arr.count).to eq 1000
15
- expect(players_arr[10]['surname']).to eq 'Абарников'
16
- end
17
- specify('#id') { expect(player.id).to eq '6' }
18
- specify('#surname') { expect(player.surname).to eq 'Абаков' }
19
- specify('#name') { expect(player.name).to eq 'Карен' }
20
- it 'respond_to should still work properly' do
21
- expect(subject.respond_to?(:count)).to eq true
22
- end
23
-
24
- context 'searching' do
25
- subject do
26
- VCR.use_cassette 'players_searching' do
27
- test_client.search_players(name: 'вас', surname: 'а')[28]
28
- end
29
- end
30
-
31
- specify('#id') { expect(subject.id).to eq '148380' }
32
- specify('#surname') { expect(subject.surname).to eq 'Абросимов' }
33
- end
34
-
35
- context 'pagination' do
36
- subject do
37
- VCR.use_cassette 'players_page3' do
38
- described_class.new(page: 3)[1]
39
- end
40
- end
41
-
42
- specify('#id') { expect(subject.id).to eq '2101' }
43
- specify('#surname') { expect(subject.surname).to eq 'Бажов' }
44
- end
45
- end
@@ -1,25 +0,0 @@
1
- RSpec.describe ChgkRating::Collections::Ratings do
2
- subject do
3
- VCR.use_cassette 'team_ratings' do
4
- described_class.new(team: 1)
5
- end
6
- end
7
- let(:ratings) do
8
- subject[0]
9
- end
10
-
11
- it_behaves_like 'not a hash'
12
- it_behaves_like 'an array'
13
-
14
- specify '#to_a' do
15
- ratings_arr = subject.to_a
16
- expect(ratings_arr.count).to eq 572
17
- expect(ratings_arr[500]['date']).to eq '2006-08-17'
18
- end
19
- specify('#date') { expect(ratings.date.to_s).to eq '2003-07-01' }
20
- specify('#formula') { expect(ratings.formula).to eq :a }
21
- specify('#rating_position') { expect(ratings.rating_position).to eq 8 }
22
- specify('#release_id') { expect(ratings.release_id).to eq '1' }
23
- specify('#team') { expect(ratings.team.id).to eq '1' }
24
- specify('#rating') { expect(ratings.rating).to eq 6093 }
25
- end