Sha256: bb34323ecc1baa4b93c53027f167cf218f9c608a7104770fcd21e040caaa1303

Contents?: true

Size: 1.98 KB

Versions: 1

Compression:

Stored size: 1.98 KB

Contents

require 'spec_helper'

describe AllscriptsUnityClient do
  subject { described_class }

  describe '#create' do
    context 'when given mode: :json' do
      it 'returns a client with client_type :json' do
        parameters = build(:allscripts_unity_client_parameters, mode: :json)
        expect(subject.create(parameters).client_type).to be(:json)
      end
    end

    context 'when not given :mode' do
      it 'returns a client with client_type :json' do
        parameters = build(:allscripts_unity_client_parameters)
        parameters[:mode] = nil
        expect(subject.create(parameters).client_type).to be(:json)
      end
    end

    context 'when given an invalid :mode' do
      it 'raises an argument error' do
        parameters = build(:allscripts_unity_client_parameters)
        parameters[:mode] = :cheese
        expect { subject.create(parameters) }.to raise_error(ArgumentError, ':mode must be :json')
      end
    end
  end

  describe '#save_task' do
    it 'raises when each of transaction_id, delegate_id, and comment are nil' do
      parameters = build(:allscripts_unity_client_parameters, mode: :json)

      client = subject.create(parameters)

      expect do
        client.save_task(:user_id, :patient_id)
      end.to raise_error(ArgumentError)
    end
  end

  describe '#save_task_status' do
    it 'raises when each of transaction_id, delegate_id, and comment are nil' do
      parameters = build(:allscripts_unity_client_parameters, mode: :json)
      client = subject.create(parameters)

      expect do
        client.save_task_status(:user_id, :patient_id)
      end.to raise_error(ArgumentError)
    end

    it 'maintains a nil parameter6 whenever taskchanges is nil' do
      parameters = build(:allscripts_unity_client_parameters, mode: :json)
      client = subject.create(parameters)

      def client.magic(params)
        params
      end

      result = client.save_task_status(1, 1, :status, 1, :comment, nil, 1)

      expect(result[:parameter6]).to eq("")
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
allscripts_unity_client-4.0.1 spec/allscripts_unity_client_spec.rb