Sha256: bbe7b46434df5e94ffb65b8f007ddf62673a7d39211a6f39f49f39f6d21a8c7d
Contents?: true
Size: 1.84 KB
Versions: 7
Compression:
Stored size: 1.84 KB
Contents
require 'spec_helper' module Fizzy module Api describe CalculateOutcome do let(:dossier_id) { '123' } let(:protocol_subscription_id) { 'abc' } let(:response) { httparty_response('') } let(:session) { FactoryGirl.build :basic_auth_session } before do allow(Sessions::BasicAuthSession).to receive(:new).and_return session allow(session).to receive(:post).and_return nil end it 'should call the correct url' do expect(session).to receive(:post) .with("/dossier/#{dossier_id}/protocol_subscriptions/#{protocol_subscription_id}/calculate") .and_return(response) described_class.run! dossier_id: dossier_id, protocol_subscription_id: protocol_subscription_id end describe 'error handling' do it 'should notice a 404' do allow(response).to receive(:code).and_return 404 expect(session).to receive(:post) .with('/dossier/fake/protocol_subscriptions/fake/calculate') .and_return(response) outcome = lambda do described_class.run! dossier_id: 'fake', protocol_subscription_id: 'fake' end expect { outcome.call }.to raise_error(Errors::GraphNotFoundError) end it 'should fail a 500 with an UnexpectedStatusError' do allow(response).to receive(:code).and_return 500 expect(session).to receive(:post) .with('/dossier/fake/protocol_subscriptions/fake/calculate') .and_return(response) outcome = lambda do described_class.run! dossier_id: 'fake', protocol_subscription_id: 'fake' end expect { outcome.call }.to raise_error(Errors::UnexpectedStatusError) end end end end end
Version data entries
7 entries across 7 versions & 1 rubygems