bootic_client 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7f0b175f26ae3c07540c632a0e07488ab48256a2
4
- data.tar.gz: 6dfc0cc96fdadce33457631b507ea355b0eefff9
3
+ metadata.gz: e21ff6db54eead797a8ca1206880db8f32fd7bb2
4
+ data.tar.gz: 6cd1e6710e2a4b19edf284c749094217242c53ff
5
5
  SHA512:
6
- metadata.gz: cff8a48dc27c6b5362df02749e63de27258ee8cf58091ee9bf3cac17079eea3a21c138a16245f16b96d5b2e22215411e97a5486c299944197fe0d8a2e66e8aa7
7
- data.tar.gz: c82c7be167dd5519bc7750a60dabf4d0af95c2372f284817ace9d9e4a508216a0de8f4fbd0523ca6e3a288a9b0aef93c44e4d71a1a51276dac731ab7b78fabee
6
+ metadata.gz: ee764305af03d550c8f6263df35b5ad0c656053dd7dffe57bfbc11713af78869e20eaf57d5cbc05574c00df947c7bf533cfc8a2276cf80a9f97106d14541ee19
7
+ data.tar.gz: 9faa674657d2ad7f08155366cce46fd8af5d7c740cfcb607d43c2d9b3f0e1877c0e4c917691c95bdec8996151271dba0ed9db9765fb623a1ea5fe3974caa4e57
@@ -4,12 +4,15 @@ module BooticClient
4
4
  module Strategies
5
5
  class Strategy
6
6
 
7
+ attr_reader :options
8
+
7
9
  def initialize(config, client_opts = {}, &on_new_token)
8
10
  @config, @options, @on_new_token = config, client_opts, (on_new_token || Proc.new{})
9
11
  raise "MUST include client_id" unless config.client_id
10
12
  raise "MUST include client_secret" unless config.client_secret
11
13
  raise "MUST include api_root" unless config.api_root
12
14
  validate! @options
15
+ reset!
13
16
  end
14
17
 
15
18
  def root
@@ -21,7 +24,8 @@ module BooticClient
21
24
  wrapper_class.new client.send(request_method, href, payload).body, self
22
25
  rescue TokenError => e
23
26
  new_token = get_token
24
- client.options[:access_token] = new_token
27
+ options[:access_token] = new_token
28
+ reset!
25
29
  on_new_token.call new_token
26
30
  wrapper_class.new client.send(request_method, href, payload).body, self
27
31
  end
@@ -33,7 +37,7 @@ module BooticClient
33
37
 
34
38
  protected
35
39
 
36
- attr_reader :config, :options, :on_new_token
40
+ attr_reader :config, :on_new_token, :client
37
41
 
38
42
  def validate!(options)
39
43
 
@@ -51,8 +55,8 @@ module BooticClient
51
55
  )
52
56
  end
53
57
 
54
- def client
55
- @client ||= Client.new(options)
58
+ def reset!
59
+ @client = Client.new(options)
56
60
  end
57
61
  end
58
62
  end
@@ -1,3 +1,3 @@
1
1
  module BooticClient
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -84,6 +84,7 @@ describe 'BooticClient::Strategies::ClientCredentials' do
84
84
  root = client.root
85
85
  expect(@failed_root_request).to have_been_requested
86
86
  expect(@auth_request).to have_been_requested
87
+ expect(@successful_root_request).to have_been_requested
87
88
  expect(root.message).to eql('Hello!')
88
89
  end
89
90
 
@@ -91,6 +92,11 @@ describe 'BooticClient::Strategies::ClientCredentials' do
91
92
  client.root
92
93
  expect(store[:access_token]).to eql('foobar')
93
94
  end
95
+
96
+ it 'updates internal access token' do
97
+ client.root
98
+ expect(client.options[:access_token]).to eql('foobar')
99
+ end
94
100
  end
95
101
  end
96
102
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bootic_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ismael Celis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-13 00:00:00.000000000 Z
11
+ date: 2014-07-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday