require 'rails_helper' RSpec.describe 'Basics', type: :request do describe 'request handling' do it 'does json requests' do # 404 get '/not_existing_url', as: :json expect(response).to have_http_status(:not_found) expect(json_response).to be_a_kind_of(Hash) expect(json_response['error']).to eq('No route matches [GET] /not_existing_url') # 401 get '/api/v1/organizations', as: :json expect(response).to have_http_status(:unauthorized) expect(json_response).to be_a_kind_of(Hash) expect(json_response['error']).to eq('authentication failed') # 422 get '/tests/unprocessable_entity', as: :json expect(response).to have_http_status(:unprocessable_entity) expect(json_response).to be_a_kind_of(Hash) expect(json_response['error']).to eq('some error message') # 401 get '/tests/not_authorized', as: :json expect(response).to have_http_status(:unauthorized) expect(json_response).to be_a_kind_of(Hash) expect(json_response['error']).to eq('some error message') # 401 get '/tests/ar_not_found', as: :json expect(response).to have_http_status(:not_found) expect(json_response).to be_a_kind_of(Hash) expect(json_response['error']).to eq('some error message') # 500 get '/tests/standard_error', as: :json expect(response).to have_http_status(:internal_server_error) expect(json_response).to be_a_kind_of(Hash) expect(json_response['error']).to eq('some error message') # 422 get '/tests/argument_error', as: :json expect(response).to have_http_status(:unprocessable_entity) expect(json_response).to be_a_kind_of(Hash) expect(json_response['error']).to eq('some error message') end it 'does html requests' do # 404 get '/not_existing_url' expect(response).to have_http_status(:not_found) expect(response.body).to match(/404: Not Found}) expect(response.body).to match(%r{