rating-chgk-v2 1.0.0.rc1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +13 -0
  3. data/README.md +2 -1
  4. data/lib/rating_chgk_v2/data/tournament_synch_request.yml +1 -0
  5. data/lib/rating_chgk_v2/endpoints/base_endpoint.rb +3 -2
  6. data/lib/rating_chgk_v2/models/venue_model.rb +5 -0
  7. data/lib/rating_chgk_v2/request.rb +0 -1
  8. data/lib/rating_chgk_v2/version.rb +1 -1
  9. data/lib/rating_chgk_v2.rb +1 -1
  10. data/rating-chgk-v2.gemspec +2 -2
  11. metadata +8 -93
  12. data/spec/lib/rating_chgk_v2/collections/base_collection_spec.rb +0 -53
  13. data/spec/lib/rating_chgk_v2/collections/countries_collection_spec.rb +0 -5
  14. data/spec/lib/rating_chgk_v2/collections/player_seasons_collection_spec.rb +0 -5
  15. data/spec/lib/rating_chgk_v2/collections/player_tournaments_collection_spec.rb +0 -5
  16. data/spec/lib/rating_chgk_v2/collections/players_collection_spec.rb +0 -5
  17. data/spec/lib/rating_chgk_v2/collections/regions_collection_spec.rb +0 -5
  18. data/spec/lib/rating_chgk_v2/collections/releases_collection_spec.rb +0 -5
  19. data/spec/lib/rating_chgk_v2/collections/seasons_collection_spec.rb +0 -5
  20. data/spec/lib/rating_chgk_v2/collections/teams_collection_spec.rb +0 -5
  21. data/spec/lib/rating_chgk_v2/collections/tournaments_collection_spec.rb +0 -5
  22. data/spec/lib/rating_chgk_v2/collections/towns_collection_spec.rb +0 -5
  23. data/spec/lib/rating_chgk_v2/collections/venue_types_collection_spec.rb +0 -5
  24. data/spec/lib/rating_chgk_v2/collections/venues_collection_spec.rb +0 -5
  25. data/spec/lib/rating_chgk_v2/connection_spec.rb +0 -22
  26. data/spec/lib/rating_chgk_v2/endpoints/base_endpoint_spec.rb +0 -15
  27. data/spec/lib/rating_chgk_v2/error_spec.rb +0 -11
  28. data/spec/lib/rating_chgk_v2/models/country_model_spec.rb +0 -30
  29. data/spec/lib/rating_chgk_v2/models/player_model_spec.rb +0 -59
  30. data/spec/lib/rating_chgk_v2/models/season_model_spec.rb +0 -36
  31. data/spec/lib/rating_chgk_v2/models/team_model_spec.rb +0 -35
  32. data/spec/lib/rating_chgk_v2/models/tournament_model_spec.rb +0 -38
  33. data/spec/lib/rating_chgk_v2/models/venue_model_spec.rb +0 -30
  34. data/spec/lib/rating_chgk_v2/rest/authentication_token_spec.rb +0 -19
  35. data/spec/lib/rating_chgk_v2/rest/countries_spec.rb +0 -94
  36. data/spec/lib/rating_chgk_v2/rest/players_spec.rb +0 -126
  37. data/spec/lib/rating_chgk_v2/rest/regions_spec.rb +0 -37
  38. data/spec/lib/rating_chgk_v2/rest/releases_spec.rb +0 -34
  39. data/spec/lib/rating_chgk_v2/rest/seasons_spec.rb +0 -71
  40. data/spec/lib/rating_chgk_v2/rest/teams_spec.rb +0 -66
  41. data/spec/lib/rating_chgk_v2/rest/tournament_flags_spec.rb +0 -27
  42. data/spec/lib/rating_chgk_v2/rest/tournament_synch_appeals_spec.rb +0 -22
  43. data/spec/lib/rating_chgk_v2/rest/tournament_synch_controversials_spec.rb +0 -20
  44. data/spec/lib/rating_chgk_v2/rest/tournament_synch_requests_spec.rb +0 -20
  45. data/spec/lib/rating_chgk_v2/rest/tournament_types_spec.rb +0 -23
  46. data/spec/lib/rating_chgk_v2/rest/tournaments_spec.rb +0 -89
  47. data/spec/lib/rating_chgk_v2/rest/towns_spec.rb +0 -35
  48. data/spec/lib/rating_chgk_v2/rest/venue_types_spec.rb +0 -46
  49. data/spec/lib/rating_chgk_v2/rest/venues_spec.rb +0 -71
  50. data/spec/lib/rating_chgk_v2_spec.rb +0 -9
  51. data/spec/spec_helper.rb +0 -37
  52. data/spec/support/shared/paginated.rb +0 -41
  53. data/spec/support/test_client.rb +0 -7
  54. data/spec/support/vcr.rb +0 -15
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3e53b64ea30c84c114b5b01ceb285985bb4ac2bb319fd5f6e4561fbca0b71bbc
4
- data.tar.gz: 2f1dc39b971c9d27fce1ad4b19d8bc537cebc587ed4a16e20d630983bffa0cb5
3
+ metadata.gz: e7dad45c8ac28f2ea451f5fe52b6fc9df788e706a4d8f3abedaa58e16b14ca6c
4
+ data.tar.gz: 5834bf7e0ac6dbdcba393203324c0f4142776a919fb57709c57388ddcd0f2724
5
5
  SHA512:
6
- metadata.gz: d2dd209511a8b1ba0157a14170674d3050db1c957311d50e750c9e07b015457e210142cc107ddfc70a5b17a887803db8ef8ab1d7b72799220d124c4bf5d39a63
7
- data.tar.gz: c6a48f19b76ef12a483fcf7e0e3d28b15dc97646400fd1a832d7afe417e9d74f4c30ff822886377ad5fd6d07ada01c6fdb9b79738cc8cc4030e9d5dd56483d93
6
+ metadata.gz: 87b5add4aea56622ec5544514ee056b7bfaa3d021cbb1f0ad270ec8a77775b78b78991e8f3e70fc9548488cb95fbe55b8fa276b22d0ec84a8baf053d6b1735b1
7
+ data.tar.gz: af776aad282c2b747ce02e8ee6064c53837c3e14578e365af8584f9d09b2eb493e274b66a5b06304f24bf5e2a0eee305a11429f7a5bf76e417b55ae977b0f760
data/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.1.0 (29-Jul-22)
4
+
5
+ * Added requests for venues (thanks, @L-Eugene)
6
+
7
+ ## 1.0.1 (28-Jul-22)
8
+
9
+ * Fixed endpoint reinitialization (thanks, @L-Eugene)
10
+ * Minor fixes
11
+
12
+ ## 1.0.0 (12-Apr-22)
13
+
14
+ * Stable release
15
+
3
16
  ## 1.0.0.rc1 (11-Apr-22)
4
17
 
5
18
  * Initial release
data/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  # RatingChgkV2
2
2
 
3
+ ![Gem](https://img.shields.io/gem/v/rating-chgk-v2)
3
4
  ![CI](https://github.com/bodrovis/rating-chgk-v2/actions/workflows/ci.yml/badge.svg)
4
5
  [![Test Coverage](https://codecov.io/gh/bodrovis/rating-chgk-v2/graph/badge.svg)](https://codecov.io/gh/bodrovis/rating-chgk-v2)
5
6
 
@@ -57,4 +58,4 @@ Observe test results and coverage.
57
58
 
58
59
  Licensed under the [MIT license](./LICENSE.md).
59
60
 
60
- Copyright (c) 2022 [Ilya Bodrov-Krukowski](http://bodrovis.tech)
61
+ Copyright (c) 2022 [Ilya Bodrov-Krukowski](http://bodrovis.tech)
@@ -5,4 +5,5 @@
5
5
  - narrators
6
6
  - approximateTeamsCount
7
7
  - issuedAt
8
+ - dateStart
8
9
  - tournamentId
@@ -8,12 +8,13 @@ module RatingChgkV2
8
8
  attr_reader :params
9
9
 
10
10
  def initialize(client, query_params = [], params = {})
11
- setup client, base_query.push(*query_params), params
11
+ @instance_query = base_query.push(*query_params)
12
+ setup client, @instance_query, params
12
13
  end
13
14
 
14
15
  def reinitialize(new_params: {}, add_query: [])
15
16
  add_query = [add_query] unless add_query.is_a?(Array)
16
- new_query = add_query&.any? ? @query_params.push(*add_query) : @query_params
17
+ new_query = add_query&.any? ? @instance_query + add_query : @query_params
17
18
  setup @client, new_query, new_params
18
19
  self
19
20
  end
@@ -11,6 +11,11 @@ module RatingChgkV2
11
11
  def destroy
12
12
  endpoint.do_delete
13
13
  end
14
+
15
+ def requests(params = {})
16
+ endpoint.reinitialize new_params: params, add_query: :requests
17
+ RatingChgkV2::Collections::TournamentRequestsCollection.load :do_get, endpoint
18
+ end
14
19
  end
15
20
  end
16
21
  end
@@ -28,7 +28,6 @@ module RatingChgkV2
28
28
 
29
29
  def delete(path, client, _params = {})
30
30
  respond_with(
31
- # Rubocop tries to replace `delete` with `gsub` but that's a different method here!
32
31
  connection(client).delete(prepare(path)),
33
32
  client
34
33
  )
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RatingChgkV2
4
- VERSION = '1.0.0.rc1'
4
+ VERSION = '1.1.0'
5
5
  end
@@ -12,7 +12,7 @@ loader.setup
12
12
  module RatingChgkV2
13
13
  class << self
14
14
  def client(token: '', params: {})
15
- @client ||= RatingChgkV2::Client.new token: token, params: params
15
+ @client = RatingChgkV2::Client.new token: token, params: params
16
16
  end
17
17
 
18
18
  def reset_client!
@@ -5,7 +5,7 @@ require File.expand_path('lib/rating_chgk_v2/version', __dir__)
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = 'rating-chgk-v2'
7
7
  spec.version = RatingChgkV2::VERSION
8
- spec.authors = ['Ilya Bodrov-Krukowski']
8
+ spec.authors = ['Ilya Krukowski']
9
9
  spec.email = ['golosizpru@gmail.com']
10
10
  spec.summary = 'Ruby interface for the new CHGK rating API'
11
11
  spec.description = 'Ruby client for the new CHGK rating API (api.rating.chgk.net).'
@@ -18,7 +18,6 @@ Gem::Specification.new do |spec|
18
18
  'CHANGELOG.md', 'lib/**/*.rb', 'lib/rating_chgk_v2/data/*.yml',
19
19
  'rating-chgk-v2.gemspec', '.github/*.md',
20
20
  'Gemfile', 'Rakefile']
21
- spec.test_files = Dir['spec/**/*.rb']
22
21
  spec.extra_rdoc_files = ['README.md']
23
22
  spec.require_paths = ['lib']
24
23
 
@@ -39,6 +38,7 @@ Gem::Specification.new do |spec|
39
38
  spec.add_development_dependency 'vcr', '~> 6.0'
40
39
  spec.add_development_dependency 'webmock', '~> 3.14'
41
40
  spec.metadata = {
41
+ 'source_code_uri' => 'https://github.com/bodrovis/rating-chgk-v2',
42
42
  'rubygems_mfa_required' => 'true',
43
43
  'wiki_uri' => 'https://github.com/bodrovis/rating-chgk-v2/wiki',
44
44
  'changelog_uri' => 'https://github.com/bodrovis/rating-chgk-v2/blob/master/CHANGELOG.md',
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rating-chgk-v2
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.rc1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
- - Ilya Bodrov-Krukowski
7
+ - Ilya Krukowski
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-04-11 00:00:00.000000000 Z
11
+ date: 2022-07-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -339,53 +339,11 @@ files:
339
339
  - lib/rating_chgk_v2/utils/string_utils.rb
340
340
  - lib/rating_chgk_v2/version.rb
341
341
  - rating-chgk-v2.gemspec
342
- - spec/lib/rating_chgk_v2/collections/base_collection_spec.rb
343
- - spec/lib/rating_chgk_v2/collections/countries_collection_spec.rb
344
- - spec/lib/rating_chgk_v2/collections/player_seasons_collection_spec.rb
345
- - spec/lib/rating_chgk_v2/collections/player_tournaments_collection_spec.rb
346
- - spec/lib/rating_chgk_v2/collections/players_collection_spec.rb
347
- - spec/lib/rating_chgk_v2/collections/regions_collection_spec.rb
348
- - spec/lib/rating_chgk_v2/collections/releases_collection_spec.rb
349
- - spec/lib/rating_chgk_v2/collections/seasons_collection_spec.rb
350
- - spec/lib/rating_chgk_v2/collections/teams_collection_spec.rb
351
- - spec/lib/rating_chgk_v2/collections/tournaments_collection_spec.rb
352
- - spec/lib/rating_chgk_v2/collections/towns_collection_spec.rb
353
- - spec/lib/rating_chgk_v2/collections/venue_types_collection_spec.rb
354
- - spec/lib/rating_chgk_v2/collections/venues_collection_spec.rb
355
- - spec/lib/rating_chgk_v2/connection_spec.rb
356
- - spec/lib/rating_chgk_v2/endpoints/base_endpoint_spec.rb
357
- - spec/lib/rating_chgk_v2/error_spec.rb
358
- - spec/lib/rating_chgk_v2/models/country_model_spec.rb
359
- - spec/lib/rating_chgk_v2/models/player_model_spec.rb
360
- - spec/lib/rating_chgk_v2/models/season_model_spec.rb
361
- - spec/lib/rating_chgk_v2/models/team_model_spec.rb
362
- - spec/lib/rating_chgk_v2/models/tournament_model_spec.rb
363
- - spec/lib/rating_chgk_v2/models/venue_model_spec.rb
364
- - spec/lib/rating_chgk_v2/rest/authentication_token_spec.rb
365
- - spec/lib/rating_chgk_v2/rest/countries_spec.rb
366
- - spec/lib/rating_chgk_v2/rest/players_spec.rb
367
- - spec/lib/rating_chgk_v2/rest/regions_spec.rb
368
- - spec/lib/rating_chgk_v2/rest/releases_spec.rb
369
- - spec/lib/rating_chgk_v2/rest/seasons_spec.rb
370
- - spec/lib/rating_chgk_v2/rest/teams_spec.rb
371
- - spec/lib/rating_chgk_v2/rest/tournament_flags_spec.rb
372
- - spec/lib/rating_chgk_v2/rest/tournament_synch_appeals_spec.rb
373
- - spec/lib/rating_chgk_v2/rest/tournament_synch_controversials_spec.rb
374
- - spec/lib/rating_chgk_v2/rest/tournament_synch_requests_spec.rb
375
- - spec/lib/rating_chgk_v2/rest/tournament_types_spec.rb
376
- - spec/lib/rating_chgk_v2/rest/tournaments_spec.rb
377
- - spec/lib/rating_chgk_v2/rest/towns_spec.rb
378
- - spec/lib/rating_chgk_v2/rest/venue_types_spec.rb
379
- - spec/lib/rating_chgk_v2/rest/venues_spec.rb
380
- - spec/lib/rating_chgk_v2_spec.rb
381
- - spec/spec_helper.rb
382
- - spec/support/shared/paginated.rb
383
- - spec/support/test_client.rb
384
- - spec/support/vcr.rb
385
342
  homepage: https://github.com/bodrovis/rating-chgk-v2
386
343
  licenses:
387
344
  - MIT
388
345
  metadata:
346
+ source_code_uri: https://github.com/bodrovis/rating-chgk-v2
389
347
  rubygems_mfa_required: 'true'
390
348
  wiki_uri: https://github.com/bodrovis/rating-chgk-v2/wiki
391
349
  changelog_uri: https://github.com/bodrovis/rating-chgk-v2/blob/master/CHANGELOG.md
@@ -401,55 +359,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
401
359
  version: 2.7.0
402
360
  required_rubygems_version: !ruby/object:Gem::Requirement
403
361
  requirements:
404
- - - ">"
362
+ - - ">="
405
363
  - !ruby/object:Gem::Version
406
- version: 1.3.1
364
+ version: '0'
407
365
  requirements: []
408
- rubygems_version: 3.3.10
366
+ rubygems_version: 3.3.19
409
367
  signing_key:
410
368
  specification_version: 4
411
369
  summary: Ruby interface for the new CHGK rating API
412
- test_files:
413
- - spec/lib/rating_chgk_v2/collections/base_collection_spec.rb
414
- - spec/lib/rating_chgk_v2/collections/countries_collection_spec.rb
415
- - spec/lib/rating_chgk_v2/collections/player_seasons_collection_spec.rb
416
- - spec/lib/rating_chgk_v2/collections/player_tournaments_collection_spec.rb
417
- - spec/lib/rating_chgk_v2/collections/players_collection_spec.rb
418
- - spec/lib/rating_chgk_v2/collections/regions_collection_spec.rb
419
- - spec/lib/rating_chgk_v2/collections/releases_collection_spec.rb
420
- - spec/lib/rating_chgk_v2/collections/seasons_collection_spec.rb
421
- - spec/lib/rating_chgk_v2/collections/teams_collection_spec.rb
422
- - spec/lib/rating_chgk_v2/collections/tournaments_collection_spec.rb
423
- - spec/lib/rating_chgk_v2/collections/towns_collection_spec.rb
424
- - spec/lib/rating_chgk_v2/collections/venue_types_collection_spec.rb
425
- - spec/lib/rating_chgk_v2/collections/venues_collection_spec.rb
426
- - spec/lib/rating_chgk_v2/connection_spec.rb
427
- - spec/lib/rating_chgk_v2/endpoints/base_endpoint_spec.rb
428
- - spec/lib/rating_chgk_v2/error_spec.rb
429
- - spec/lib/rating_chgk_v2/models/country_model_spec.rb
430
- - spec/lib/rating_chgk_v2/models/player_model_spec.rb
431
- - spec/lib/rating_chgk_v2/models/season_model_spec.rb
432
- - spec/lib/rating_chgk_v2/models/team_model_spec.rb
433
- - spec/lib/rating_chgk_v2/models/tournament_model_spec.rb
434
- - spec/lib/rating_chgk_v2/models/venue_model_spec.rb
435
- - spec/lib/rating_chgk_v2/rest/authentication_token_spec.rb
436
- - spec/lib/rating_chgk_v2/rest/countries_spec.rb
437
- - spec/lib/rating_chgk_v2/rest/players_spec.rb
438
- - spec/lib/rating_chgk_v2/rest/regions_spec.rb
439
- - spec/lib/rating_chgk_v2/rest/releases_spec.rb
440
- - spec/lib/rating_chgk_v2/rest/seasons_spec.rb
441
- - spec/lib/rating_chgk_v2/rest/teams_spec.rb
442
- - spec/lib/rating_chgk_v2/rest/tournament_flags_spec.rb
443
- - spec/lib/rating_chgk_v2/rest/tournament_synch_appeals_spec.rb
444
- - spec/lib/rating_chgk_v2/rest/tournament_synch_controversials_spec.rb
445
- - spec/lib/rating_chgk_v2/rest/tournament_synch_requests_spec.rb
446
- - spec/lib/rating_chgk_v2/rest/tournament_types_spec.rb
447
- - spec/lib/rating_chgk_v2/rest/tournaments_spec.rb
448
- - spec/lib/rating_chgk_v2/rest/towns_spec.rb
449
- - spec/lib/rating_chgk_v2/rest/venue_types_spec.rb
450
- - spec/lib/rating_chgk_v2/rest/venues_spec.rb
451
- - spec/lib/rating_chgk_v2_spec.rb
452
- - spec/spec_helper.rb
453
- - spec/support/shared/paginated.rb
454
- - spec/support/test_client.rb
455
- - spec/support/vcr.rb
370
+ test_files: []
@@ -1,53 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe RatingChgkV2::Collections::BaseCollection do
4
- let(:players) do
5
- described_class.new [{
6
- id: 1,
7
- name: 'Ivan',
8
- surname: 'Petrov'
9
- }, {
10
- id: 2,
11
- name: 'Petr',
12
- surname: 'Ivanov'
13
- }]
14
- end
15
-
16
- specify '#first' do
17
- stub_const "#{described_class}::MODEL", 'Player'
18
-
19
- player = players.first
20
- expect(player).to be_an_instance_of(RatingChgkV2::Models::PlayerModel)
21
- expect(player.id).to eq(1)
22
- end
23
-
24
- specify '#last' do
25
- stub_const "#{described_class}::MODEL", 'Player'
26
-
27
- player = players.last
28
- expect(player).to be_an_instance_of(RatingChgkV2::Models::PlayerModel)
29
- expect(player.id).to eq(2)
30
- end
31
-
32
- specify '#[]' do
33
- stub_const "#{described_class}::MODEL", 'Player'
34
-
35
- player = players[1]
36
- expect(player.id).to eq(2)
37
- end
38
-
39
- specify '#each' do
40
- stub_const "#{described_class}::MODEL", 'Player'
41
-
42
- klass = RatingChgkV2::Models::PlayerModel
43
-
44
- expect { |b| players.each(&b) }.to yield_successive_args(klass, klass)
45
- end
46
-
47
- specify '#map' do
48
- stub_const "#{described_class}::MODEL", 'Player'
49
-
50
- mapped = players.map(&:id)
51
- expect(mapped).to include(1, 2)
52
- end
53
- end
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe RatingChgkV2::Collections::CountriesCollection do
4
- it_behaves_like 'paginated'
5
- end
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe RatingChgkV2::Collections::PlayerSeasonsCollection do
4
- it_behaves_like 'paginated'
5
- end
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe RatingChgkV2::Collections::PlayerTournamentsCollection do
4
- it_behaves_like 'paginated'
5
- end
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe RatingChgkV2::Collections::PlayersCollection do
4
- it_behaves_like 'paginated'
5
- end
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe RatingChgkV2::Collections::RegionsCollection do
4
- it_behaves_like 'paginated'
5
- end
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe RatingChgkV2::Collections::ReleasesCollection do
4
- it_behaves_like 'paginated'
5
- end
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe RatingChgkV2::Collections::SeasonsCollection do
4
- it_behaves_like 'paginated'
5
- end
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe RatingChgkV2::Collections::TeamsCollection do
4
- it_behaves_like 'paginated'
5
- end
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe RatingChgkV2::Collections::TournamentsCollection do
4
- it_behaves_like 'paginated'
5
- end
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe RatingChgkV2::Collections::TownsCollection do
4
- it_behaves_like 'paginated'
5
- end
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe RatingChgkV2::Collections::VenueTypesCollection do
4
- it_behaves_like 'paginated'
5
- end
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe RatingChgkV2::Collections::VenuesCollection do
4
- it_behaves_like 'paginated'
5
- end
@@ -1,22 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe RatingChgkV2::Connection do
4
- let(:dummy) { Class.new { include RatingChgkV2::Connection }.new }
5
-
6
- before { RatingChgkV2.reset_client! }
7
-
8
- after { RatingChgkV2.reset_client! }
9
-
10
- it 'allows to customize timeouts' do
11
- custom_client = RatingChgkV2.client(params: {open_timeout: 100, timeout: 500})
12
- conn = dummy.connection custom_client
13
- expect(conn.options.timeout).to eq(500)
14
- expect(conn.options.open_timeout).to eq(100)
15
-
16
- custom_client.timeout = 300
17
- custom_client.open_timeout = 200
18
- another_conn = dummy.connection custom_client
19
- expect(another_conn.options.timeout).to eq(300)
20
- expect(another_conn.options.open_timeout).to eq(200)
21
- end
22
- end
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe RatingChgkV2::Endpoints::BaseEndpoint do
4
- subject { described_class.new test_client }
5
-
6
- let(:endpoint) { subject }
7
-
8
- it { is_expected.to respond_to(:do_get) }
9
- it { is_expected.to respond_to(:do_post) }
10
- it { is_expected.not_to respond_to(:very_wrong_method) }
11
-
12
- it 'raises an error when calling invalid methods' do
13
- expect { endpoint.very_wrong_method }.to raise_error(NoMethodError)
14
- end
15
- end
@@ -1,11 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe RatingChgkV2::Error do
4
- it 'raises NotFound for 404 status code' do
5
- expect do
6
- VCR.use_cassette('error/error_404') do
7
- test_client.player(3)
8
- end
9
- end.to raise_error(RatingChgkV2::Error::NotFound)
10
- end
11
- end
@@ -1,30 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe RatingChgkV2::Models::CountryModel do
4
- let!(:country) do
5
- VCR.use_cassette('countries/country') do
6
- test_client.country 20
7
- end
8
- end
9
-
10
- specify '#update' do
11
- stub_request(:put, 'https://api.rating.chgk.net/countries/20').
12
- with(body: {name: 'Обновлённая страна'}).
13
- to_return(
14
- status: 200,
15
- body: '{"id":20,"name":"Обновлённая страна"}',
16
- headers: {}
17
- )
18
-
19
- updated_country = country.update name: 'Обновлённая страна'
20
- expect(updated_country).to be_an_instance_of(described_class)
21
- expect(updated_country.name).to eq('Обновлённая страна')
22
- expect(updated_country.id).to eq(20)
23
- end
24
-
25
- specify '#destroy' do
26
- stub_request(:delete, 'https://api.rating.chgk.net/countries/20').to_return(status: 204, body: '', headers: {})
27
-
28
- expect(country.destroy).to eq('')
29
- end
30
- end
@@ -1,59 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe RatingChgkV2::Models::PlayerModel do
4
- let(:player) do
5
- VCR.use_cassette('players/player') do
6
- test_client.player(player_id)
7
- end
8
- end
9
-
10
- let(:player_id) { 1110 }
11
-
12
- describe '#seasons' do
13
- it 'returns all seasons' do
14
- player_seasons = VCR.use_cassette('players/player_seasons') do
15
- player.seasons
16
- end
17
-
18
- expect(player_seasons).to be_an_instance_of(RatingChgkV2::Collections::PlayerSeasonsCollection)
19
- season = player_seasons.first
20
-
21
- expect(season.idplayer).to eq(player_id)
22
- expect(season.idseason).to eq(7)
23
- end
24
-
25
- it 'returns seasons by params' do
26
- season = VCR.use_cassette('players/player_seasons_params') do
27
- player.seasons itemsPerPage: 2, idseason: 8, idteam: 7456
28
- end.first
29
-
30
- expect(season.idplayer).to eq(player_id)
31
- expect(season.idseason).to eq(8)
32
- expect(season.idteam).to eq(7456)
33
- end
34
- end
35
-
36
- describe '#tournaments' do
37
- it 'returns all tournaments' do
38
- player_tournaments = VCR.use_cassette('players/player_tournaments') do
39
- player.tournaments
40
- end
41
-
42
- expect(player_tournaments).to be_an_instance_of(RatingChgkV2::Collections::PlayerTournamentsCollection)
43
- tour = player_tournaments.first
44
-
45
- expect(tour.idtournament).to eq(314)
46
- expect(tour.idteam).to eq(7121)
47
- end
48
-
49
- it 'returns tournaments by params' do
50
- tour = VCR.use_cassette('players/player_tournaments_params') do
51
- player.tournaments itemsPerPage: 2
52
- end.first
53
-
54
- expect(tour.idplayer).to eq(player_id)
55
- expect(tour.idtournament).to eq(314)
56
- expect(tour.idteam).to eq(7121)
57
- end
58
- end
59
- end
@@ -1,36 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe RatingChgkV2::Models::SeasonModel do
4
- let!(:season) do
5
- VCR.use_cassette('seasons/season') do
6
- test_client.season 5
7
- end
8
- end
9
-
10
- specify '#update' do
11
- data = {
12
- dateStart: '2021-02-05T19:37:45.004Z',
13
- dateEnd: '2021-02-05T19:37:45.004Z'
14
- }
15
-
16
- stub_request(:put, 'https://api.rating.chgk.net/seasons/5').
17
- with(body: data).
18
- to_return(
19
- status: 200,
20
- body: JSON.dump(data.merge({id: season.id})),
21
- headers: {}
22
- )
23
-
24
- updated_season = season.update data
25
- expect(updated_season).to be_an_instance_of(described_class)
26
- expect(updated_season.id).to eq(5)
27
- expect(updated_season.dateStart).to eq(data[:dateStart])
28
- expect(updated_season.dateEnd).to eq(data[:dateEnd])
29
- end
30
-
31
- specify '#destroy' do
32
- stub_request(:delete, 'https://api.rating.chgk.net/seasons/5').to_return(status: 204, body: '', headers: {})
33
-
34
- expect(season.destroy).to eq('')
35
- end
36
- end
@@ -1,35 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe RatingChgkV2::Models::TeamModel do
4
- let(:team_id) { 2 }
5
- let(:team) do
6
- VCR.use_cassette('teams/team') do
7
- test_client.team(team_id)
8
- end
9
- end
10
-
11
- describe '#seasons' do
12
- it 'returns seasons by params' do
13
- season = VCR.use_cassette('teams/team_seasons_params') do
14
- team.seasons idseason: 9
15
- end.first
16
-
17
- expect(season).to be_an_instance_of(RatingChgkV2::Models::PlayerSeasonModel)
18
- expect(season.idplayer).to eq(707)
19
- expect(season.idseason).to eq(9)
20
- expect(season.idteam).to eq(team_id)
21
- end
22
- end
23
-
24
- describe '#tournaments' do
25
- it 'returns tournaments by params' do
26
- tour = VCR.use_cassette('teams/team_tournaments_params') do
27
- team.tournaments pagination: true
28
- end[2]
29
-
30
- expect(tour).to be_an_instance_of(RatingChgkV2::Models::TeamTournamentModel)
31
- expect(tour.idtournament).to eq(8)
32
- expect(tour.idteam).to eq(team_id)
33
- end
34
- end
35
- end
@@ -1,38 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe RatingChgkV2::Models::TournamentModel do
4
- let(:tournament_id) { 7798 }
5
- let(:tournament) do
6
- VCR.use_cassette('tournaments/tournament') do
7
- test_client.tournament(tournament_id)
8
- end
9
- end
10
-
11
- specify '#appeals' do
12
- appeals = VCR.use_cassette('tournaments/appeals') do
13
- tournament.appeals
14
- end
15
-
16
- expect(appeals[0].id).to eq(12_153)
17
- expect(appeals[0].questionNumber).to eq(20)
18
- end
19
-
20
- specify '#requests' do
21
- requests = VCR.use_cassette('tournaments/requests') do
22
- tournament.requests
23
- end
24
-
25
- expect(requests[0].id).to eq(101_060)
26
- expect(requests[0].status).to eq('A')
27
- end
28
-
29
- specify '#results' do
30
- results = VCR.use_cassette('tournaments/results') do
31
- tournament.results includeTeamMembers: 1, includeMasksAndControversials: 1,
32
- includeTeamFlags: 1, includeRatingB: 1, town: 202
33
- end.first
34
-
35
- expect(results.team['id']).to eq(53_341)
36
- expect(results.position).to eq(1)
37
- end
38
- end