Sha256: cc01b182d212224add21731ef2e6aec4634a9ed228f538a34f572b16fba20cc4
Contents?: true
Size: 1.33 KB
Versions: 2
Compression:
Stored size: 1.33 KB
Contents
require 'spec_helper' describe AllscriptsUnityClient::JSONUnityResponse do it_behaves_like 'a unity response' subject { build(:json_unity_response, response: get_server_info) } let(:get_server_info) { FixtureLoader.load_yaml('get_server_info_json.yml') } let(:get_providers) { FixtureLoader.load_yaml('get_providers_json.yml') } describe '#initialize' do context 'when nil is given for response' do it { expect { build(:json_unity_response, response: nil) }.to raise_error(ArgumentError) } end context 'when nil is given for timezone' do it { expect { build(:json_unity_response, timezone: nil) }.to raise_error(ArgumentError) } end end describe '#to_hash' do context 'when given a GetServerInfo JSON response hash' do it 'strips Unity JSON wrappers' do expect(subject.to_hash[:server_time_zone]).to_not be_nil end end context 'when given empty response' do it 'returns []' do magic_response = get_providers magic_response[0]['getprovidersinfo'] = [] subject.response = magic_response expect(subject.to_hash).to eq([]) end end context 'when given a multiple item response' do it 'returns an array' do subject.response = get_providers expect(subject.to_hash).to be_instance_of(Array) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
allscripts_unity_client-4.0.1 | spec/json_unity_response_spec.rb |
allscripts_unity_client-4.0.0 | spec/json_unity_response_spec.rb |