happi 0.0.11 → 0.0.12

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: 4609eaf1588e9e857af6526d060c052773fbbece
4
- data.tar.gz: 82c6dca31274a713b4d0f3078df6d8ba650c184b
3
+ metadata.gz: 299cad5f6062c82230763027fc28c972166fac65
4
+ data.tar.gz: 7f569b830deebb62102547e9a14840c01de4f7e5
5
5
  SHA512:
6
- metadata.gz: e54212b486bfe57ae4635b3867b96735c930e9fea1a15458e2001c9ac61bc7e797ac64ad896442ee0bd51fe06f2a4b9687b58705dc1e6733ed3a262aac3a1d94
7
- data.tar.gz: 7740cff68f3442b7ac303bc3cc3cbd24fdb911c133b714b41e8d4c8e4cf6d000650086bbfd7fc29afb4e5777f7eb523d5c2ba5019285f5bde578666eee3cc466
6
+ metadata.gz: 6e89dee05f976a673fd030894a41de63bdb4f4a5e9df7e54db2b1cb7053f6390d20a2d695eed838e0ea054a755f97e91c5ad50ddfe34e7c8abfb194ad0a86abd
7
+ data.tar.gz: 88aef7e42786f035d5993464806794e9dedcad31601a4b4d2b1792ff560d7c3dd7993b06c53c84d88ab940c1a0aa5df7756a9fddaa30a311fc16b294ba740330
data/lib/happi/client.rb CHANGED
@@ -4,10 +4,12 @@ require 'active_support/core_ext/string/inflections'
4
4
  require 'active_support/core_ext/hash'
5
5
 
6
6
  class Happi::Client
7
- delegate :config, to: self
7
+ def config
8
+ @config ||= self.class.config.dup
9
+ end
8
10
 
9
11
  def self.config
10
- @config ||= Happi::Configuration.new
12
+ @global_config ||= Happi::Configuration.new
11
13
  end
12
14
 
13
15
  def self.configure
data/lib/happi/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Happi
2
- VERSION = '0.0.11'
2
+ VERSION = '0.0.12'
3
3
  end
data/spec/client_spec.rb CHANGED
@@ -1,11 +1,82 @@
1
1
  require 'spec_helper'
2
2
 
3
+ class DerivedClient < Happi::Client; end
4
+
3
5
  describe Happi::Client do
4
- describe 'call' do
6
+ describe '.new' do
7
+ let(:default_port) { Happi::Configuration.defaults[:port] }
8
+ let(:class_level_port) { 80 }
9
+ let(:instance_level_port) { 8080 }
10
+ let(:derived_class_level_port) { 8081 }
11
+ let(:config_port) { described_class.new.config.port }
12
+ let(:derived_config_port) { DerivedClient.new.config.port }
5
13
 
6
- end
14
+ context 'with no supplied config' do
15
+ it 'uses the default config for the base class' do
16
+ expect(config_port).to eq(default_port)
17
+ end
18
+
19
+ it 'uses the default config for the derived class' do
20
+ expect(derived_config_port).to eq(default_port)
21
+ end
22
+ end
23
+
24
+ context 'with class level config for the base class' do
25
+ before do
26
+ described_class.configure { |config| config.port = class_level_port }
27
+ end
28
+
29
+ it 'overrides the default config for the base class' do
30
+ expect(config_port).to eq(class_level_port)
31
+ end
32
+
33
+ it 'does not override the default config for the derived class' do
34
+ expect(derived_config_port).to_not eq(class_level_port)
35
+ end
36
+ end
37
+
38
+ context 'with class level config for the derived class' do
39
+ before do
40
+ DerivedClient.configure { |config| config.port = derived_class_level_port }
41
+ end
42
+
43
+ it 'does not affect the config for the base class' do
44
+ expect(config_port).to_not eq(derived_class_level_port)
45
+ end
46
+
47
+ it 'overrides the default config for the derived class' do
48
+ expect(derived_config_port).to eq(derived_class_level_port)
49
+ end
50
+ end
51
+
52
+ context 'with instance level config for the base class' do
53
+ before do
54
+ described_class.configure { |config| config.port = class_level_port }
55
+ end
56
+
57
+ it 'overrides the class config for only that base class instance' do
58
+ expect(Happi::Client.new(port: instance_level_port).config.port).to eq(instance_level_port)
59
+ expect(config_port).to_not eq(instance_level_port)
60
+ end
61
+
62
+ it 'does not affect the config for an instance of the derived class' do
63
+ expect(derived_config_port).to_not eq(instance_level_port)
64
+ end
65
+ end
66
+
67
+ context 'with instance level config for the derived class' do
68
+ before do
69
+ described_class.configure { |config| config.port = class_level_port }
70
+ end
7
71
 
8
- describe 'raise_error' do
72
+ it 'does not affect the config for an instance of the base class' do
73
+ expect(config_port).to_not eq(instance_level_port)
74
+ end
9
75
 
76
+ it 'overrides the class config for only that derived class instance' do
77
+ expect(DerivedClient.new(port: instance_level_port).config.port).to eq(instance_level_port)
78
+ expect(derived_config_port).to_not eq(instance_level_port)
79
+ end
80
+ end
10
81
  end
11
82
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: happi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - John D'Agostino
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-12 00:00:00.000000000 Z
11
+ date: 2015-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday