Sha256: 7632c4fc963288face6b633e908d366408abcc0edc17e12c4936cde9a263f0bf

Contents?: true

Size: 1.01 KB

Versions: 11

Compression:

Stored size: 1.01 KB

Contents

# frozen_string_literal: true

describe ErrorController, type: :controller do
  describe '#show' do
    context 'when request error code 10' do
      let(:code) { 10 }

      let(:expected_response) do
        {
          error: {
            code: code,
            message: 'You requested error code: 10',
          },
        }.to_json
      end

      it 'returns 400 Bad request with error code 10' do
        get '/error/:code', code: code
        expect(response.status).to eq 400
        expect(response.body).to eq expected_response
      end
    end

    context 'when request error code 20' do
      let(:code) { 20 }

      let(:expected_response) do
        {
          error: {
            code: code,
            message: 'You requested error code: 20',
          },
        }.to_json
      end

      it 'returns 400 Bad request with error code 20' do
        get '/error/:code', code: code
        expect(response.status).to eq 400
        expect(response.body).to eq expected_response
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
my_api_client-0.23.0 my_api/spec/controllers/error_controller_spec.rb
my_api_client-0.22.0 my_api/spec/controllers/error_controller_spec.rb
my_api_client-0.21.0 my_api/spec/controllers/error_controller_spec.rb
my_api_client-0.20.0 my_api/spec/controllers/error_controller_spec.rb
my_api_client-0.19.0 my_api/spec/controllers/error_controller_spec.rb
my_api_client-0.18.0 my_api/spec/controllers/error_controller_spec.rb
my_api_client-0.17.0 my_api/spec/controllers/error_controller_spec.rb
my_api_client-0.16.1 my_api/spec/controllers/error_controller_spec.rb
my_api_client-0.16.0 my_api/spec/controllers/error_controller_spec.rb
my_api_client-0.15.0 my_api/spec/controllers/error_controller_spec.rb
my_api_client-0.14.0 my_api/spec/controllers/error_controller_spec.rb