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 +4 -4
- data/lib/happi/client.rb +4 -2
- data/lib/happi/version.rb +1 -1
- data/spec/client_spec.rb +74 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 299cad5f6062c82230763027fc28c972166fac65
|
4
|
+
data.tar.gz: 7f569b830deebb62102547e9a14840c01de4f7e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
7
|
+
def config
|
8
|
+
@config ||= self.class.config.dup
|
9
|
+
end
|
8
10
|
|
9
11
|
def self.config
|
10
|
-
@
|
12
|
+
@global_config ||= Happi::Configuration.new
|
11
13
|
end
|
12
14
|
|
13
15
|
def self.configure
|
data/lib/happi/version.rb
CHANGED
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 '
|
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
|
-
|
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
|
-
|
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.
|
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-
|
11
|
+
date: 2015-04-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|