Sha256: a444a4b458150dd70436aea0400ec655315e57d303e887d8610c63785e39abff

Contents?: true

Size: 1.88 KB

Versions: 2

Compression:

Stored size: 1.88 KB

Contents

# frozen_string_literal: true

RSpec.describe RatingChgkV2::Rest::Teams do
  let(:team_id) { 2 }

  specify '#team' do
    team = VCR.use_cassette('teams/team') do
      test_client.team(team_id)
    end

    expect(team.id).to eq(team_id)
    expect(team.name).to eq('Афина')
    expect(team.town['id']).to eq(201)
  end

  describe '#teams' do
    it 'returns a collection of teams' do
      teams = VCR.use_cassette('teams/all_teams') do
        test_client.teams
      end

      expect(teams[1].name).to eq('Афина')
      expect(teams[1].id).to eq(2)
      expect(teams[1].town['id']).to eq(201)
    end

    it 'returns a collection of teams with params' do
      teams = VCR.use_cassette('teams/all_teams_params') do
        test_client.teams itemsPerPage: 2, name: 'Н', page: 3
      end

      expect(teams.count).to eq(2)
      expect(teams[0].name).to eq('Миллениум')
      expect(teams[0].id).to eq(11)
      expect(teams[0].town['id']).to eq(282)
    end
  end

  describe '#team_seasons' do
    it 'returns seasons by params' do
      team_seasons = VCR.use_cassette('teams/team_seasons_params') do
        test_client.team_seasons team_id, idseason: 9
      end

      expect(team_seasons).to be_an_instance_of(RatingChgkV2::Collections::PlayerSeasonsCollection)
      season = team_seasons.first

      expect(season.idplayer).to eq(707)
      expect(season.idseason).to eq(9)
      expect(season.idteam).to eq(team_id)
    end
  end

  describe '#team_tournaments' do
    it 'returns a collection of team tournaments with params' do
      team_tournaments = VCR.use_cassette('teams/team_tournaments_params') do
        test_client.team_tournaments team_id, pagination: true
      end

      tour = team_tournaments[2]

      expect(tour.idtournament).to eq(8)
      expect(tour.idteam).to eq(team_id)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rating-chgk-v2-1.0.0 spec/lib/rating_chgk_v2/rest/teams_spec.rb
rating-chgk-v2-1.0.0.rc1 spec/lib/rating_chgk_v2/rest/teams_spec.rb