allscripts_unity_client 2.0.2 → 2.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 78b65bf8597ab01389fb52af523a577324cf25af
4
- data.tar.gz: 906619caa58558d76501a941e68d9f440e7bfeee
3
+ metadata.gz: 8a8ad6c24ee13b526a4712967fdcd5297da828de
4
+ data.tar.gz: 5aa6e846c1d5236c6f81c2c9f97d1566d6f2a4fc
5
5
  SHA512:
6
- metadata.gz: 6d8287a426c5c4bed6e1aa8bb084d1d0e0e14e43c6983bbdbf92fc4eb27fca5528ff7ef02951a76289855cf9284cc2d97f8823d067f0c5dc7e9ebda1bc69cee2
7
- data.tar.gz: 32e1e7798cbaf325d5cc2abd90fe70336216cf54e4d88444f7bc2ce285d8a9d0c836ac4ca8c561718f036cebf3b8d401095e1ffbd637dff2fb801177f40e49b4
6
+ metadata.gz: 47f75cbd115e5227ead22005ff18006b869b98815c25f9868d8c59ee0189f1dfdd3ab12c360e26c1a5e5453894811cf0dccbefead528f2dab0b6e6a3da7ea888
7
+ data.tar.gz: 96a3a111d967cc60fbfbabc62314d6334b64856979382dd8c451837aba12773998e20f03eaa9ad6973eef6937bf3441727a6f085510b308a3d9e1c03dffc32cd
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2013 healthfinch, Inc
1
+ Copyright (c) 2014 healthfinch, Inc
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -317,11 +317,11 @@ The above example would output the following `Hash`:
317
317
 
318
318
  ## Additional Information
319
319
 
320
- Maintainer(s): Ash Gupta (https://github.com/incomethax), Neil Goodman (https://github.com/posco2k8)
320
+ Maintainer(s): Neil Goodman (https://github.com/posco2k8)
321
321
 
322
322
  ## License
323
323
 
324
- Copyright (c) 2013 healthfinch, Inc
324
+ Copyright (c) 2014 healthfinch, Inc
325
325
 
326
326
  MIT License
327
327
 
@@ -1,20 +1,21 @@
1
1
  module AllscriptsUnityClient
2
2
  class ClientOptions
3
- attr_accessor :proxy, :logger
4
- attr_reader :base_unity_url, :username, :password, :appname, :timezone, :ca_file, :ca_path, :timeout
3
+ attr_accessor :proxy, :logger, :ca_file, :ca_path, :timeout
4
+ attr_reader :base_unity_url, :username, :password, :appname, :timezone
5
5
 
6
6
  def initialize(options = {})
7
- @base_unity_url = options[:base_unity_url] ? options[:base_unity_url].gsub(/\/$/, '') : nil
8
7
  @username = options[:username]
9
8
  @password = options[:password]
10
9
  @appname = options[:appname]
11
10
  @proxy = options[:proxy]
12
- self.timezone = options[:timezone]
13
11
  @logger = options[:logger]
14
12
  @ca_file = options[:ca_file]
15
13
  @ca_path = options[:ca_path]
16
14
  @timeout = options[:timeout]
17
15
 
16
+ self.timezone = options[:timezone]
17
+ self.base_unity_url = options[:base_unity_url]
18
+
18
19
  validate_options
19
20
  end
20
21
 
@@ -59,9 +60,7 @@ module AllscriptsUnityClient
59
60
  end
60
61
 
61
62
  def proxy?
62
- return false if @proxy.nil?
63
- return false if @proxy.empty?
64
- true
63
+ !@proxy.to_s.strip.empty?
65
64
  end
66
65
 
67
66
  def logger?
@@ -69,21 +68,15 @@ module AllscriptsUnityClient
69
68
  end
70
69
 
71
70
  def ca_file?
72
- return false if @ca_file.nil?
73
- return false if @ca_file.empty?
74
- true
71
+ !@ca_file.to_s.strip.empty?
75
72
  end
76
73
 
77
74
  def ca_path?
78
- return false if @ca_path.nil?
79
- return false if @ca_path.empty?
80
- true
75
+ !@ca_path.to_s.strip.empty?
81
76
  end
82
77
 
83
78
  def timeout?
84
- return false if @timeout.nil?
85
- return false if @timeout.empty?
86
- true
79
+ !@timeout.to_s.strip.empty?
87
80
  end
88
81
  end
89
82
  end
@@ -1,3 +1,3 @@
1
1
  module AllscriptsUnityClient
2
- VERSION = '2.0.2'
2
+ VERSION = '2.0.3'
3
3
  end
@@ -10,14 +10,6 @@ describe 'ClientOptions' do
10
10
  let(:america_los_angeles_timezone) { AllscriptsUnityClient::Timezone.new('America/Los_Angeles') }
11
11
  let(:client_options_hash) { { base_unity_url: 'http://www.example.com', username: 'username', password: 'password', appname: 'appname', proxy: 'proxy', timezone: 'UTC', logger: nil } }
12
12
 
13
- describe '#initialize' do
14
- context 'when given a base_unity_url that ends in a slash (/)' do
15
- it 'strips the slash' do
16
- expect(build(:client_options, base_unity_url: url_with_slash).base_unity_url).to eq(url_without_slash)
17
- end
18
- end
19
- end
20
-
21
13
  describe '#validate_options' do
22
14
  context 'when not given base_unity_url' do
23
15
  it { expect { build(:client_options, base_unity_url: nil) }.to raise_error(ArgumentError) }
@@ -131,4 +123,63 @@ describe 'ClientOptions' do
131
123
  end
132
124
  end
133
125
  end
126
+
127
+ describe '#ca_file?' do
128
+ context 'when ca_file is nil' do
129
+ it 'returns false' do
130
+ expect(subject.ca_file?).to be_falsey
131
+ end
132
+ end
133
+
134
+ context 'when ca_file is not nil' do
135
+ it 'returns true' do
136
+ subject.ca_file = 'test_file'
137
+ expect(subject.ca_file?).to be_truthy
138
+ end
139
+ end
140
+
141
+ context 'when ca_file is empty string' do
142
+ it 'returns false' do
143
+ subject.ca_file = ''
144
+ expect(subject.ca_file?).to be_falsey
145
+ end
146
+ end
147
+ end
148
+
149
+ describe '#ca_path?' do
150
+ context 'when ca_path is nil' do
151
+ it 'returns false' do
152
+ expect(subject.ca_path?).to be_falsey
153
+ end
154
+ end
155
+
156
+ context 'when ca_path is not nil' do
157
+ it 'returns true' do
158
+ subject.ca_path = 'test_path'
159
+ expect(subject.ca_path?).to be_truthy
160
+ end
161
+ end
162
+
163
+ context 'when ca_path is empty string' do
164
+ it 'returns false' do
165
+ subject.ca_path = ''
166
+ expect(subject.ca_path?).to be_falsey
167
+ end
168
+ end
169
+ end
170
+
171
+ describe '#timeout?' do
172
+ context 'when timeout is nil' do
173
+ it 'returns false' do
174
+ expect(subject.timeout?).to be_falsey
175
+ end
176
+ end
177
+
178
+ context 'when timeout is not nil' do
179
+ it 'returns true' do
180
+ subject.timeout = 10
181
+ expect(subject.timeout?).to be_truthy
182
+ end
183
+ end
184
+ end
134
185
  end
@@ -6,8 +6,11 @@ FactoryGirl.define do
6
6
  username Faker::Name.name
7
7
  password Faker::Internet.password
8
8
  appname Faker::Name.name
9
- mode [:json, :soap].sample
10
- log false
9
+ proxy nil
10
+ timezone 'America/Phoenix'
11
11
  logger nil
12
+ ca_file nil
13
+ ca_path nil
14
+ timeout nil
12
15
  end
13
16
  end
@@ -1,6 +1,6 @@
1
1
  FactoryGirl.define do
2
2
  factory :client_driver, class: AllscriptsUnityClient::ClientDriver do
3
- initialize_with { new(base_unity_url: base_unity_url, username: username, password: password, appname: appname, proxy: proxy, timezone: timezone, logger: logger) }
3
+ initialize_with { new(attributes) }
4
4
 
5
5
  base_unity_url 'http://www.example.com'
6
6
  username Faker::Name.name
@@ -9,5 +9,8 @@ FactoryGirl.define do
9
9
  proxy nil
10
10
  timezone 'America/Phoenix'
11
11
  logger nil
12
+ ca_file nil
13
+ ca_path nil
14
+ timeout nil
12
15
  end
13
16
  end
@@ -1,6 +1,6 @@
1
1
  FactoryGirl.define do
2
2
  factory :client_options, class: AllscriptsUnityClient::ClientOptions do
3
- initialize_with { new(base_unity_url: base_unity_url, username: username, password: password, appname: appname, proxy: proxy, timezone: timezone, logger: logger) }
3
+ initialize_with { new(attributes) }
4
4
 
5
5
  base_unity_url 'http://www.example.com'
6
6
  username Faker::Name.name
@@ -9,5 +9,8 @@ FactoryGirl.define do
9
9
  proxy nil
10
10
  timezone 'America/Phoenix'
11
11
  logger nil
12
+ ca_file nil
13
+ ca_path nil
14
+ timeout nil
12
15
  end
13
16
  end
@@ -2,7 +2,7 @@ FactoryGirl.define do
2
2
  factory :unity_response, class: AllscriptsUnityClient::UnityResponse do
3
3
  initialize_with { new(response, timezone) }
4
4
 
5
- response {}
5
+ response Hash.new
6
6
  timezone { build(:timezone) }
7
7
  end
8
8
  end
@@ -138,4 +138,109 @@ describe 'JSONClientDriver' do
138
138
  it { expect { subject.send(:raise_if_response_error, error_string) }.to raise_error(AllscriptsUnityClient::APIError) }
139
139
  end
140
140
  end
141
+
142
+ describe '#build_faraday_options' do
143
+ context 'when given options with ca_file' do
144
+ it 'sets ca_file' do
145
+ client_driver = build(:json_client_driver, ca_file: 'test_file')
146
+ expect(client_driver.send(:build_faraday_options)[:ssl][:ca_file]).to eq('test_file')
147
+ end
148
+ end
149
+
150
+ context 'when given options with ca_path' do
151
+ it 'sets ca_path' do
152
+ client_driver = build(:json_client_driver, ca_path: 'test_path')
153
+ expect(client_driver.send(:build_faraday_options)[:ssl][:ca_path]).to eq('test_path')
154
+ end
155
+ end
156
+
157
+ context 'when given options with nil ca_file and ca_path' do
158
+ it 'calls JSONClientDriver.find_ca_file' do
159
+ allow(AllscriptsUnityClient::JSONClientDriver).to receive(:find_ca_file).and_return('/test/file')
160
+ expect(subject.send(:build_faraday_options)[:ssl][:ca_file]).to eq('/test/file')
161
+ end
162
+ end
163
+
164
+ context 'when given options with nil ca_file, ca_path, and JSONClientDriver.find_ca_file returns nil' do
165
+ it 'calls JSONClientDriver.find_ca_file' do
166
+ allow(AllscriptsUnityClient::JSONClientDriver).to receive(:find_ca_file).and_return(nil)
167
+ allow(AllscriptsUnityClient::JSONClientDriver).to receive(:find_ca_path).and_return('/test/path')
168
+ expect(subject.send(:build_faraday_options)[:ssl][:ca_path]).to eq('/test/path')
169
+ end
170
+ end
171
+ end
172
+
173
+ describe '.find_ca_path' do
174
+ context 'when Ubuntu certs path is found' do
175
+ it 'returns the Ubuntu certs path' do
176
+ allow(File).to receive(:directory?).with('/usr/lib/ssl/certs').and_return(true)
177
+ expect(AllscriptsUnityClient::JSONClientDriver.send(:find_ca_path)).to eq('/usr/lib/ssl/certs')
178
+ end
179
+ end
180
+
181
+ context 'when no certificate path is found' do
182
+ it 'returns nil' do
183
+ allow(File).to receive(:directory?).with('/usr/lib/ssl/certs').and_return(false)
184
+ expect(AllscriptsUnityClient::JSONClientDriver.send(:find_ca_path)).to be_nil
185
+ end
186
+ end
187
+ end
188
+
189
+ describe '.find_ca_file' do
190
+ context 'when OS X ca-bundle.crt found' do
191
+ it 'returns the ca-bundle.crt' do
192
+ allow(File).to receive(:exists?).with('/opt/boxen/homebrew/opt/curl-ca-bundle/share/ca-bundle.crt').and_return(true)
193
+ expect(AllscriptsUnityClient::JSONClientDriver.send(:find_ca_file)).to eq('/opt/boxen/homebrew/opt/curl-ca-bundle/share/ca-bundle.crt')
194
+ end
195
+ end
196
+
197
+ context 'when OS X curl-ca-bundle.crt found' do
198
+ it 'returns the curl-ca-bundle.crt' do
199
+ allow(File).to receive(:exists?).with('/opt/boxen/homebrew/opt/curl-ca-bundle/share/ca-bundle.crt').and_return(false)
200
+ allow(File).to receive(:exists?).with('/opt/local/share/curl/curl-ca-bundle.crt').and_return(true)
201
+ expect(AllscriptsUnityClient::JSONClientDriver.send(:find_ca_file)).to eq('/opt/local/share/curl/curl-ca-bundle.crt')
202
+ end
203
+ end
204
+
205
+ context 'when CentOS ca-certificates.crt found' do
206
+ it 'returns the curl-ca-bundle.crt' do
207
+ allow(File).to receive(:exists?).with('/opt/boxen/homebrew/opt/curl-ca-bundle/share/ca-bundle.crt').and_return(false)
208
+ allow(File).to receive(:exists?).with('/opt/local/share/curl/curl-ca-bundle.crt').and_return(false)
209
+ allow(File).to receive(:exists?).with('/usr/lib/ssl/certs/ca-certificates.crt').and_return(true)
210
+ expect(AllscriptsUnityClient::JSONClientDriver.send(:find_ca_file)).to eq('/usr/lib/ssl/certs/ca-certificates.crt')
211
+ end
212
+ end
213
+
214
+ context 'when no certificate file is found' do
215
+ it 'returns nil' do
216
+ allow(File).to receive(:exists?).with('/opt/boxen/homebrew/opt/curl-ca-bundle/share/ca-bundle.crt').and_return(false)
217
+ allow(File).to receive(:exists?).with('/opt/local/share/curl/curl-ca-bundle.crt').and_return(false)
218
+ allow(File).to receive(:exists?).with('/usr/lib/ssl/certs/ca-certificates.crt').and_return(false)
219
+ expect(AllscriptsUnityClient::JSONClientDriver.send(:find_ca_file)).to be_nil
220
+ end
221
+ end
222
+ end
223
+
224
+ describe '.set_request_timeout' do
225
+ context 'when given options with timeout set' do
226
+ it 'sets timeout and open_timeout on the request' do
227
+ client_driver = build(:json_client_driver, timeout: 10)
228
+ options = {}
229
+ request = double('request', options: options)
230
+ client_driver.send(:set_request_timeout, request)
231
+ expect(options[:timeout]).to eq(10)
232
+ expect(options[:open_timeout]).to eq(10)
233
+ end
234
+ end
235
+
236
+ context 'when given options without timeout set' do
237
+ it 'sets timeout and open_timeout to 90 on the request' do
238
+ options = {}
239
+ request = double('request', options: options)
240
+ subject.send(:set_request_timeout, request)
241
+ expect(options[:timeout]).to eq(90)
242
+ expect(options[:open_timeout]).to eq(90)
243
+ end
244
+ end
245
+ end
141
246
  end
data/spec/spec_helper.rb CHANGED
@@ -1,17 +1,21 @@
1
1
  require 'pathname'
2
2
  require 'simplecov'
3
- require 'coveralls'
3
+
4
+ # Setup coveralls only if running inside Travis-CI
5
+ if ENV['TRAVIS']
6
+ require 'coveralls'
7
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
8
+ SimpleCov::Formatter::HTMLFormatter,
9
+ Coveralls::SimpleCov::Formatter
10
+ ]
11
+ end
4
12
 
5
13
  # Configure coverage stats.
6
- SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
7
- SimpleCov::Formatter::HTMLFormatter,
8
- Coveralls::SimpleCov::Formatter
9
- ]
10
14
  SimpleCov.start do
15
+ ignored_files = %w(version.rb allscripts_unity_client.gemspec Gemfile Rakefile)
16
+
11
17
  add_filter do |source_file|
12
18
  filename = Pathname.new(source_file.filename).basename
13
- ignored_files = %w(version.rb allscripts_unity_client.gemspec Gemfile Rakefile)
14
-
15
19
  ignored_files.include?(filename) || source_file.filename.include?('spec/')
16
20
  end
17
21
  end
@@ -20,7 +24,6 @@ lib = File.expand_path('../lib/', __FILE__)
20
24
  $:.unshift lib unless $:.include?(lib)
21
25
 
22
26
  require 'allscripts_unity_client'
23
-
24
27
  require 'rspec'
25
28
  require 'webmock/rspec'
26
29
  require 'savon/mock/spec_helper'
@@ -32,9 +35,10 @@ require 'json'
32
35
  # Include all support files
33
36
  Dir['./spec/support/**/*.rb'].sort.each { |f| require f }
34
37
 
35
- # Include all factories
36
- FactoryGirl.find_definitions
37
-
38
38
  RSpec.configure do |config|
39
- config.include FactoryGirl::Syntax::Methods
39
+ # Run specs in random order to surface order dependencies. If you find an
40
+ # order dependency and want to debug it, you can fix the order by providing
41
+ # the seed, which is printed after each run.
42
+ # --seed 1234
43
+ config.order = "random"
40
44
  end
@@ -0,0 +1,10 @@
1
+ # Include all factories
2
+ FactoryGirl.find_definitions
3
+
4
+ RSpec.configure do |config|
5
+ config.include FactoryGirl::Syntax::Methods
6
+
7
+ config.before(:suite) do
8
+ FactoryGirl.lint
9
+ end
10
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: allscripts_unity_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 2.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ash Gupta
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-05-01 00:00:00.000000000 Z
12
+ date: 2014-05-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: savon
@@ -283,6 +283,7 @@ files:
283
283
  - spec/json_unity_response_spec.rb
284
284
  - spec/soap_client_driver_spec.rb
285
285
  - spec/spec_helper.rb
286
+ - spec/support/factory_girl.rb
286
287
  - spec/support/fixture_loader.rb
287
288
  - spec/support/shared_examples_for_client_driver.rb
288
289
  - spec/support/shared_examples_for_unity_request.rb