voxpupuli-test 1.2.0 → 1.3.0

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
  SHA256:
3
- metadata.gz: 77bc03767c8ec31c56ad01387b44f076da3f46a093ad7497ec72d3927b70725d
4
- data.tar.gz: a01ea0674defb7e51d80579e3aab0c0c46a04f994c2098fe08f8d9f020df2037
3
+ metadata.gz: ae4f31040a7c6f31b6c796599bfad36becc0297caa870daf78cf8e9d42cc4069
4
+ data.tar.gz: 1244e510fa236fb03cf1d496cc818ee8df3773340dc8a2279b66110b1cddec68
5
5
  SHA512:
6
- metadata.gz: 1c04841db70904b8cb9b4da786bc51c9b5d6901c5fe519d8ab1375e08aa4aaf71aa3a23e5b8c3d7fc9321a1a436bdd37ba36be664453663538163766f20e0871
7
- data.tar.gz: bba1d56a532d2b118a3269ce502044216b402409b31790730f7f61e030d608a69f8dc69bd20aeaf0403d13fb4fcd28c3d2e657e09f40a06ee2cdd885c2f7cf87
6
+ metadata.gz: a8a8395a3b6817b5c82ed1e8fefdd8e6b994847ac738a200505f3fa0a1a22221e8428d06b5646a6f6558c690acc279df4020e251fc7714c9c6012261c2adb8d3
7
+ data.tar.gz: cdcbf4c05bf995a2269e749745daacaccbeb0125a308b7811a9dd5bd5987bc22dab5036e99dbd34bcfb6214e1f7d092c10be9e881f1f69e99c947ef58fb17156
@@ -0,0 +1,34 @@
1
+ # Override facts
2
+ #
3
+ # This doesn't use deep_merge because that's highly unpredictable. It can merge
4
+ # nested hashes in place, modifying the original. It's also unable to override
5
+ # true to false.
6
+ #
7
+ # A deep copy is obtained by using Marshal so it can be modified in place. Then
8
+ # it recursively overrides values. If the result is a hash, it's recursed into.
9
+ #
10
+ # A typical example:
11
+ #
12
+ # let(:facts) do
13
+ # override_facts(super(), os: {'selinux' => {'enabled' => false}})
14
+ # end
15
+ def override_facts(base_facts, **overrides)
16
+ facts = Marshal.load(Marshal.dump(base_facts))
17
+ apply_overrides!(facts, overrides, false)
18
+ facts
19
+ end
20
+
21
+ # A private helper to override_facts
22
+ def apply_overrides!(facts, overrides, enforce_strings)
23
+ overrides.each do |key, value|
24
+ # Nested facts are strings
25
+ key = key.to_s if enforce_strings
26
+
27
+ if value.is_a?(Hash)
28
+ facts[key] = {} unless facts.key?(key)
29
+ apply_overrides!(facts[key], value, true)
30
+ else
31
+ facts[key] = value
32
+ end
33
+ end
34
+ end
@@ -24,6 +24,7 @@ RSpec.configure do |config|
24
24
  end
25
25
  end
26
26
 
27
+ require 'voxpupuli/test/facts'
27
28
  require 'puppetlabs_spec_helper/module_spec_helper'
28
29
  require 'rspec-puppet-facts'
29
30
  include RspecPuppetFacts
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: voxpupuli-test
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vox Pupuli
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-14 00:00:00.000000000 Z
11
+ date: 2020-04-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -276,6 +276,20 @@ dependencies:
276
276
  - - ">="
277
277
  - !ruby/object:Gem::Version
278
278
  version: '0'
279
+ - !ruby/object:Gem::Dependency
280
+ name: rspec
281
+ requirement: !ruby/object:Gem::Requirement
282
+ requirements:
283
+ - - ">="
284
+ - !ruby/object:Gem::Version
285
+ version: '0'
286
+ type: :development
287
+ prerelease: false
288
+ version_requirements: !ruby/object:Gem::Requirement
289
+ requirements:
290
+ - - ">="
291
+ - !ruby/object:Gem::Version
292
+ version: '0'
279
293
  description: A package that depends on all the gems Vox Pupuli modules need and methods
280
294
  to simplify spec helpers
281
295
  email:
@@ -285,6 +299,7 @@ extensions: []
285
299
  extra_rdoc_files: []
286
300
  files:
287
301
  - lib/voxpupuli/test.rb
302
+ - lib/voxpupuli/test/facts.rb
288
303
  - lib/voxpupuli/test/rake.rb
289
304
  - lib/voxpupuli/test/spec_helper.rb
290
305
  homepage: http://github.com/voxpupuli/voxpupuli-test