allscripts_unity_client 4.0.0 → 5.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/lib/allscripts_unity_client.rb +4 -0
- data/lib/allscripts_unity_client/client.rb +11 -4
- data/lib/allscripts_unity_client/client_driver.rb +15 -5
- data/lib/allscripts_unity_client/client_options.rb +13 -4
- data/lib/allscripts_unity_client/json_client_driver.rb +37 -3
- data/lib/allscripts_unity_client/unity_request.rb +9 -2
- data/lib/allscripts_unity_client/version.rb +1 -1
- metadata +20 -59
- data/.gitignore +0 -21
- data/.rspec +0 -2
- data/.rubocop.yml +0 -340
- data/.travis.yml +0 -11
- data/Gemfile +0 -2
- data/LICENSE +0 -22
- data/README.md +0 -347
- data/Rakefile +0 -7
- data/allscripts_unity_client.gemspec +0 -40
- data/spec/allscripts_unity_client_spec.rb +0 -30
- data/spec/client_driver_spec.rb +0 -23
- data/spec/client_options_spec.rb +0 -185
- data/spec/client_spec.rb +0 -471
- data/spec/factories/allscripts_unity_client_parameters_factory.rb +0 -18
- data/spec/factories/client_driver_factory.rb +0 -20
- data/spec/factories/client_factory.rb +0 -9
- data/spec/factories/client_options.rb +0 -18
- data/spec/factories/magic_request_factory.rb +0 -37
- data/spec/factories/unity_request_factory.rb +0 -13
- data/spec/factories/unity_response_factory.rb +0 -12
- data/spec/fixtures/attributes_hash.yml +0 -15
- data/spec/fixtures/date_hash.yml +0 -8
- data/spec/fixtures/date_string_hash.yml +0 -8
- data/spec/fixtures/error.json +0 -3
- data/spec/fixtures/get_providers.json +0 -69
- data/spec/fixtures/get_providers.xml +0 -119
- data/spec/fixtures/get_providers_json.yml +0 -65
- data/spec/fixtures/get_providers_xml.yml +0 -270
- data/spec/fixtures/get_security_token.json +0 -1
- data/spec/fixtures/get_security_token.xml +0 -7
- data/spec/fixtures/get_server_info.json +0 -10
- data/spec/fixtures/get_server_info.xml +0 -40
- data/spec/fixtures/get_server_info_json.yml +0 -8
- data/spec/fixtures/get_server_info_xml.yml +0 -55
- data/spec/fixtures/no_attributes_hash.yml +0 -7
- data/spec/fixtures/retire_security_token.json +0 -1
- data/spec/fixtures/retire_security_token.xml +0 -5
- data/spec/fixtures/soap_fault.xml +0 -13
- data/spec/fixtures/string_keyed_hash.yml +0 -8
- data/spec/fixtures/symbol_keyed_hash.yml +0 -8
- data/spec/json_client_driver_spec.rb +0 -152
- data/spec/json_unity_request_spec.rb +0 -37
- data/spec/json_unity_response_spec.rb +0 -44
- data/spec/spec_helper.rb +0 -85
- data/spec/support/factory_bot.rb +0 -10
- data/spec/support/fixture_loader.rb +0 -20
- data/spec/support/shared_examples_for_client_driver.rb +0 -118
- data/spec/support/shared_examples_for_unity_request.rb +0 -114
- data/spec/support/shared_examples_for_unity_response.rb +0 -26
- data/spec/unity_request_spec.rb +0 -37
- data/spec/unity_response_spec.rb +0 -36
- data/spec/utilities_spec.rb +0 -144
data/spec/support/factory_bot.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
require 'yaml'
|
2
|
-
require 'json'
|
3
|
-
|
4
|
-
class FixtureLoader
|
5
|
-
def self.load_yaml(filename)
|
6
|
-
YAML.load(read(filename))
|
7
|
-
end
|
8
|
-
|
9
|
-
def self.load_json(filename)
|
10
|
-
JSON.parse(read(filename))
|
11
|
-
end
|
12
|
-
|
13
|
-
def self.load_file(filename)
|
14
|
-
read(filename)
|
15
|
-
end
|
16
|
-
|
17
|
-
def self.read(filename)
|
18
|
-
File.read(File.expand_path("../../fixtures/#{filename}", __FILE__))
|
19
|
-
end
|
20
|
-
end
|
@@ -1,118 +0,0 @@
|
|
1
|
-
shared_examples 'a client driver' do
|
2
|
-
describe '#security_token?' do
|
3
|
-
context 'when @security_token is nil' do
|
4
|
-
it do
|
5
|
-
subject.security_token = nil
|
6
|
-
expect(subject.security_token?).to be_falsey
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
context 'when @security_token is not nil' do
|
11
|
-
it do
|
12
|
-
subject.security_token = 'security token'
|
13
|
-
expect(subject.security_token?).to be_truthy
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
describe '#log_get_security_token' do
|
19
|
-
it 'should call log_info' do
|
20
|
-
allow(subject).to receive(:log_info)
|
21
|
-
subject.send(:log_get_security_token)
|
22
|
-
expect(subject).to have_received(:log_info)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
describe '#log_retire_security_token' do
|
27
|
-
it 'should call log_info' do
|
28
|
-
allow(subject).to receive(:log_info)
|
29
|
-
subject.send(:log_retire_security_token)
|
30
|
-
expect(subject).to have_received(:log_info)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
describe '#log_magic' do
|
35
|
-
it 'should call log_info' do
|
36
|
-
allow(subject).to receive(:log_info)
|
37
|
-
subject.send(:log_magic, double(parameters: { action: 'action'}))
|
38
|
-
expect(subject).to have_received(:log_info)
|
39
|
-
end
|
40
|
-
|
41
|
-
context 'when given nil for request' do
|
42
|
-
it { expect { subject.send(:log_magic, nil) }.to raise_error(ArgumentError) }
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
describe '#log_info' do
|
47
|
-
context 'when @options.logger? is true' do
|
48
|
-
it 'should call @options.logger.info' do
|
49
|
-
subject.options.logger = double('logger', info: true)
|
50
|
-
subject.send(:log_info, 'test')
|
51
|
-
expect(subject.options.logger).to have_received(:info)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
context 'when @options.logger? is false' do
|
56
|
-
it 'should not call @options.logger.info' do
|
57
|
-
allow_message_expectations_on_nil
|
58
|
-
subject.options.logger = nil
|
59
|
-
allow(subject.options.logger).to receive(:info)
|
60
|
-
subject.send(:log_info, 'test')
|
61
|
-
expect(subject.options.logger).not_to have_received(:info)
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
context 'when given nil for message' do
|
66
|
-
it 'should not call @options.logger.info' do
|
67
|
-
subject.options.logger = double('logger', info: true)
|
68
|
-
subject.send(:log_info, nil)
|
69
|
-
expect(subject.options.logger).not_to have_received(:info)
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
context 'when @options.logger? is false' do
|
74
|
-
it 'should not call @logger.info' do
|
75
|
-
expect { subject.send(:log_info, 'test') }.not_to raise_error
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
context 'when @timer is nil and @options.logger is true' do
|
80
|
-
it 'should not include seconds in the log' do
|
81
|
-
subject.options.logger = double('logger', info: true)
|
82
|
-
subject.instance_variable_set('@timer', nil)
|
83
|
-
subject.send(:log_info, 'test')
|
84
|
-
expect(subject.options.logger).not_to have_received(:info).with(match(/seconds/))
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
context 'when @timer is not nil and @options.logger? is true' do
|
89
|
-
it 'should include seconds in log' do
|
90
|
-
subject.options.logger = double('logger', info: true)
|
91
|
-
subject.instance_variable_set('@timer', 1.2)
|
92
|
-
subject.send(:log_info, 'test')
|
93
|
-
expect(subject.options.logger).to have_received(:info).with(match(/seconds/))
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
describe '#start_timer' do
|
99
|
-
it 'sets @start_time' do
|
100
|
-
subject.send(:start_timer)
|
101
|
-
expect(subject.instance_variable_get('@start_time')).not_to be_nil
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
describe '#end_timer' do
|
106
|
-
it 'sets @end_time' do
|
107
|
-
subject.send(:start_timer)
|
108
|
-
subject.send(:end_timer)
|
109
|
-
expect(subject.instance_variable_get('@end_time')).not_to be_nil
|
110
|
-
end
|
111
|
-
|
112
|
-
it 'sets @timer to @end_time - @start_time' do
|
113
|
-
subject.send(:start_timer)
|
114
|
-
subject.send(:end_timer)
|
115
|
-
expect(subject.instance_variable_get('@timer')).to eq(subject.instance_variable_get('@end_time') - subject.instance_variable_get('@start_time'))
|
116
|
-
end
|
117
|
-
end
|
118
|
-
end
|
@@ -1,114 +0,0 @@
|
|
1
|
-
shared_examples 'a unity request' do
|
2
|
-
let(:magic_request) { build(:magic_request) }
|
3
|
-
|
4
|
-
describe '#to_hash' do
|
5
|
-
it ':action maps to Action' do
|
6
|
-
subject.parameters = build(:magic_request, action: 'Action')
|
7
|
-
expect(subject.to_hash['Action']).to eq('Action')
|
8
|
-
end
|
9
|
-
|
10
|
-
it ':appname maps to Appname' do
|
11
|
-
subject.parameters = build(:magic_request, appname: 'Appname')
|
12
|
-
expect(subject.to_hash['Appname']).to eq('Appname')
|
13
|
-
end
|
14
|
-
|
15
|
-
it ':patientid maps to PatientID' do
|
16
|
-
subject.parameters = build(:magic_request, patientid: 'PatientID')
|
17
|
-
expect(subject.to_hash['PatientID']).to eq('PatientID')
|
18
|
-
end
|
19
|
-
|
20
|
-
it ':token maps to Token' do
|
21
|
-
subject.parameters = build(:magic_request, token: 'Token')
|
22
|
-
expect(subject.to_hash['Token']).to eq('Token')
|
23
|
-
end
|
24
|
-
|
25
|
-
it ':parameter1 maps to Parameter1' do
|
26
|
-
subject.parameters = build(:magic_request, parameter1: 'Parameter1')
|
27
|
-
expect(subject.to_hash['Parameter1']).to eq('Parameter1')
|
28
|
-
end
|
29
|
-
|
30
|
-
it ':parameter2 maps to Parameter2' do
|
31
|
-
subject.parameters = build(:magic_request, parameter2: 'Parameter2')
|
32
|
-
expect(subject.to_hash['Parameter2']).to eq('Parameter2')
|
33
|
-
end
|
34
|
-
|
35
|
-
it ':parameter3 maps to Parameter3' do
|
36
|
-
subject.parameters = build(:magic_request, parameter3: 'Parameter3')
|
37
|
-
expect(subject.to_hash['Parameter3']).to eq('Parameter3')
|
38
|
-
end
|
39
|
-
|
40
|
-
it ':parameter4 maps to Parameter4' do
|
41
|
-
subject.parameters = build(:magic_request, parameter4: 'Parameter4')
|
42
|
-
expect(subject.to_hash['Parameter4']).to eq('Parameter4')
|
43
|
-
end
|
44
|
-
|
45
|
-
it ':parameter5 maps to Parameter5' do
|
46
|
-
subject.parameters = build(:magic_request, parameter5: 'Parameter5')
|
47
|
-
expect(subject.to_hash['Parameter5']).to eq('Parameter5')
|
48
|
-
end
|
49
|
-
|
50
|
-
it ':parameter6 maps to Parameter6' do
|
51
|
-
subject.parameters = build(:magic_request, parameter6: 'Parameter6')
|
52
|
-
expect(subject.to_hash['Parameter6']).to eq('Parameter6')
|
53
|
-
end
|
54
|
-
|
55
|
-
it 'calls process_date on parameters' do
|
56
|
-
subject.parameters = build(:populated_magic_request)
|
57
|
-
allow(subject).to receive(:process_date)
|
58
|
-
subject.to_hash
|
59
|
-
expect(subject).to have_received(:process_date).exactly(6).times
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
describe '#process_date' do
|
64
|
-
context 'when given nil' do
|
65
|
-
it { expect(subject.send(:process_date, nil)).to be_nil }
|
66
|
-
end
|
67
|
-
|
68
|
-
context 'when given a non-date string' do
|
69
|
-
it do
|
70
|
-
not_a_date = Faker::Name.name
|
71
|
-
expect(subject.send(:process_date, not_a_date)).to eq(not_a_date)
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
context 'when given a date string' do
|
76
|
-
it 'returns an ISO8601 string' do
|
77
|
-
date = '10/24/2013'
|
78
|
-
expect(subject.send(:process_date, date)).to eq('2013-10-24')
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
context 'when given a UTC date time string' do
|
83
|
-
it 'returns an ISO8601 string' do
|
84
|
-
now = DateTime.now.utc
|
85
|
-
now_iso8601 = now.strftime('%Y-%m-%dT%H:%M:%S%:z')
|
86
|
-
expect(subject.send(:process_date, now_iso8601)).to eq(now_iso8601)
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
context 'when given a Date' do
|
91
|
-
it 'returns an ISO8601 string' do
|
92
|
-
today = Date.today
|
93
|
-
today_iso8601 = Date.today.iso8601
|
94
|
-
expect(subject.send(:process_date, today)).to eq(today_iso8601)
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
context 'when given a UTC Time' do
|
99
|
-
it 'returns an ISO8601 string' do
|
100
|
-
now = Time.now.utc
|
101
|
-
now_iso8601 = now.strftime('%Y-%m-%dT%H:%M:%S%:z')
|
102
|
-
expect(subject.send(:process_date, now)).to eq(now_iso8601)
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
context 'when given a UTC DateTime' do
|
107
|
-
it 'returns an ISO8601 string' do
|
108
|
-
now = DateTime.now.utc
|
109
|
-
now_iso8601 = now.strftime('%Y-%m-%dT%H:%M:%S%:z')
|
110
|
-
expect(subject.send(:process_date, now)).to eq(now_iso8601)
|
111
|
-
end
|
112
|
-
end
|
113
|
-
end
|
114
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
shared_examples 'a unity response' do
|
2
|
-
let(:attributes_hash) { FixtureLoader.load_yaml('attributes_hash.yml') }
|
3
|
-
let(:no_attributes_hash) { FixtureLoader.load_yaml('no_attributes_hash.yml') }
|
4
|
-
let(:date_string_hash) { FixtureLoader.load_yaml('date_string_hash.yml') }
|
5
|
-
let(:date_hash) { FixtureLoader.load_yaml('date_hash.yml') }
|
6
|
-
|
7
|
-
describe '#strip_attributes' do
|
8
|
-
context 'when given nil' do
|
9
|
-
it { expect(subject.send(:strip_attributes, nil)).to be_nil }
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'recursively strips attribute keys off hashes' do
|
13
|
-
expect(subject.send(:strip_attributes, attributes_hash)).to eq(no_attributes_hash)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
describe '#convert_dates_to_utc' do
|
18
|
-
context 'when given nil' do
|
19
|
-
it { expect(subject.send(:convert_dates_to_utc, nil)).to be_nil }
|
20
|
-
end
|
21
|
-
|
22
|
-
it 'recursively converts date strings' do
|
23
|
-
expect(subject.send(:convert_dates_to_utc, date_string_hash)).to eq(date_hash)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
data/spec/unity_request_spec.rb
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe AllscriptsUnityClient::UnityRequest do
|
4
|
-
it_behaves_like 'a unity request'
|
5
|
-
|
6
|
-
subject { build(:unity_request) }
|
7
|
-
|
8
|
-
describe '#initialize' do
|
9
|
-
context 'when nil is given for parameters' do
|
10
|
-
it { expect { build(:unity_request, parameters: nil) }.to raise_error(ArgumentError) }
|
11
|
-
end
|
12
|
-
|
13
|
-
context 'when nil is given for timezone' do
|
14
|
-
it { expect { build(:unity_request, timezone: nil) }.to raise_error(ArgumentError) }
|
15
|
-
end
|
16
|
-
|
17
|
-
context 'when nil is given for appname' do
|
18
|
-
it { expect { build(:unity_request, appname: nil) }.to raise_error(ArgumentError) }
|
19
|
-
end
|
20
|
-
|
21
|
-
context 'when nil is given for security_token' do
|
22
|
-
it { expect { build(:unity_request, security_token: nil) }.to raise_error(ArgumentError) }
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
describe '#to_hash' do
|
27
|
-
it ':userid maps to UserID' do
|
28
|
-
subject.parameters = build(:magic_request, userid: 'UserID')
|
29
|
-
expect(subject.to_hash['UserID']).to eq('UserID')
|
30
|
-
end
|
31
|
-
|
32
|
-
it ':data maps to Base64 encoded data' do
|
33
|
-
subject.parameters = build(:magic_request, data: 'data')
|
34
|
-
expect(subject.to_hash['data']).to eq(['data'].pack('m'))
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
data/spec/unity_response_spec.rb
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe AllscriptsUnityClient::UnityResponse do
|
4
|
-
it_behaves_like 'a unity response'
|
5
|
-
|
6
|
-
subject { build(:unity_response, response: get_server_info) }
|
7
|
-
|
8
|
-
let(:get_server_info) { FixtureLoader.load_yaml('get_server_info_xml.yml') }
|
9
|
-
|
10
|
-
describe '#initialize' do
|
11
|
-
context 'when nil is given for response' do
|
12
|
-
it { expect { build(:unity_response, response: nil) }.to raise_error(ArgumentError) }
|
13
|
-
end
|
14
|
-
|
15
|
-
context 'when nil is given for timezone' do
|
16
|
-
it { expect { build(:unity_response, timezone: nil) }.to raise_error(ArgumentError) }
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
describe '#to_hash' do
|
21
|
-
context 'when given a GetServerInfo SOAP response hash' do
|
22
|
-
it 'strips Unity SOAP wrappers' do
|
23
|
-
expect(subject.to_hash[:server_time_zone]).to_not be_nil
|
24
|
-
end
|
25
|
-
|
26
|
-
context 'when given nil magic_result' do
|
27
|
-
it 'returns []' do
|
28
|
-
magic_response = get_server_info
|
29
|
-
magic_response[:magic_response][:magic_result][:diffgram] = nil
|
30
|
-
subject.response = magic_response
|
31
|
-
expect(subject.to_hash).to eq([])
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
data/spec/utilities_spec.rb
DELETED
@@ -1,144 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe AllscriptsUnityClient::Utilities do
|
4
|
-
subject { described_class }
|
5
|
-
|
6
|
-
let(:date_string) { '2013-02-15' }
|
7
|
-
let(:date) { Date.parse(date_string) }
|
8
|
-
let(:datetime_string) { '2013-02-15T00:00:00Z' }
|
9
|
-
let(:datetime) { timezone.parse(datetime_string) }
|
10
|
-
let(:timezone) { ActiveSupport::TimeZone['Etc/UTC'] }
|
11
|
-
|
12
|
-
let(:string) { 'string' }
|
13
|
-
let(:string_array) { ['string'] }
|
14
|
-
let(:base64_string) { "c3RyaW5n\n" }
|
15
|
-
|
16
|
-
let(:string_keyed_hash) { FixtureLoader.load_yaml('string_keyed_hash.yml') }
|
17
|
-
let(:symbol_keyed_hash) { FixtureLoader.load_yaml('symbol_keyed_hash.yml') }
|
18
|
-
|
19
|
-
let(:datetime_string_one) { 'Feb 27 2013 12:37PM' }
|
20
|
-
let(:datetime_string_two) { 'Feb 28 2013 1:34PM' }
|
21
|
-
let(:datetime_string_three) { '12/25/2013 12:37 PM' }
|
22
|
-
let(:datetime_string_four) { 'Nov 1 2011 11:31AM' }
|
23
|
-
let(:datetime_one) { timezone.parse(datetime_string_one) }
|
24
|
-
let(:datetime_two) { timezone.parse(datetime_string_two) }
|
25
|
-
let(:datetime_three) { timezone.parse(datetime_string_three) }
|
26
|
-
let(:datetime_four) { timezone.parse(datetime_string_four) }
|
27
|
-
let(:date_string_one) { '20-Jul-2014' }
|
28
|
-
let(:date_string_two) { '12/25/2013' }
|
29
|
-
let(:date_string_three) { 'Nov 1 2011' }
|
30
|
-
let(:date_one) { Date.parse(date_string_one) }
|
31
|
-
let(:date_two) { Date.parse(date_string_two) }
|
32
|
-
let(:date_three) { Date.parse(date_string_three) }
|
33
|
-
|
34
|
-
let(:invalid_date_string_one) { "32-13-2014\n02/21/2014"}
|
35
|
-
|
36
|
-
describe '.try_to_encode_as_date' do
|
37
|
-
context 'when given nil' do
|
38
|
-
it { expect(subject.try_to_encode_as_date(timezone, nil)).to be_nil }
|
39
|
-
end
|
40
|
-
|
41
|
-
context 'when given date string' do
|
42
|
-
it 'returns the string as a Date' do
|
43
|
-
expect(subject.try_to_encode_as_date(timezone, date_string)).to eq(date)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
context 'when given date time string' do
|
48
|
-
it 'returns the string as a DateTime' do
|
49
|
-
expect(subject.try_to_encode_as_date(timezone, datetime_string)).to eq(datetime)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
context 'when given datetime_string_one' do
|
54
|
-
it 'returns the string as a DateTime' do
|
55
|
-
expect(subject.try_to_encode_as_date(timezone, datetime_string_one)).to eq(datetime_one)
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
context 'when given datetime_string_two' do
|
60
|
-
it 'returns the string as a DateTime' do
|
61
|
-
expect(subject.try_to_encode_as_date(timezone, datetime_string_two)).to eq(datetime_two)
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
context 'when given datetime_string_three' do
|
66
|
-
it 'returns the string as a DateTime' do
|
67
|
-
expect(subject.try_to_encode_as_date(timezone, datetime_string_three)).to eq(datetime_three)
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
context 'when given datetime_string_four' do
|
72
|
-
it 'returns the string as a DateTime' do
|
73
|
-
expect(subject.try_to_encode_as_date(timezone, datetime_string_four)).to eq(datetime_four)
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
context 'when given date_string_one' do
|
78
|
-
it 'returns the string as a Date' do
|
79
|
-
expect(subject.try_to_encode_as_date(timezone, date_string_one)).to eq(date_one)
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
context 'when given date_string_two' do
|
84
|
-
it 'returns the string as a Date' do
|
85
|
-
expect(subject.try_to_encode_as_date(timezone, date_string_two)).to eq(date_two)
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
context 'when given date_string_three' do
|
90
|
-
it 'returns the string as a Date' do
|
91
|
-
expect(subject.try_to_encode_as_date(timezone, date_string_three)).to eq(date_three)
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
context 'when given a non-date string' do
|
96
|
-
it 'returns that string' do
|
97
|
-
expect(subject.try_to_encode_as_date(timezone, string)).to eq(string)
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
context 'when given an invalid date string' do
|
102
|
-
it 'returns that string' do
|
103
|
-
expect(subject.try_to_encode_as_date(timezone, invalid_date_string_one)).to eq(invalid_date_string_one)
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
context 'when givn an valid date string that represents an invalid date' do
|
108
|
-
it 'it returns the string' do
|
109
|
-
date = "10/00/1999"
|
110
|
-
date_time = "10/00/1999 01:01:01"
|
111
|
-
expect(subject.try_to_encode_as_date(timezone, date)).to be(date)
|
112
|
-
expect(subject.try_to_encode_as_date(timezone, date_time)).to be(date_time)
|
113
|
-
end
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
describe '.encode_data' do
|
118
|
-
context 'when given nil' do
|
119
|
-
it { expect(subject.encode_data(nil)).to be_nil }
|
120
|
-
end
|
121
|
-
|
122
|
-
context 'when given a string' do
|
123
|
-
it 'returns a base64 encoded version of that string' do
|
124
|
-
expect(subject.encode_data(string)).to eq(base64_string)
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
128
|
-
context 'when given an array of strings' do
|
129
|
-
it 'returns a base64 encoded version of that string' do
|
130
|
-
expect(subject.encode_data(string_array)).to eq(base64_string)
|
131
|
-
end
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
describe '.recursively_symbolize_keys' do
|
136
|
-
context 'when given nil' do
|
137
|
-
it { expect(subject.recursively_symbolize_keys(nil)).to be_nil }
|
138
|
-
end
|
139
|
-
|
140
|
-
context 'when given a hash with string keys' do
|
141
|
-
it { expect(subject.recursively_symbolize_keys(string_keyed_hash)).to eq(symbol_keyed_hash) }
|
142
|
-
end
|
143
|
-
end
|
144
|
-
end
|