rating-chgk-v2 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/rating_chgk_v2/endpoints/base_endpoint.rb +3 -2
- data/lib/rating_chgk_v2/request.rb +0 -1
- data/lib/rating_chgk_v2/version.rb +1 -1
- data/lib/rating_chgk_v2.rb +1 -1
- data/rating-chgk-v2.gemspec +0 -2
- metadata +4 -91
- data/spec/lib/rating_chgk_v2/collections/base_collection_spec.rb +0 -53
- data/spec/lib/rating_chgk_v2/collections/countries_collection_spec.rb +0 -5
- data/spec/lib/rating_chgk_v2/collections/player_seasons_collection_spec.rb +0 -5
- data/spec/lib/rating_chgk_v2/collections/player_tournaments_collection_spec.rb +0 -5
- data/spec/lib/rating_chgk_v2/collections/players_collection_spec.rb +0 -5
- data/spec/lib/rating_chgk_v2/collections/regions_collection_spec.rb +0 -5
- data/spec/lib/rating_chgk_v2/collections/releases_collection_spec.rb +0 -5
- data/spec/lib/rating_chgk_v2/collections/seasons_collection_spec.rb +0 -5
- data/spec/lib/rating_chgk_v2/collections/teams_collection_spec.rb +0 -5
- data/spec/lib/rating_chgk_v2/collections/tournaments_collection_spec.rb +0 -5
- data/spec/lib/rating_chgk_v2/collections/towns_collection_spec.rb +0 -5
- data/spec/lib/rating_chgk_v2/collections/venue_types_collection_spec.rb +0 -5
- data/spec/lib/rating_chgk_v2/collections/venues_collection_spec.rb +0 -5
- data/spec/lib/rating_chgk_v2/connection_spec.rb +0 -22
- data/spec/lib/rating_chgk_v2/endpoints/base_endpoint_spec.rb +0 -15
- data/spec/lib/rating_chgk_v2/error_spec.rb +0 -11
- data/spec/lib/rating_chgk_v2/models/country_model_spec.rb +0 -30
- data/spec/lib/rating_chgk_v2/models/player_model_spec.rb +0 -59
- data/spec/lib/rating_chgk_v2/models/season_model_spec.rb +0 -36
- data/spec/lib/rating_chgk_v2/models/team_model_spec.rb +0 -35
- data/spec/lib/rating_chgk_v2/models/tournament_model_spec.rb +0 -38
- data/spec/lib/rating_chgk_v2/models/venue_model_spec.rb +0 -30
- data/spec/lib/rating_chgk_v2/rest/authentication_token_spec.rb +0 -19
- data/spec/lib/rating_chgk_v2/rest/countries_spec.rb +0 -94
- data/spec/lib/rating_chgk_v2/rest/players_spec.rb +0 -126
- data/spec/lib/rating_chgk_v2/rest/regions_spec.rb +0 -37
- data/spec/lib/rating_chgk_v2/rest/releases_spec.rb +0 -34
- data/spec/lib/rating_chgk_v2/rest/seasons_spec.rb +0 -71
- data/spec/lib/rating_chgk_v2/rest/teams_spec.rb +0 -66
- data/spec/lib/rating_chgk_v2/rest/tournament_flags_spec.rb +0 -27
- data/spec/lib/rating_chgk_v2/rest/tournament_synch_appeals_spec.rb +0 -22
- data/spec/lib/rating_chgk_v2/rest/tournament_synch_controversials_spec.rb +0 -20
- data/spec/lib/rating_chgk_v2/rest/tournament_synch_requests_spec.rb +0 -20
- data/spec/lib/rating_chgk_v2/rest/tournament_types_spec.rb +0 -23
- data/spec/lib/rating_chgk_v2/rest/tournaments_spec.rb +0 -89
- data/spec/lib/rating_chgk_v2/rest/towns_spec.rb +0 -35
- data/spec/lib/rating_chgk_v2/rest/venue_types_spec.rb +0 -46
- data/spec/lib/rating_chgk_v2/rest/venues_spec.rb +0 -71
- data/spec/lib/rating_chgk_v2_spec.rb +0 -9
- data/spec/spec_helper.rb +0 -37
- data/spec/support/shared/paginated.rb +0 -41
- data/spec/support/test_client.rb +0 -7
- data/spec/support/vcr.rb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 32e9b5b23a321dcdc852d8ad1ee65ee64e2b0ac34f12141d5b5b6ac3b1907df5
|
4
|
+
data.tar.gz: 6384799d428ad6e9d541f589d90916aaf63e2aea34b72b24ee4efafe21fc0249
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d576f34181d9ef0f059cd33a10f0bc7db83b0554eb3f372144597b0f24e7d5eb784d3766c260ad81bd454be66c77fde4a9ae0a0626737bd4b0f4dac4e3bb8a8
|
7
|
+
data.tar.gz: 8835357de3b4eab7b1e693ff8ea9a9c20c573efb38156694733bf0e36969ac1591b77418ad17f59ff730dfd39f7788e70dc968e1b8073996cb59f2da40c9b846
|
data/CHANGELOG.md
CHANGED
@@ -8,12 +8,13 @@ module RatingChgkV2
|
|
8
8
|
attr_reader :params
|
9
9
|
|
10
10
|
def initialize(client, query_params = [], params = {})
|
11
|
-
|
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? ? @
|
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
|
data/lib/rating_chgk_v2.rb
CHANGED
data/rating-chgk-v2.gemspec
CHANGED
@@ -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,7 +38,6 @@ 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 = {
|
42
|
-
'homepage_uri' => 'https://github.com/bodrovis/rating-chgk-v2',
|
43
41
|
'source_code_uri' => 'https://github.com/bodrovis/rating-chgk-v2',
|
44
42
|
'rubygems_mfa_required' => 'true',
|
45
43
|
'wiki_uri' => 'https://github.com/bodrovis/rating-chgk-v2/wiki',
|
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.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ilya Krukowski
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-07-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -339,54 +339,10 @@ 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:
|
389
|
-
homepage_uri: https://github.com/bodrovis/rating-chgk-v2
|
390
346
|
source_code_uri: https://github.com/bodrovis/rating-chgk-v2
|
391
347
|
rubygems_mfa_required: 'true'
|
392
348
|
wiki_uri: https://github.com/bodrovis/rating-chgk-v2/wiki
|
@@ -407,51 +363,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
407
363
|
- !ruby/object:Gem::Version
|
408
364
|
version: '0'
|
409
365
|
requirements: []
|
410
|
-
rubygems_version: 3.3.
|
366
|
+
rubygems_version: 3.3.19
|
411
367
|
signing_key:
|
412
368
|
specification_version: 4
|
413
369
|
summary: Ruby interface for the new CHGK rating API
|
414
|
-
test_files:
|
415
|
-
- spec/lib/rating_chgk_v2/collections/base_collection_spec.rb
|
416
|
-
- spec/lib/rating_chgk_v2/collections/countries_collection_spec.rb
|
417
|
-
- spec/lib/rating_chgk_v2/collections/player_seasons_collection_spec.rb
|
418
|
-
- spec/lib/rating_chgk_v2/collections/player_tournaments_collection_spec.rb
|
419
|
-
- spec/lib/rating_chgk_v2/collections/players_collection_spec.rb
|
420
|
-
- spec/lib/rating_chgk_v2/collections/regions_collection_spec.rb
|
421
|
-
- spec/lib/rating_chgk_v2/collections/releases_collection_spec.rb
|
422
|
-
- spec/lib/rating_chgk_v2/collections/seasons_collection_spec.rb
|
423
|
-
- spec/lib/rating_chgk_v2/collections/teams_collection_spec.rb
|
424
|
-
- spec/lib/rating_chgk_v2/collections/tournaments_collection_spec.rb
|
425
|
-
- spec/lib/rating_chgk_v2/collections/towns_collection_spec.rb
|
426
|
-
- spec/lib/rating_chgk_v2/collections/venue_types_collection_spec.rb
|
427
|
-
- spec/lib/rating_chgk_v2/collections/venues_collection_spec.rb
|
428
|
-
- spec/lib/rating_chgk_v2/connection_spec.rb
|
429
|
-
- spec/lib/rating_chgk_v2/endpoints/base_endpoint_spec.rb
|
430
|
-
- spec/lib/rating_chgk_v2/error_spec.rb
|
431
|
-
- spec/lib/rating_chgk_v2/models/country_model_spec.rb
|
432
|
-
- spec/lib/rating_chgk_v2/models/player_model_spec.rb
|
433
|
-
- spec/lib/rating_chgk_v2/models/season_model_spec.rb
|
434
|
-
- spec/lib/rating_chgk_v2/models/team_model_spec.rb
|
435
|
-
- spec/lib/rating_chgk_v2/models/tournament_model_spec.rb
|
436
|
-
- spec/lib/rating_chgk_v2/models/venue_model_spec.rb
|
437
|
-
- spec/lib/rating_chgk_v2/rest/authentication_token_spec.rb
|
438
|
-
- spec/lib/rating_chgk_v2/rest/countries_spec.rb
|
439
|
-
- spec/lib/rating_chgk_v2/rest/players_spec.rb
|
440
|
-
- spec/lib/rating_chgk_v2/rest/regions_spec.rb
|
441
|
-
- spec/lib/rating_chgk_v2/rest/releases_spec.rb
|
442
|
-
- spec/lib/rating_chgk_v2/rest/seasons_spec.rb
|
443
|
-
- spec/lib/rating_chgk_v2/rest/teams_spec.rb
|
444
|
-
- spec/lib/rating_chgk_v2/rest/tournament_flags_spec.rb
|
445
|
-
- spec/lib/rating_chgk_v2/rest/tournament_synch_appeals_spec.rb
|
446
|
-
- spec/lib/rating_chgk_v2/rest/tournament_synch_controversials_spec.rb
|
447
|
-
- spec/lib/rating_chgk_v2/rest/tournament_synch_requests_spec.rb
|
448
|
-
- spec/lib/rating_chgk_v2/rest/tournament_types_spec.rb
|
449
|
-
- spec/lib/rating_chgk_v2/rest/tournaments_spec.rb
|
450
|
-
- spec/lib/rating_chgk_v2/rest/towns_spec.rb
|
451
|
-
- spec/lib/rating_chgk_v2/rest/venue_types_spec.rb
|
452
|
-
- spec/lib/rating_chgk_v2/rest/venues_spec.rb
|
453
|
-
- spec/lib/rating_chgk_v2_spec.rb
|
454
|
-
- spec/spec_helper.rb
|
455
|
-
- spec/support/shared/paginated.rb
|
456
|
-
- spec/support/test_client.rb
|
457
|
-
- 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,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
|
@@ -1,30 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
RSpec.describe RatingChgkV2::Models::VenueModel do
|
4
|
-
let!(:venue) do
|
5
|
-
VCR.use_cassette('venues/venue') do
|
6
|
-
test_client.venue 3601
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
specify '#update' do
|
11
|
-
stub_request(:put, 'https://api.rating.chgk.net/venues/3601').
|
12
|
-
with(body: {name: 'Обновлённая'}).
|
13
|
-
to_return(
|
14
|
-
status: 201,
|
15
|
-
body: '{"id":3601,"name":"Обновлённая"}',
|
16
|
-
headers: {}
|
17
|
-
)
|
18
|
-
|
19
|
-
updated_venue = venue.update name: 'Обновлённая'
|
20
|
-
expect(updated_venue).to be_an_instance_of(described_class)
|
21
|
-
expect(updated_venue.name).to eq('Обновлённая')
|
22
|
-
expect(updated_venue.id).to eq(3601)
|
23
|
-
end
|
24
|
-
|
25
|
-
specify '#destroy' do
|
26
|
-
stub_request(:delete, 'https://api.rating.chgk.net/venues/3601').to_return(status: 204, body: '', headers: {})
|
27
|
-
|
28
|
-
expect(venue.destroy).to eq('')
|
29
|
-
end
|
30
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
RSpec.describe RatingChgkV2::Rest::AuthenticationToken do
|
4
|
-
it 'raises 401 for incorrect email and password' do
|
5
|
-
expect do
|
6
|
-
VCR.use_cassette('authentication_token/token_401') do
|
7
|
-
test_client.authentication_token email: 'fake@example.com', password: '123'
|
8
|
-
end
|
9
|
-
end.to raise_error(RatingChgkV2::Error::Unauthorized)
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'returns token for correct email and password' do
|
13
|
-
token_obj = VCR.use_cassette('authentication_token/token') do
|
14
|
-
test_client.authentication_token email: ENV['CHGK_EMAIL'], password: ENV['CHGK_PASSWORD']
|
15
|
-
end
|
16
|
-
|
17
|
-
expect(token_obj.token).to eq('stubbed_token')
|
18
|
-
end
|
19
|
-
end
|