Sha256: d2fcf04ff4486d219806fe084232f7a78894bec67447fcb5ca443f1236aef0d0

Contents?: true

Size: 1.12 KB

Versions: 6

Compression:

Stored size: 1.12 KB

Contents

require 'spec_helper'

describe 'UnityRequest' do
  it_behaves_like 'a unity request'

  subject { build(:unity_request) }

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

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

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

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

  describe '#to_hash' do
    it ':userid maps to UserID' do
      subject.parameters = build(:magic_request, userid: 'UserID')
      expect(subject.to_hash['UserID']).to eq('UserID')
    end

    it ':data maps to Base64 encoded data' do
      subject.parameters = build(:magic_request, data: 'data')
      expect(subject.to_hash['data']).to eq(['data'].pack('m'))
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
allscripts_unity_client-2.0.5 spec/unity_request_spec.rb
allscripts_unity_client-2.0.4 spec/unity_request_spec.rb
allscripts_unity_client-2.0.3 spec/unity_request_spec.rb
allscripts_unity_client-2.0.2 spec/unity_request_spec.rb
allscripts_unity_client-2.0.1 spec/unity_request_spec.rb
allscripts_unity_client-2.0.0 spec/unity_request_spec.rb