Sha256: f7b3751e44a6127cdf6bb2f20850d18febf9e291773c561e496c7d5f16a463d6

Contents?: true

Size: 992 Bytes

Versions: 17

Compression:

Stored size: 992 Bytes

Contents

# frozen_string_literal: true
RSpec.describe FinApps::Middleware::RaiseError do
  let(:fake_app) { proc {|env| env } }
  Env = Struct.new(:status, :response_headers, :body)

  describe '#on_complete' do
    subject { FinApps::Middleware::RaiseError.new(fake_app) }

    context 'for succesful requests' do
      let(:env) { Env.new(200) }
      it { expect { subject.on_complete(env) }.not_to raise_error }
    end
    context 'for client errors' do
      let(:env) { Env.new(401, {}, '{"messages":["Invalid User Identifier or Credentials"]}') }
      error_message = 'the server responded with status 401'
      it { expect { subject.on_complete(env) }.to raise_error(Faraday::Error::ClientError, error_message) }
    end
    context 'for connection failed error' do
      let(:env) { Env.new(407) }
      error_message = '407 "Proxy Authentication Required"'
      it { expect { subject.on_complete(env) }.to raise_error(Faraday::Error::ConnectionFailed, error_message) }
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
finapps-2.1.4 spec/middleware/response/raise_error_spec.rb
finapps-2.1.3 spec/middleware/response/raise_error_spec.rb
finapps-2.1.2 spec/middleware/response/raise_error_spec.rb
finapps-2.1.1 spec/middleware/response/raise_error_spec.rb
finapps-2.0.30 spec/middleware/response/raise_error_spec.rb
finapps-2.0.29 spec/middleware/response/raise_error_spec.rb
finapps-2.0.28 spec/middleware/response/raise_error_spec.rb
finapps-2.0.27 spec/middleware/response/raise_error_spec.rb
finapps-2.0.26 spec/middleware/response/raise_error_spec.rb
finapps-2.0.25 spec/middleware/response/raise_error_spec.rb
finapps-2.0.24 spec/middleware/response/raise_error_spec.rb
finapps-2.0.23 spec/middleware/response/raise_error_spec.rb
finapps-2.0.22 spec/middleware/response/raise_error_spec.rb
finapps-2.0.21 spec/middleware/response/raise_error_spec.rb
finapps-2.0.20 spec/middleware/response/raise_error_spec.rb
finapps-2.0.19 spec/middleware/response/raise_error_spec.rb
finapps-2.0.17 spec/middleware/response/raise_error_spec.rb