Sha256: 4d97172ae4beed17a8d946dd436777c5e0aa2782159dc962b9d73f551125d973

Contents?: true

Size: 1.7 KB

Versions: 2

Compression:

Stored size: 1.7 KB

Contents

# frozen_string_literal: true

RSpec.describe RatingChgkV2::Models::PlayerModel do
  let(:player) do
    VCR.use_cassette('players/player') do
      test_client.player(player_id)
    end
  end

  let(:player_id) { 1110 }

  describe '#seasons' do
    it 'returns all seasons' do
      player_seasons = VCR.use_cassette('players/player_seasons') do
        player.seasons
      end

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

      expect(season.idplayer).to eq(player_id)
      expect(season.idseason).to eq(7)
    end

    it 'returns seasons by params' do
      season = VCR.use_cassette('players/player_seasons_params') do
        player.seasons itemsPerPage: 2, idseason: 8, idteam: 7456
      end.first

      expect(season.idplayer).to eq(player_id)
      expect(season.idseason).to eq(8)
      expect(season.idteam).to eq(7456)
    end
  end

  describe '#tournaments' do
    it 'returns all tournaments' do
      player_tournaments = VCR.use_cassette('players/player_tournaments') do
        player.tournaments
      end

      expect(player_tournaments).to be_an_instance_of(RatingChgkV2::Collections::PlayerTournamentsCollection)
      tour = player_tournaments.first

      expect(tour.idtournament).to eq(314)
      expect(tour.idteam).to eq(7121)
    end

    it 'returns tournaments by params' do
      tour = VCR.use_cassette('players/player_tournaments_params') do
        player.tournaments itemsPerPage: 2
      end.first

      expect(tour.idplayer).to eq(player_id)
      expect(tour.idtournament).to eq(314)
      expect(tour.idteam).to eq(7121)
    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/models/player_model_spec.rb
rating-chgk-v2-1.0.0.rc1 spec/lib/rating_chgk_v2/models/player_model_spec.rb