Sha256: 4b9fd446b1a57aee0be76e32535cdabcfced623ae5efee311a5e3d01d7b9d605

Contents?: true

Size: 1.54 KB

Versions: 6

Compression:

Stored size: 1.54 KB

Contents

RSpec.describe Commons::Errors::InternalServerError, type: :serializer do
  let(:title) { Faker::Name.name }
  let(:message) { Faker::Name.name }
  let(:detail) { Faker::Name.name }
  let(:meta) { { data: Faker::Name.name } }
  let(:error) { described_class.new }
  subject do
    serializer = Commons::Errors::ErrorSerializer.new(error)
    serializer.serializable_hash
  end

  describe 'serialize the model' do
    context 'should validate required attributes' do
      it do
        serialized = subject
        expect(serialized.keys).to include :status
        expect(serialized.keys).to include :code
        expect(serialized.keys).to include :title
        expect(serialized.keys).to include :detail
      end
    end

    context 'should work with default values' do
      it do
        serialized = subject
        expect(serialized[:status]).to eq error.status
        expect(serialized[:code]).to eq error.code
        expect(serialized[:title]).to eq error.title
        expect(serialized[:detail]).to eq error.detail
        expect(serialized[:meta]).to eq error.meta
      end
    end

    context 'should work with custom values' do
      let(:error) { described_class.new(message, title: title, detail: detail, meta: meta) }
      it do
        serialized = subject
        expect(serialized[:status]).to eq error.status
        expect(serialized[:title]).to eq title
        expect(serialized[:detail]).to eq detail
        expect(serialized[:meta][:message]).to eq message
        expect(serialized[:meta][:data]).to eq meta[:data]
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
commons_yellowme-0.16.0 spec/commons/serializers/internal_server_error_spec.rb
commons_yellowme-0.15.0 spec/commons/serializers/internal_server_error_spec.rb
commons_yellowme-0.12.0 spec/commons/serializers/internal_server_error_spec.rb
commons_yellowme-0.11.3 spec/commons/serializers/internal_server_error_spec.rb
commons_yellowme-0.11.2 spec/commons/serializers/internal_server_error_spec.rb
commons_yellowme-0.11.1 spec/commons/serializers/internal_server_error_spec.rb