hieracles 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -17,7 +17,8 @@ describe Hieracles::Node do
17
17
  let(:extraoptions) {
18
18
  options.merge({ params: 'key1=value1;key2=value2' })
19
19
  }
20
- let(:node) { Hieracles::Node.new 'server.example.com', extraoptions }
20
+ let(:config) { Hieracles::Config.new extraoptions }
21
+ let(:node) { Hieracles::Node.new 'server.example.com', config }
21
22
  let(:expected) {
22
23
  {
23
24
  classes: ['dev'],
@@ -35,12 +36,14 @@ describe Hieracles::Node do
35
36
  end
36
37
 
37
38
  context "when parameters are not valid" do
38
- let(:node) { Hieracles::Node.new 'server_not_there.example.com', options }
39
+ let(:config) { Hieracles::Config.new options }
40
+ let(:node) { Hieracles::Node.new 'server_not_there.example.com', config }
39
41
  it { expect{ node }.to raise_error(RuntimeError) }
40
42
  end
41
43
 
42
44
  context "when parameters are valid" do
43
- let(:node) { Hieracles::Node.new 'server.example.com', options }
45
+ let(:config) { Hieracles::Config.new options }
46
+ let(:node) { Hieracles::Node.new 'server.example.com', config }
44
47
 
45
48
  describe '.new' do
46
49
  let(:expected) {
@@ -78,58 +81,71 @@ describe Hieracles::Node do
78
81
 
79
82
  describe '.params' do
80
83
  let(:expected) {
81
- [
82
- [ "another.more_sublevel",
83
- [{
84
+ {
85
+ "another.more_sublevel" =>
86
+ {
84
87
  value: "something",
85
88
  file: 'params/farm/dev.yaml',
86
- merged: 'something'
87
- }]
88
- ],
89
- [ "another.sublevel.array",
90
- [
91
- {
92
- value: ["one", "two", "three"],
89
+ overriden: false,
90
+ found_in: [
91
+ value: "something",
93
92
  file: 'params/farm/dev.yaml',
94
- merged: ["one", "three", "two"]
95
- },
96
- {
97
- value: ["four", "five"],
98
- file: 'params/nodes/server.example.com.yaml',
99
- merged: ["five", "four"]
100
- }
101
- ]
102
- ],
103
- [ "another.sublevel.thing",
104
- [{
93
+ ]
94
+ },
95
+ "another.sublevel.array" =>
96
+ {
97
+ value: ["four", "five"],
98
+ file: '-',
99
+ overriden: true,
100
+ found_in: [
101
+ {
102
+ value: ["four", "five"],
103
+ file: 'params/nodes/server.example.com.yaml'
104
+ },
105
+ {
106
+ value: ["one", "two", "three"],
107
+ file: 'params/farm/dev.yaml'
108
+ }
109
+ ]
110
+ },
111
+ "another.sublevel.thing" =>
112
+ {
105
113
  value: "always",
106
114
  file: 'params/nodes/server.example.com.yaml',
107
- merged: "always"
108
- }]
109
- ],
110
- [ "common_param.subparam",
111
- [
112
- {
113
- value: "override-me",
114
- file: 'params/farm/dev.yaml',
115
- merged: "override-me"
116
- },
117
- {
118
- value: "overriden",
115
+ overriden: false,
116
+ found_in: [
117
+ value: "always",
119
118
  file: 'params/nodes/server.example.com.yaml',
120
- merged: "overriden"
121
- }
122
- ]
123
- ],
124
- [ "somefarmparam",
125
- [{
119
+ ]
120
+ },
121
+ "common_param.subparam" =>
122
+ {
123
+ value: "overriden",
124
+ file: '-',
125
+ overriden: true,
126
+ found_in: [
127
+ {
128
+ value: "overriden",
129
+ file: 'params/nodes/server.example.com.yaml'
130
+ },
131
+ {
132
+ value: "override-me",
133
+ file: 'params/farm/dev.yaml'
134
+ },
135
+ ]
136
+ },
137
+ "somefarmparam" =>
138
+ {
126
139
  value: false,
127
140
  file: 'params/farm/dev.yaml',
128
- merged: false
129
- }]
130
- ]
131
- ]
132
- }
141
+ overriden: false,
142
+ found_in: [
143
+ value: false,
144
+ file: 'params/farm/dev.yaml',
145
+ ]
146
+ }
147
+ }
148
+ }
133
149
  it { expect(node.params).to eq expected }
134
150
  end
135
151
 
@@ -164,7 +180,7 @@ describe Hieracles::Node do
164
180
  it { expect(node.modules).to eq expected }
165
181
  end
166
182
  context "one unfound modules" do
167
- let(:node) { Hieracles::Node.new 'server2.example.com', options }
183
+ let(:node) { Hieracles::Node.new 'server2.example.com', config }
168
184
  let(:expected) {
169
185
  {
170
186
  "fake_module" => File.expand_path("spec/files/modules/fake_module"),
@@ -175,11 +191,11 @@ describe Hieracles::Node do
175
191
  it { expect(node.modules).to eq expected }
176
192
  end
177
193
  context "no farm file found" do
178
- let(:node) { Hieracles::Node.new 'server3.example.com', options }
194
+ let(:node) { Hieracles::Node.new 'server3.example.com', config }
179
195
  it { expect { node.modules }.to raise_error(RuntimeError) }
180
196
  end
181
197
  context "multiple classes included" do
182
- let(:node) { Hieracles::Node.new 'server4.example.com', options }
198
+ let(:node) { Hieracles::Node.new 'server4.example.com', config }
183
199
  let(:expected) {
184
200
  {
185
201
  "fake_module" => File.expand_path("spec/files/modules/fake_module"),
@@ -232,7 +248,8 @@ describe Hieracles::Node do
232
248
  let(:resp_facts) {
233
249
  Hieracles::Puppetdb::Response.new([{ 'name' => 'datacenter', 'value' => 'tahiti' }], 1)
234
250
  }
235
- let(:node) { Hieracles::Node.new 'server.example.com', options }
251
+ let(:config) { Hieracles::Config.new options }
252
+ let(:node) { Hieracles::Node.new 'server.example.com', config }
236
253
  before {
237
254
  allow_any_instance_of(Hieracles::Puppetdb::Client).
238
255
  to receive(:request).
@@ -256,7 +273,8 @@ describe Hieracles::Node do
256
273
  basepath: 'spec/files'
257
274
  }
258
275
  }
259
- let(:node) { Hieracles::Node.new 'server.example.com', options }
276
+ let(:config) { Hieracles::Config.new options }
277
+ let(:node) { Hieracles::Node.new 'server.example.com', config }
260
278
 
261
279
  describe '.files' do
262
280
  let(:expected) {
@@ -279,62 +297,76 @@ describe Hieracles::Node do
279
297
  basepath: 'spec/files'
280
298
  }
281
299
  }
282
- let(:node) { Hieracles::Node.new 'server.example.com', options }
300
+ let(:config) { Hieracles::Config.new options }
301
+ let(:node) { Hieracles::Node.new 'server.example.com', config }
283
302
 
284
303
  describe '.params' do
285
304
  let(:expected) {
286
- [
287
- [ "another.more_sublevel",
288
- [{
305
+ {
306
+ "another.more_sublevel" =>
307
+ {
289
308
  value: "something",
290
309
  file: 'params/farm/dev.yaml',
291
- merged: "something"
292
- }]
293
- ],
294
- [ "another.sublevel.array",
295
- [
296
- {
297
- value: ["one", "two", "three"],
298
- file: 'params/farm/dev.yaml',
299
- merged: ["one", "three", "two"]
300
- },
301
- {
302
- value: ["four", "five"],
303
- file: 'params/nodes/server.example.com.yaml',
304
- merged: ["five", "four", "one", "three", "two"]
305
- }
306
- ]
307
- ],
308
- [ "another.sublevel.thing",
309
- [{
310
+ overriden: false,
311
+ found_in: [
312
+ value: "something",
313
+ file: 'params/farm/dev.yaml'
314
+ ]
315
+ },
316
+ "another.sublevel.array" =>
317
+ {
318
+ value: ["four", "five", "one", "two", "three"],
319
+ file: '-',
320
+ overriden: true,
321
+ found_in: [
322
+ {
323
+ value: ["four", "five"],
324
+ file: 'params/nodes/server.example.com.yaml'
325
+ },
326
+ {
327
+ value: ["one", "two", "three"],
328
+ file: 'params/farm/dev.yaml'
329
+ }
330
+ ]
331
+ },
332
+ "another.sublevel.thing" =>
333
+ {
310
334
  value: "always",
311
335
  file: 'params/nodes/server.example.com.yaml',
312
- merged: "always"
313
- }]
314
- ],
315
- [ "common_param.subparam",
316
- [
317
- {
318
- value: "override-me",
319
- file: 'params/farm/dev.yaml',
320
- merged: "override-me"
321
- },
322
- {
323
- value: "overriden",
324
- file: 'params/nodes/server.example.com.yaml',
325
- merged: "overriden"
326
- }
327
- ]
328
- ],
329
- [ "somefarmparam",
330
- [{
336
+ overriden: false,
337
+ found_in: [
338
+ value: "always",
339
+ file: 'params/nodes/server.example.com.yaml'
340
+ ]
341
+ },
342
+ "common_param.subparam" =>
343
+ {
344
+ value: "overriden",
345
+ file: '-',
346
+ overriden: true,
347
+ found_in: [
348
+ {
349
+ value: "overriden",
350
+ file: 'params/nodes/server.example.com.yaml'
351
+ },
352
+ {
353
+ value: "override-me",
354
+ file: 'params/farm/dev.yaml'
355
+ },
356
+ ]
357
+ },
358
+ "somefarmparam" =>
359
+ {
331
360
  value: false,
332
361
  file: 'params/farm/dev.yaml',
333
- merged: false
334
- }]
335
- ]
336
- ]
337
- }
362
+ overriden: false,
363
+ found_in: [
364
+ value: false,
365
+ file: 'params/farm/dev.yaml',
366
+ ]
367
+ }
368
+ }
369
+ }
338
370
  it { expect(node.params).to eq expected }
339
371
  end
340
372
 
@@ -369,65 +401,81 @@ describe Hieracles::Node do
369
401
  basepath: 'spec/files'
370
402
  }
371
403
  }
372
- let(:node) { Hieracles::Node.new 'server.example.com', options }
404
+ let(:config) { Hieracles::Config.new options }
405
+ let(:node) { Hieracles::Node.new 'server.example.com', config }
406
+
373
407
 
374
408
  describe '.params' do
375
409
  let(:expected) {
376
- [
377
- [ "another.more_sublevel",
378
- [{
410
+ {
411
+ "another.more_sublevel" =>
412
+ {
379
413
  value: "something",
380
414
  file: 'params/farm/dev.yaml',
381
- merged: "something"
382
- }]
383
- ],
384
- [ "another.sublevel.array",
385
- [
386
- {
387
- value: ["one", "two", "three"],
388
- file: 'params/farm/dev.yaml',
389
- merged: ["one", "three", "two"]
390
- },
391
- {
392
- value: ["four", "five"],
393
- file: 'params/nodes/server.example.com.yaml',
394
- merged: ["five", "four", "one", "three", "two"]
395
- }
396
- ]
397
- ],
398
- [ "another.sublevel.thing",
399
- [{
415
+ overriden: false,
416
+ found_in: [
417
+ value: "something",
418
+ file: 'params/farm/dev.yaml'
419
+ ]
420
+ },
421
+ "another.sublevel.array" =>
422
+ {
423
+ value: ["one", "two", "three", "four", "five"],
424
+ file: '-',
425
+ overriden: true,
426
+ found_in: [
427
+ {
428
+ value: ["four", "five"],
429
+ file: 'params/nodes/server.example.com.yaml'
430
+ },
431
+ {
432
+ value: ["one", "two", "three"],
433
+ file: 'params/farm/dev.yaml'
434
+ }
435
+ ]
436
+ },
437
+ "another.sublevel.thing" =>
438
+ {
400
439
  value: "always",
401
440
  file: 'params/nodes/server.example.com.yaml',
402
- merged: "always"
403
- }]
404
- ],
405
- [ "common_param.subparam",
406
- [
407
- {
408
- value: "override-me",
409
- file: 'params/farm/dev.yaml',
410
- merged: "override-me"
411
- },
412
- {
413
- value: "overriden",
414
- file: 'params/nodes/server.example.com.yaml',
415
- merged: "overriden"
416
- }
417
- ]
418
- ],
419
- [ "somefarmparam",
420
- [{
441
+ overriden: false,
442
+ found_in: [
443
+ value: "always",
444
+ file: 'params/nodes/server.example.com.yaml'
445
+ ]
446
+ },
447
+ "common_param.subparam" =>
448
+ {
449
+ value: "overriden",
450
+ file: '-',
451
+ overriden: true,
452
+ found_in: [
453
+ {
454
+ value: "overriden",
455
+ file: 'params/nodes/server.example.com.yaml'
456
+ },
457
+ {
458
+ value: "override-me",
459
+ file: 'params/farm/dev.yaml'
460
+ },
461
+ ]
462
+ },
463
+ "somefarmparam" =>
464
+ {
421
465
  value: false,
422
466
  file: 'params/farm/dev.yaml',
423
- merged: false
424
- }]
425
- ]
426
- ]
427
- }
467
+ overriden: false,
468
+ found_in: [
469
+ value: false,
470
+ file: 'params/farm/dev.yaml',
471
+ ]
472
+ }
473
+ }
474
+ }
428
475
  it { expect(node.params).to eq expected }
429
476
  end
430
477
 
478
+
431
479
  describe '.params_tree' do
432
480
  let(:expected) {
433
481
  {
@@ -10,13 +10,13 @@ describe Hieracles::Registry do
10
10
  basepath: 'spec/files'
11
11
  }
12
12
  end
13
+ let(:config) { Hieracles::Config.new options }
13
14
  let(:expected) { [
14
- File.join(Hieracles::Config.basepath, 'farm_modules', 'dev.pp'),
15
- File.join(Hieracles::Config.basepath, 'farm_modules', 'dev2.pp'),
16
- File.join(Hieracles::Config.basepath, 'farm_modules', 'dev4.pp')
17
- ] }
18
- before { Hieracles::Config.load options}
19
- it { expect(Hieracles::Registry.farms Hieracles::Config).to eq expected }
15
+ 'dev',
16
+ 'dev2',
17
+ 'dev4'
18
+ ] }
19
+ it { expect(Hieracles::Registry.farms config).to eq expected }
20
20
  end
21
21
 
22
22
  describe '.nodes' do
@@ -32,8 +32,8 @@ describe Hieracles::Registry do
32
32
  'server3.example.com',
33
33
  'server4.example.com'
34
34
  ] }
35
- before { Hieracles::Config.load options}
36
- it { expect(Hieracles::Registry.nodes Hieracles::Config).to eq expected }
35
+ let(:config) { Hieracles::Config.new options }
36
+ it { expect(Hieracles::Registry.nodes config).to eq expected }
37
37
  end
38
38
 
39
39
  describe '.modules' do
@@ -50,8 +50,8 @@ describe Hieracles::Registry do
50
50
  'faux_module1',
51
51
  'faux_module2'
52
52
  ] }
53
- before { Hieracles::Config.load options}
54
- it { expect(Hieracles::Registry.modules Hieracles::Config).to eq expected }
53
+ let(:config) { Hieracles::Config.new options }
54
+ it { expect(Hieracles::Registry.modules config).to eq expected }
55
55
  end
56
56
 
57
57
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hieracles
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - mose
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-16 00:00:00.000000000 Z
11
+ date: 2015-12-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty