Sha256: 4fc5e5717f8952ff50f1eeea861ddc16082bd3188741de5dddb725fbcd65ea8d

Contents?: true

Size: 1.6 KB

Versions: 6

Compression:

Stored size: 1.6 KB

Contents

describe Commons::Errors::BadRequest do
  describe 'handle_error' do
    context 'works with no message or validation_errors' do
      it do
        expect do
          raise described_class
        end.to raise_error(described_class)
      end
    end

    context 'default values works ok' do
      subject { described_class.new }

      it do
        expect do
          raise subject
        end.to raise_error(described_class)
      end
      it { expect(subject.detail).to eq I18n.t('status_code.IER4003_bad_request.detail') }
    end

    context 'works with message but no validation_errors' do
      let(:message) { 'my totally non-existent message' }

      subject { described_class.new(message) }

      it do
        expect do
          raise subject
        end.to raise_error(described_class)
      end
      it { expect(subject.message).to eq message }
    end

    context 'works with message & validation_errors' do
      let(:message) { 'my totally non-existent message' }
      let(:detail) { { errors: 'my totally non-existent error' } }

      subject { described_class.new(message, nil, detail: detail) }

      it do
        expect do
          raise subject
        end.to raise_error(described_class)
      end
      it { expect(subject.detail).to eq detail }
    end

    context 'works with message & backtrace' do
      let(:message) { 'my totally non-existent message' }

      subject { described_class.new(message, [message]) }

      it do
        expect do
          raise subject
        end.to raise_error(described_class)
      end
      it { expect(subject.backtrace).to eq [message] }
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
commons_yellowme-0.16.0 spec/commons/errors/bad_request_spec.rb
commons_yellowme-0.15.0 spec/commons/errors/bad_request_spec.rb
commons_yellowme-0.12.0 spec/commons/errors/bad_request_spec.rb
commons_yellowme-0.11.3 spec/commons/errors/bad_request_spec.rb
commons_yellowme-0.11.2 spec/commons/errors/bad_request_spec.rb
commons_yellowme-0.11.1 spec/commons/errors/bad_request_spec.rb