Fix borders specs

This commit is contained in:
Eugene Burmakin
2025-08-10 12:05:34 +02:00
parent dfbe9a9821
commit da438d9c93

View File

@@ -4,12 +4,24 @@ require 'rails_helper'
RSpec.describe 'Api::V1::Countries::Borders', type: :request do
describe 'GET /index' do
it 'returns a list of countries with borders' do
get '/api/v1/countries/borders'
let(:user) { create(:user) }
expect(response).to have_http_status(:success)
expect(response.body).to include('AF')
expect(response.body).to include('ZW')
context 'when user is not authenticated' do
it 'returns http unauthorized' do
get '/api/v1/countries/borders'
expect(response).to have_http_status(:unauthorized)
end
end
context 'when user is authenticated' do
it 'returns a list of countries with borders' do
get '/api/v1/countries/borders', headers: { 'Authorization' => "Bearer #{user.api_key}" }
expect(response).to have_http_status(:success)
expect(response.body).to include('AF')
expect(response.body).to include('ZW')
end
end
end
end