Sha256: 867478633ae0a6fe53fab5259460612708898659698c5371826d94c72b5b4e4b

Contents?: true

Size: 980 Bytes

Versions: 2

Compression:

Stored size: 980 Bytes

Contents

# frozen_string_literal: true

RSpec.describe RatingChgkV2::Models::CountryModel do
  let!(:country) do
    VCR.use_cassette('countries/country') do
      test_client.country 20
    end
  end

  specify '#update' do
    stub_request(:put, 'https://api.rating.chgk.net/countries/20').
      with(body: {name: 'Обновлённая страна'}).
      to_return(
        status: 200,
        body: '{"id":20,"name":"Обновлённая страна"}',
        headers: {}
      )

    updated_country = country.update name: 'Обновлённая страна'
    expect(updated_country).to be_an_instance_of(described_class)
    expect(updated_country.name).to eq('Обновлённая страна')
    expect(updated_country.id).to eq(20)
  end

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

    expect(country.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/country_model_spec.rb
rating-chgk-v2-1.0.0.rc1 spec/lib/rating_chgk_v2/models/country_model_spec.rb