Sha256: 657175635d6f300efeee04055d38e9703540773849896695e4c8ff585fcf9aa0

Contents?: true

Size: 1.27 KB

Versions: 15

Compression:

Stored size: 1.27 KB

Contents

require 'spec_helper'

describe Freddy::ErrorResponse do
  subject(:error) { described_class.new(input) }

  context 'with an error type' do
    let(:input) { { error: 'SomeError' } }

    describe '#response' do
      subject { error.response }

      it { is_expected.to eq(input) }
    end

    describe '#message' do
      subject(:message) { error.message }

      it 'uses error type as a message' do
        expect(message).to eq('SomeError')
      end
    end
  end

  context 'with an error type and message' do
    let(:input) { { error: 'SomeError', message: 'extra info' } }

    describe '#response' do
      subject { error.response }

      it { is_expected.to eq(input) }
    end

    describe '#message' do
      subject(:message) { error.message }

      it 'uses error type as a message' do
        expect(message).to eq('SomeError: extra info')
      end
    end
  end

  context 'without an error type' do
    let(:input) { { something: 'else' } }

    describe '#response' do
      subject { error.response }

      it { is_expected.to eq(input) }
    end

    describe '#message' do
      subject(:message) { error.message }

      it 'uses default error message as a message' do
        expect(message).to eq('Use #response to get the error response')
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
freddy-2.8.0 spec/freddy/error_response_spec.rb
freddy-2.7.0 spec/freddy/error_response_spec.rb
freddy-2.6.0 spec/freddy/error_response_spec.rb
freddy-2.5.1 spec/freddy/error_response_spec.rb
freddy-2.5.0 spec/freddy/error_response_spec.rb
freddy-2.5.0.pre.rc.1 spec/freddy/error_response_spec.rb
freddy-2.4.0 spec/freddy/error_response_spec.rb
freddy-2.3.0 spec/freddy/error_response_spec.rb
freddy-2.2.4 spec/freddy/error_response_spec.rb
freddy-2.2.3 spec/freddy/error_response_spec.rb
freddy-2.2.2 spec/freddy/error_response_spec.rb
freddy-2.2.1 spec/freddy/error_response_spec.rb
freddy-2.2.0 spec/freddy/error_response_spec.rb
freddy-2.1.0 spec/freddy/error_response_spec.rb
freddy-2.0.0 spec/freddy/error_response_spec.rb