rating-chgk-v2 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
@@ -1,46 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
RSpec.describe RatingChgkV2::Rest::VenueTypes do
|
4
|
-
let(:type_id) { 1 }
|
5
|
-
|
6
|
-
specify '#venue_type' do
|
7
|
-
venue_type = VCR.use_cassette('venue_types/venue_type') do
|
8
|
-
test_client.venue_type(type_id)
|
9
|
-
end
|
10
|
-
|
11
|
-
expect(venue_type.id).to eq(type_id)
|
12
|
-
expect(venue_type.name).to eq('Постоянная')
|
13
|
-
end
|
14
|
-
|
15
|
-
describe '#venue_types' do
|
16
|
-
it 'returns a collection of venue types' do
|
17
|
-
types = VCR.use_cassette('venue_types/venue_types') do
|
18
|
-
test_client.venue_types
|
19
|
-
end
|
20
|
-
|
21
|
-
expect(types[0].name).to eq('Постоянная')
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'returns a collection of venue types with params' do
|
25
|
-
types = VCR.use_cassette('venue_types/all_venue_types_params') do
|
26
|
-
test_client.venue_types itemsPerPage: 3, page: 2
|
27
|
-
end
|
28
|
-
|
29
|
-
expect(types[0].name).to eq('Разовая')
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
specify '#create_venue_type' do
|
34
|
-
stub_request(:post, 'https://api.rating.chgk.net/venue_types').
|
35
|
-
with(body: {name: 'Фейковая'}).
|
36
|
-
to_return(
|
37
|
-
status: 201,
|
38
|
-
body: '{"id":0,"name":"Фейковая"}',
|
39
|
-
headers: {}
|
40
|
-
)
|
41
|
-
|
42
|
-
venue_type = test_client.create_venue_type name: 'Фейковая'
|
43
|
-
expect(venue_type.name).to eq('Фейковая')
|
44
|
-
expect(venue_type.id).to eq(0)
|
45
|
-
end
|
46
|
-
end
|
@@ -1,71 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
RSpec.describe RatingChgkV2::Rest::Venues do
|
4
|
-
let(:venue_id) { 3601 }
|
5
|
-
|
6
|
-
specify '#venue' do
|
7
|
-
venue = VCR.use_cassette('venues/venue') do
|
8
|
-
test_client.venue(venue_id)
|
9
|
-
end
|
10
|
-
|
11
|
-
expect(venue.id).to eq(venue_id)
|
12
|
-
expect(venue.name).to eq('Библиотека')
|
13
|
-
expect(venue.town['name']).to eq('Витебск')
|
14
|
-
expect(venue.type['name']).to eq('Постоянная')
|
15
|
-
expect(venue.address).to eq('Витебск, пр. Фрунзе 30а')
|
16
|
-
expect(venue.urls.first).to include('vk.com')
|
17
|
-
end
|
18
|
-
|
19
|
-
describe '#venues' do
|
20
|
-
it 'returns a collection of venues' do
|
21
|
-
venues = VCR.use_cassette('venues/venues') do
|
22
|
-
test_client.venues
|
23
|
-
end
|
24
|
-
|
25
|
-
expect(venues[0].id).to eq(3030)
|
26
|
-
end
|
27
|
-
|
28
|
-
it 'returns a collection of venues with params' do
|
29
|
-
venues = VCR.use_cassette('venues/all_venues_params') do
|
30
|
-
test_client.venues itemsPerPage: 3, page: 2
|
31
|
-
end
|
32
|
-
|
33
|
-
expect(venues.count).to eq(3)
|
34
|
-
expect(venues[0].name).to eq('Ереван')
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
specify '#create_venue' do
|
39
|
-
stub_request(:post, 'https://api.rating.chgk.net/venues').
|
40
|
-
with(body: {name: 'Фейк', type: {name: 'Фейковый тип'}}).
|
41
|
-
to_return(
|
42
|
-
status: 201,
|
43
|
-
body: '{"id":0,"name":"Фейк","type":{"id":0,"name":"Фейковый тип"}}',
|
44
|
-
headers: {}
|
45
|
-
)
|
46
|
-
|
47
|
-
venue = test_client.create_venue name: 'Фейк', type: {name: 'Фейковый тип'}
|
48
|
-
expect(venue.name).to eq('Фейк')
|
49
|
-
expect(venue.type['id']).to eq(0)
|
50
|
-
end
|
51
|
-
|
52
|
-
specify '#update_venue' do
|
53
|
-
stub_request(:put, 'https://api.rating.chgk.net/venues/0').
|
54
|
-
with(body: {name: 'Обновлённая'}).
|
55
|
-
to_return(
|
56
|
-
status: 200,
|
57
|
-
body: '{"id":0,"name":"Обновлённая"}',
|
58
|
-
headers: {}
|
59
|
-
)
|
60
|
-
|
61
|
-
venue = test_client.update_venue 0, name: 'Обновлённая'
|
62
|
-
expect(venue.name).to eq('Обновлённая')
|
63
|
-
expect(venue.id).to eq(0)
|
64
|
-
end
|
65
|
-
|
66
|
-
specify '#delete_country' do
|
67
|
-
stub_request(:delete, 'https://api.rating.chgk.net/venues/1').to_return(status: 204, body: '', headers: {})
|
68
|
-
|
69
|
-
expect(test_client.delete_venue(1)).to eq('')
|
70
|
-
end
|
71
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'dotenv/load'
|
4
|
-
require 'simplecov'
|
5
|
-
require 'webmock/rspec'
|
6
|
-
|
7
|
-
SimpleCov.start do
|
8
|
-
add_filter 'spec/'
|
9
|
-
add_filter '.github/'
|
10
|
-
end
|
11
|
-
|
12
|
-
if ENV['CI'] == 'true'
|
13
|
-
require 'codecov'
|
14
|
-
SimpleCov.formatter = SimpleCov::Formatter::Codecov
|
15
|
-
end
|
16
|
-
|
17
|
-
require 'rating_chgk_v2'
|
18
|
-
|
19
|
-
# Support files
|
20
|
-
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].sort.each { |f| require f }
|
21
|
-
|
22
|
-
RSpec.configure do |config|
|
23
|
-
config.include TestClient
|
24
|
-
|
25
|
-
WebMock.allow_net_connect!
|
26
|
-
WebMock::API.prepend(Module.new do
|
27
|
-
extend self
|
28
|
-
# disable VCR when a WebMock stub is created
|
29
|
-
# for clearer spec failure messaging
|
30
|
-
def stub_request(*args)
|
31
|
-
VCR.turn_off!
|
32
|
-
super
|
33
|
-
end
|
34
|
-
end)
|
35
|
-
|
36
|
-
config.before { VCR.turn_on! }
|
37
|
-
end
|
@@ -1,41 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
RSpec.shared_examples 'paginated' do
|
4
|
-
let(:endpoint) { RatingChgkV2::Endpoints::BaseEndpoint.new test_client }
|
5
|
-
let(:collection) { described_class.new [], endpoint }
|
6
|
-
|
7
|
-
specify '#next_page!' do
|
8
|
-
allow(endpoint).to receive(:do_get).and_return([{paginated: true}])
|
9
|
-
expect(endpoint.params[:page]).to be_nil
|
10
|
-
|
11
|
-
expect(collection.next_page!).to be_an_instance_of(described_class)
|
12
|
-
expect(endpoint).to have_received(:do_get)
|
13
|
-
|
14
|
-
expect(collection.first.class.superclass).to eq(RatingChgkV2::Models::BaseModel)
|
15
|
-
expect(endpoint.params[:page]).to eq(2)
|
16
|
-
end
|
17
|
-
|
18
|
-
describe '#prev_page!' do
|
19
|
-
it 'fetches the previous page' do
|
20
|
-
allow(endpoint).to receive(:do_get).and_return([{paginated: true}])
|
21
|
-
allow(endpoint.params).to receive(:[]).with(:page).and_return(3)
|
22
|
-
|
23
|
-
expect(collection.prev_page!).to be_an_instance_of(described_class)
|
24
|
-
expect(endpoint).to have_received(:do_get)
|
25
|
-
|
26
|
-
expect(collection.first.class.superclass).to eq(RatingChgkV2::Models::BaseModel)
|
27
|
-
expect(endpoint.params[:page]).to eq(2)
|
28
|
-
end
|
29
|
-
|
30
|
-
it 'does not fetch anything when the page is the first one' do
|
31
|
-
allow(endpoint).to receive(:do_get).and_return([{paginated: true}])
|
32
|
-
expect(endpoint.params[:page]).to be_nil
|
33
|
-
|
34
|
-
expect(collection.prev_page!).to be_nil
|
35
|
-
expect(endpoint).not_to have_received(:do_get)
|
36
|
-
|
37
|
-
expect(collection.first).to be_nil
|
38
|
-
expect(endpoint.params[:page]).to be_nil
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
data/spec/support/test_client.rb
DELETED
data/spec/support/vcr.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'vcr'
|
4
|
-
|
5
|
-
VCR.configure do |c|
|
6
|
-
c.ignore_hosts 'codeclimate.com'
|
7
|
-
c.hook_into :faraday
|
8
|
-
c.default_cassette_options = {
|
9
|
-
decode_compressed_response: true
|
10
|
-
}
|
11
|
-
c.cassette_library_dir = File.join(File.dirname(__FILE__), '..', 'fixtures', 'vcr_cassettes')
|
12
|
-
c.filter_sensitive_data('<API_TOKEN>') { ENV.fetch('API_TOKEN', 'hidden') }
|
13
|
-
c.filter_sensitive_data('<CHGK_EMAIL>') { ENV.fetch('CHGK_EMAIL', 'fake') }
|
14
|
-
c.filter_sensitive_data('<CHGK_PASSWORD>') { ENV.fetch('CHGK_PASSWORD', 'fake') }
|
15
|
-
end
|