Sha256: f0665949ceee76a6ecf9f722f11f1995cf685ccd76940462e83352c3610634ca

Contents?: true

Size: 1016 Bytes

Versions: 2

Compression:

Stored size: 1016 Bytes

Contents

# frozen_string_literal: true

RSpec.describe RatingChgkV2::Models::SeasonModel do
  let!(:season) do
    VCR.use_cassette('seasons/season') do
      test_client.season 5
    end
  end

  specify '#update' do
    data = {
      dateStart: '2021-02-05T19:37:45.004Z',
      dateEnd: '2021-02-05T19:37:45.004Z'
    }

    stub_request(:put, 'https://api.rating.chgk.net/seasons/5').
      with(body: data).
      to_return(
        status: 200,
        body: JSON.dump(data.merge({id: season.id})),
        headers: {}
      )

    updated_season = season.update data
    expect(updated_season).to be_an_instance_of(described_class)
    expect(updated_season.id).to eq(5)
    expect(updated_season.dateStart).to eq(data[:dateStart])
    expect(updated_season.dateEnd).to eq(data[:dateEnd])
  end

  specify '#destroy' do
    stub_request(:delete, 'https://api.rating.chgk.net/seasons/5').to_return(status: 204, body: '', headers: {})

    expect(season.destroy).to eq('')
  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/season_model_spec.rb
rating-chgk-v2-1.0.0.rc1 spec/lib/rating_chgk_v2/models/season_model_spec.rb