Sha256: de7768acdcd6b5f34b8766002345961dd8e65a7642a97b4cb250fa7db5673e88

Contents?: true

Size: 1.61 KB

Versions: 1

Compression:

Stored size: 1.61 KB

Contents

# frozen_string_literal: true

require 'spec_helper'
require 'shared_examples_for_endpoints'
module Fizzy
  module Api
    module Endpoints
      describe RenderOverview do
        let(:dossier_id) { '123' }
        let(:protocol_subscription_id) { 'abc' }
        let(:response) { httparty_response('{}') }
        let(:session)  { FactoryBot.build :basic_auth_session }

        it_behaves_like 'an endpoint'

        before do
          allow(Sessions::BasicAuthSession).to receive(:new).and_return session
        end

        it 'should call the correct url' do
          expect(session).to receive(:get)
            .with("/dossier/#{dossier_id}/protocol_subscriptions/#{protocol_subscription_id}/render.json")
            .and_return(response)
          outcome = described_class.run! dossier_id: dossier_id,
                                         protocol_subscription_id: protocol_subscription_id
          expect(outcome).to eq response
        end

        describe 'error handling' do
          it 'should fail a 500 with an UnexpectedStatusError' do
            allow(response).to receive(:code).and_return 500
            expect(session).to receive(:get)
              .with("/dossier/#{dossier_id}/protocol_subscriptions/#{protocol_subscription_id}/render.json")
              .and_return(response)
            outcome = lambda do
              described_class.run! dossier_id: dossier_id,
                                   protocol_subscription_id: protocol_subscription_id
            end
            expect { outcome.call }.to raise_error(Errors::UnexpectedStatusError)
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fizzy-api-0.1.5 spec/fizzy/api/endpoints/render_overview_spec.rb