Sha256: 95957b28f8b038604d4cea117de6e063e36578347b0f2aaebadd3a89b22ca4d4

Contents?: true

Size: 1.08 KB

Versions: 2

Compression:

Stored size: 1.08 KB

Contents

require 'spec_helper'

describe AllscriptsUnityClient::UnityResponse do
  it_behaves_like 'a unity response'

  subject { build(:unity_response, response: get_server_info) }

  let(:get_server_info) { FixtureLoader.load_yaml('get_server_info_xml.yml') }

  describe '#initialize' do
    context 'when nil is given for response' do
      it { expect { build(:unity_response, response: nil) }.to raise_error(ArgumentError) }
    end

    context 'when nil is given for timezone' do
      it { expect { build(:unity_response, timezone: nil) }.to raise_error(ArgumentError) }
    end
  end

  describe '#to_hash' do
    context 'when given a GetServerInfo SOAP response hash' do
      it 'strips Unity SOAP wrappers' do
        expect(subject.to_hash[:server_time_zone]).to_not be_nil
      end

      context 'when given nil magic_result' do
        it 'returns []' do
          magic_response = get_server_info
          magic_response[:magic_response][:magic_result][:diffgram] = nil
          subject.response = magic_response
          expect(subject.to_hash).to eq([])
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
allscripts_unity_client-4.0.1 spec/unity_response_spec.rb
allscripts_unity_client-4.0.0 spec/unity_response_spec.rb