gds-api-adapters 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -12,6 +12,7 @@ module GdsApi
12
12
  @kind = options[:kind] || 'custom-application'
13
13
  @panopticon = options[:panopticon]
14
14
  @platform = options[:platform] || Plek.current.environment
15
+ @timeout = options[:timeout] || 10
15
16
  end
16
17
 
17
18
  def record_to_artefact(record)
@@ -59,7 +60,7 @@ module GdsApi
59
60
 
60
61
  def panopticon
61
62
  options = {
62
- timeout: 5
63
+ timeout: @timeout
63
64
  }
64
65
  @panopticon ||= GdsApi::Panopticon.new(@platform, options.merge(panopticon_api_credentials))
65
66
  end
@@ -1,3 +1,3 @@
1
1
  module GdsApi
2
- VERSION = '0.2.2'
2
+ VERSION = '0.2.3'
3
3
  end
@@ -0,0 +1,55 @@
1
+ require_relative 'test_helper'
2
+ require 'gds_api/panopticon'
3
+
4
+ describe GdsApi::Panopticon::Registerer do
5
+
6
+
7
+ describe "creating an instance of the panopticon client" do
8
+ describe "setting the platform" do
9
+ it "should create an instance using the current Plek environment as the platform by default" do
10
+ Plek.stubs(:current).returns(stub(environment: "Something"))
11
+
12
+ GdsApi::Panopticon.expects(:new).with("Something", anything()).returns(:panopticon_instance)
13
+ r = GdsApi::Panopticon::Registerer.new({})
14
+ assert_equal :panopticon_instance, r.send(:panopticon)
15
+ end
16
+
17
+ it "should allow overriding the platform" do
18
+ Plek.stubs(:current).returns(stub(environment: "Something"))
19
+
20
+ GdsApi::Panopticon.expects(:new).with("Something_else", anything()).returns(:panopticon_instance)
21
+ r = GdsApi::Panopticon::Registerer.new({platform: "Something_else"})
22
+ assert_equal :panopticon_instance, r.send(:panopticon)
23
+ end
24
+ end
25
+
26
+ describe "setting other options" do
27
+ it "should create an instance with a default timeout of 10 seconds" do
28
+ GdsApi::Panopticon.expects(:new).with(anything(), {timeout: 10}).returns(:panopticon_instance)
29
+ r = GdsApi::Panopticon::Registerer.new({})
30
+ assert_equal :panopticon_instance, r.send(:panopticon)
31
+ end
32
+
33
+ it "should allow overriding the timeout" do
34
+ GdsApi::Panopticon.expects(:new).with(anything(), {timeout: 15}).returns(:panopticon_instance)
35
+ r = GdsApi::Panopticon::Registerer.new({timeout: 15})
36
+ assert_equal :panopticon_instance, r.send(:panopticon)
37
+ end
38
+
39
+ it "shoule merge in the api credentials" do
40
+ GdsApi::Panopticon::Registerer.any_instance.stubs(:panopticon_api_credentials).returns({foo: "Bar", baz: "kablooie"})
41
+ GdsApi::Panopticon.expects(:new).with(anything(), {timeout: 10, foo: "Bar", baz: "kablooie"}).returns(:panopticon_instance)
42
+ r = GdsApi::Panopticon::Registerer.new({})
43
+ assert_equal :panopticon_instance, r.send(:panopticon)
44
+ end
45
+ end
46
+
47
+ it "should memoize the panopticon instance" do
48
+ GdsApi::Panopticon.expects(:new).once.returns(:panopticon_instance)
49
+ r = GdsApi::Panopticon::Registerer.new({})
50
+
51
+ assert_equal :panopticon_instance, r.send(:panopticon)
52
+ assert_equal :panopticon_instance, r.send(:panopticon)
53
+ end
54
+ end
55
+ end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: gds-api-adapters
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.2.2
5
+ version: 0.2.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - James Stewart
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2012-07-23 00:00:00 Z
13
+ date: 2012-08-31 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: plek
@@ -129,7 +129,7 @@ dependencies:
129
129
  requirements:
130
130
  - - ~>
131
131
  - !ruby/object:Gem::Version
132
- version: 1.0.0
132
+ version: 1.1.1
133
133
  type: :development
134
134
  prerelease: false
135
135
  version_requirements: *id011
@@ -143,35 +143,36 @@ extensions: []
143
143
  extra_rdoc_files: []
144
144
 
145
145
  files:
146
- - lib/gds_api/version.rb
147
- - lib/gds_api/publisher.rb
148
- - lib/gds_api/panopticon/registerer.rb
149
- - lib/gds_api/typhoeus_client.rb
150
- - lib/gds_api/imminence.rb
151
- - lib/gds_api/contactotron.rb
152
- - lib/gds_api/test_helpers/publisher.rb
153
- - lib/gds_api/test_helpers/imminence.rb
154
146
  - lib/gds_api/test_helpers/contactotron.rb
155
- - lib/gds_api/test_helpers/panopticon.rb
156
147
  - lib/gds_api/test_helpers/json_client_helper.rb
157
- - lib/gds_api/base.rb
158
- - lib/gds_api/json_client.rb
159
- - lib/gds_api/response.rb
160
- - lib/gds_api/panopticon.rb
161
- - lib/gds_api/core-ext/openstruct.rb
162
- - lib/gds_api/oauth2_client.rb
148
+ - lib/gds_api/test_helpers/publisher.rb
149
+ - lib/gds_api/test_helpers/panopticon.rb
150
+ - lib/gds_api/test_helpers/imminence.rb
163
151
  - lib/gds_api/part_methods.rb
164
152
  - lib/gds_api/needotron.rb
153
+ - lib/gds_api/typhoeus_client.rb
154
+ - lib/gds_api/json_client.rb
155
+ - lib/gds_api/contactotron.rb
156
+ - lib/gds_api/oauth2_client.rb
157
+ - lib/gds_api/response.rb
158
+ - lib/gds_api/panopticon/registerer.rb
159
+ - lib/gds_api/publisher.rb
165
160
  - lib/gds_api/exceptions.rb
161
+ - lib/gds_api/version.rb
166
162
  - lib/gds_api/helpers.rb
163
+ - lib/gds_api/base.rb
164
+ - lib/gds_api/panopticon.rb
165
+ - lib/gds_api/core-ext/openstruct.rb
166
+ - lib/gds_api/imminence.rb
167
167
  - README.md
168
168
  - Rakefile
169
169
  - test/contactotron_api_test.rb
170
- - test/panopticon_api_test.rb
171
- - test/publisher_api_test.rb
172
170
  - test/json_client_test.rb
173
- - test/gds_api_base_test.rb
171
+ - test/publisher_api_test.rb
172
+ - test/panopticon_registerer_test.rb
173
+ - test/panopticon_api_test.rb
174
174
  - test/test_helper.rb
175
+ - test/gds_api_base_test.rb
175
176
  homepage: http://github.com/alphagov/gds-api-adapters
176
177
  licenses: []
177
178
 
@@ -185,7 +186,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
185
186
  requirements:
186
187
  - - ">="
187
188
  - !ruby/object:Gem::Version
188
- hash: 3276666182600664028
189
+ hash: 694492284820059124
189
190
  segments:
190
191
  - 0
191
192
  version: "0"
@@ -194,7 +195,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
194
195
  requirements:
195
196
  - - ">="
196
197
  - !ruby/object:Gem::Version
197
- hash: 3276666182600664028
198
+ hash: 694492284820059124
198
199
  segments:
199
200
  - 0
200
201
  version: "0"
@@ -207,8 +208,9 @@ specification_version: 3
207
208
  summary: Adapters to work with GDS APIs
208
209
  test_files:
209
210
  - test/contactotron_api_test.rb
210
- - test/panopticon_api_test.rb
211
- - test/publisher_api_test.rb
212
211
  - test/json_client_test.rb
213
- - test/gds_api_base_test.rb
212
+ - test/publisher_api_test.rb
213
+ - test/panopticon_registerer_test.rb
214
+ - test/panopticon_api_test.rb
214
215
  - test/test_helper.rb
216
+ - test/gds_api_base_test.rb