Sha256: 0ecf95fce9fd3303c213fe571f42350b84e9f2b325e91af6029771cdceeee9c0

Contents?: true

Size: 822 Bytes

Versions: 17

Compression:

Stored size: 822 Bytes

Contents

require 'spec_helper'

describe Locomotive::Coal::Error do

  let(:status)      { nil }
  let(:body)        { {} }
  let(:response)    { instance_double('Response', status: status, body: body) }
  let(:error)       { described_class.from_response(response) }

  describe '#message' do

    subject { error.message }

    context 'error caused by a wrong answer from the server' do

      context 'invalid resource (422)' do
        let(:status) { 422 }
        let(:body) { { 'error' => 'Resource invalid', 'attributes' => { 'name' => ["can't be blank"] } } }

        it { is_expected.to eq "Resource invalid: name can't be blank" }

      end

      context 'Request Entity Too Large (413)' do

        let(:status) { 413 }

        it { is_expected.to eq "File too big for the server" }

      end

    end

  end

end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
locomotivecms_coal-1.7.0 spec/unit/error_spec.rb
locomotivecms_coal-1.6.0 spec/unit/error_spec.rb
locomotivecms_coal-1.6.0.rc2 spec/unit/error_spec.rb
locomotivecms_coal-1.6.0.rc1 spec/unit/error_spec.rb
locomotivecms_coal-1.6.0.beta1 spec/unit/error_spec.rb
locomotivecms_coal-1.5.1 spec/unit/error_spec.rb
locomotivecms_coal-1.5.0 spec/unit/error_spec.rb
locomotivecms_coal-1.4.0 spec/unit/error_spec.rb
locomotivecms_coal-1.3.0 spec/unit/error_spec.rb
locomotivecms_coal-1.3.0.rc1 spec/unit/error_spec.rb
locomotivecms_coal-1.3.0.rc spec/unit/error_spec.rb
locomotivecms_coal-1.2.0 spec/unit/error_spec.rb
locomotivecms_coal-1.1.0 spec/unit/error_spec.rb
locomotivecms_coal-1.0.0 spec/unit/error_spec.rb
locomotivecms_coal-1.0.0.rc4 spec/unit/error_spec.rb
locomotivecms_coal-1.0.0.rc3 spec/unit/error_spec.rb
locomotivecms_coal-1.0.0.rc2 spec/unit/error_spec.rb