Sha256: 6eb1453e4c2d3e9d085ffed61b1845c53d2d8270ae854218df983a2e8d82c530

Contents?: true

Size: 1.31 KB

Versions: 2

Compression:

Stored size: 1.31 KB

Contents

# frozen_string_literal: true

RSpec.describe RatingChgkV2::Rest::VenueTypes do
  let(:type_id) { 1 }

  specify '#venue_type' do
    venue_type = VCR.use_cassette('venue_types/venue_type') do
      test_client.venue_type(type_id)
    end

    expect(venue_type.id).to eq(type_id)
    expect(venue_type.name).to eq('Постоянная')
  end

  describe '#venue_types' do
    it 'returns a collection of venue types' do
      types = VCR.use_cassette('venue_types/venue_types') do
        test_client.venue_types
      end

      expect(types[0].name).to eq('Постоянная')
    end

    it 'returns a collection of venue types with params' do
      types = VCR.use_cassette('venue_types/all_venue_types_params') do
        test_client.venue_types itemsPerPage: 3, page: 2
      end

      expect(types[0].name).to eq('Разовая')
    end
  end

  specify '#create_venue_type' do
    stub_request(:post, 'https://api.rating.chgk.net/venue_types').
      with(body: {name: 'Фейковая'}).
      to_return(
        status: 201,
        body: '{"id":0,"name":"Фейковая"}',
        headers: {}
      )

    venue_type = test_client.create_venue_type name: 'Фейковая'
    expect(venue_type.name).to eq('Фейковая')
    expect(venue_type.id).to eq(0)
  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/venue_types_spec.rb
rating-chgk-v2-1.0.0.rc1 spec/lib/rating_chgk_v2/rest/venue_types_spec.rb