rspec-puppet-facts 2.0.5 → 3.0.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: f8b388a56b77311997681ce48848b6e799c7943d8c2e3d296345e9f6587bc2ca
4
- data.tar.gz: 33f5a3534d51478872c88b1e8ca74843820ff433f19e62932c9c7e58228f2234
3
+ metadata.gz: 6d829fff0e8b5d1ca49d62e80553aeb95658f8b12fd774c92c9f92322a52bbe1
4
+ data.tar.gz: a00418119004c0fbad99a43362ff35f3e76ee118b2f460c922c3b4d6d51fce49
5
5
  SHA512:
6
- metadata.gz: 3e0487293f8f9a2b4c9b8e45db12770f9002eddefe705e0697d68f8e74982910a4deb8f1c939d56953b0cb203980910ad6011527a131ca03828c3351336f6a83
7
- data.tar.gz: 82229c84b00526195fa998d14047a84cbf7ba2782930928b8ba11fe7f646b793b76b5e3932ee33503d40cf2f1d59c97eb3a8269fe8f88e60baaaa2d926d0efcd
6
+ metadata.gz: 2467fd5253ad8096ac306a162580b4bff64cee7ff0193a67b769ef2d272346781e12b9c07ed69dd33ace30b00dd51f6668bb99c2493d5976be4fbc896f86b9cd
7
+ data.tar.gz: '092e3f2d3b573d26caf21c953fc8dbc92e5a77599a34b61da190669514f6875a01df1289e6daeec43760c7a591f2491fef5c6decf708bccee4f6ad67a881793d'
@@ -1,8 +1,17 @@
1
1
  version: 2
2
2
  updates:
3
+ # raise PRs for gem updates
3
4
  - package-ecosystem: bundler
4
5
  directory: "/"
5
6
  schedule:
6
7
  interval: daily
7
- time: "04:00"
8
+ time: "13:00"
9
+ open-pull-requests-limit: 10
10
+
11
+ # Maintain dependencies for GitHub Actions
12
+ - package-ecosystem: github-actions
13
+ directory: "/"
14
+ schedule:
15
+ interval: daily
16
+ time: "13:00"
8
17
  open-pull-requests-limit: 10
@@ -10,15 +10,15 @@ jobs:
10
10
  runs-on: ubuntu-latest
11
11
  if: github.repository_owner == 'voxpupuli'
12
12
  steps:
13
- - uses: actions/checkout@v2
14
- - name: Install Ruby 3.0
13
+ - uses: actions/checkout@v4
14
+ - name: Install Ruby 3.3
15
15
  uses: ruby/setup-ruby@v1
16
16
  with:
17
- ruby-version: '3.0'
17
+ ruby-version: '3.3'
18
18
  env:
19
19
  BUNDLE_WITHOUT: release
20
20
  - name: Build gem
21
- run: gem build *.gemspec
21
+ run: gem build --strict --verbose *.gemspec
22
22
  - name: Publish gem to rubygems.org
23
23
  run: gem push *.gem
24
24
  env:
@@ -1,30 +1,45 @@
1
1
  name: Test
2
2
 
3
3
  on:
4
- - pull_request
5
- - push
4
+ pull_request: {}
5
+ push:
6
+ branches:
7
+ - master
6
8
 
7
9
  env:
8
10
  BUNDLE_WITHOUT: release
9
11
 
10
12
  jobs:
13
+ rubocop:
14
+ env:
15
+ BUNDLE_WITHOUT: release
16
+ runs-on: ubuntu-latest
17
+ steps:
18
+ - uses: actions/checkout@v4
19
+ - name: Install Ruby ${{ matrix.ruby }}
20
+ uses: ruby/setup-ruby@v1
21
+ with:
22
+ ruby-version: "3.3"
23
+ bundler-cache: true
24
+ - name: Run Rubocop
25
+ run: bundle exec rake rubocop
26
+
11
27
  test:
12
28
  runs-on: ubuntu-latest
13
29
  strategy:
14
30
  fail-fast: false
15
31
  matrix:
16
32
  include:
17
- - ruby: '2.4'
18
- - ruby: '2.5'
19
- - ruby: '2.6'
20
33
  - ruby: '2.7'
21
34
  - ruby: '3.0'
22
35
  - ruby: '3.1'
36
+ - ruby: '3.2'
37
+ - ruby: '3.3'
23
38
  coverage: 'yes'
24
39
  env:
25
40
  COVERAGE: ${{ matrix.coverage }}
26
41
  steps:
27
- - uses: actions/checkout@v2
42
+ - uses: actions/checkout@v4
28
43
  - name: Install Ruby ${{ matrix.ruby }}
29
44
  uses: ruby/setup-ruby@v1
30
45
  with:
@@ -35,4 +50,13 @@ jobs:
35
50
  - name: Test against Puppet component versions
36
51
  run: bundle exec rake puppet_versions:test
37
52
  - name: Test gem build
38
- run: bundle exec rake build
53
+ run: gem build --strict --verbose *.gemspec
54
+
55
+ tests:
56
+ needs:
57
+ - rubocop
58
+ - test
59
+ runs-on: ubuntu-latest
60
+ name: Test suite
61
+ steps:
62
+ - run: echo Test suite completed
data/.rubocop.yml ADDED
@@ -0,0 +1,16 @@
1
+ ---
2
+ inherit_from: .rubocop_todo.yml
3
+
4
+ inherit_gem:
5
+ voxpupuli-rubocop: rubocop.yml
6
+
7
+ Style:
8
+ Enabled: false
9
+
10
+ Layout:
11
+ Enabled: false
12
+
13
+ # To match the gem name
14
+ Naming/FileName:
15
+ Exclude:
16
+ - 'lib/rspec-puppet-facts.rb'
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,76 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2023-07-06 14:12:32 UTC using RuboCop version 1.50.2.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 1
10
+ # This cop supports unsafe autocorrection (--autocorrect-all).
11
+ Performance/MapCompact:
12
+ Exclude:
13
+ - 'lib/rspec-puppet-facts.rb'
14
+
15
+ # Offense count: 32
16
+ # Configuration parameters: Prefixes, AllowedPatterns.
17
+ # Prefixes: when, with, without
18
+ RSpec/ContextWording:
19
+ Exclude:
20
+ - 'spec/rspec_puppet_facts_spec.rb'
21
+
22
+ # Offense count: 7
23
+ # Configuration parameters: CountAsOne.
24
+ RSpec/ExampleLength:
25
+ Max: 13
26
+
27
+ # Offense count: 1
28
+ RSpec/ExpectInHook:
29
+ Exclude:
30
+ - 'spec/rspec_puppet_facts_spec.rb'
31
+
32
+ # Offense count: 20
33
+ # This cop supports safe autocorrection (--autocorrect).
34
+ # Configuration parameters: EnforcedStyle.
35
+ # SupportedStyles: single_line_only, single_statement_only, disallow, require_implicit
36
+ RSpec/ImplicitSubject:
37
+ Exclude:
38
+ - 'spec/rspec_puppet_facts_spec.rb'
39
+
40
+ # Offense count: 4
41
+ RSpec/LeakyConstantDeclaration:
42
+ Exclude:
43
+ - 'spec/rspec_puppet_facts_spec.rb'
44
+
45
+ # Offense count: 7
46
+ # Configuration parameters: .
47
+ # SupportedStyles: have_received, receive
48
+ RSpec/MessageSpies:
49
+ EnforcedStyle: receive
50
+
51
+ # Offense count: 4
52
+ RSpec/MultipleExpectations:
53
+ Max: 2
54
+
55
+ # Offense count: 46
56
+ # Configuration parameters: EnforcedStyle, IgnoreSharedExamples.
57
+ # SupportedStyles: always, named_only
58
+ RSpec/NamedSubject:
59
+ Exclude:
60
+ - 'spec/rspec_puppet_facts_spec.rb'
61
+
62
+ # Offense count: 14
63
+ # Configuration parameters: AllowedGroups.
64
+ RSpec/NestedGroups:
65
+ Max: 6
66
+
67
+ # Offense count: 1
68
+ RSpec/StubbedMock:
69
+ Exclude:
70
+ - 'spec/rspec_puppet_facts_spec.rb'
71
+
72
+ # Offense count: 2
73
+ # This cop supports safe autocorrection (--autocorrect).
74
+ Rake/Desc:
75
+ Exclude:
76
+ - 'Rakefile'
data/CHANGELOG.md CHANGED
@@ -1,5 +1,63 @@
1
1
  # Changelog
2
2
 
3
+ ## [3.0.0](https://github.com/voxpupuli/rspec-puppet-facts/tree/3.0.0) (2024-03-23)
4
+
5
+ [Full Changelog](https://github.com/voxpupuli/rspec-puppet-facts/compare/2.0.5...3.0.0)
6
+
7
+ **symbolized facts deprecation**
8
+
9
+ With the release of rspec-puppet-facts 4.0.0 we will remove support for symbolized facts. At the moment people typically use this in their unit files:
10
+
11
+ ```ruby
12
+ case facts[:os]['name']
13
+ when 'Archlinux'
14
+ context 'on Archlinux' do
15
+ it { is_expected.to contain_package('borg') }
16
+ end
17
+ when 'Ubuntu'
18
+ ```
19
+
20
+ For history reasons the first level of facts were symbols. You will have to update it to strings with the 4.0.0 release:
21
+
22
+ ```ruby
23
+ case facts['os']['name']
24
+ when 'Archlinux'
25
+ context 'on Archlinux' do
26
+ it { is_expected.to contain_package('borg') }
27
+ end
28
+ when 'Ubuntu'
29
+ ```
30
+
31
+
32
+ **Breaking changes:**
33
+
34
+ - Use facterdb\_string\_keys configuration option for custom facts [\#157](https://github.com/voxpupuli/rspec-puppet-facts/pull/157) ([jordanbreen28](https://github.com/jordanbreen28))
35
+ - Do not query for the exact facter version [\#151](https://github.com/voxpupuli/rspec-puppet-facts/pull/151) ([ekohl](https://github.com/ekohl))
36
+ - Drop Ruby 2.4/2.5/2.6 support [\#149](https://github.com/voxpupuli/rspec-puppet-facts/pull/149) ([bastelfreak](https://github.com/bastelfreak))
37
+
38
+ **Implemented enhancements:**
39
+
40
+ - Add Ruby 3.3 support [\#169](https://github.com/voxpupuli/rspec-puppet-facts/pull/169) ([bastelfreak](https://github.com/bastelfreak))
41
+ - gemspec: Add version constraints & CI: Build gem in strict mode [\#165](https://github.com/voxpupuli/rspec-puppet-facts/pull/165) ([bastelfreak](https://github.com/bastelfreak))
42
+ - update puppet agent components [\#164](https://github.com/voxpupuli/rspec-puppet-facts/pull/164) ([bastelfreak](https://github.com/bastelfreak))
43
+ - Add merge facts option to add\_custom\_fact [\#160](https://github.com/voxpupuli/rspec-puppet-facts/pull/160) ([jordanbreen28](https://github.com/jordanbreen28))
44
+ - Collect facts iteratively [\#152](https://github.com/voxpupuli/rspec-puppet-facts/pull/152) ([ekohl](https://github.com/ekohl))
45
+ - Use Hash.to\_h to construct a new hash [\#150](https://github.com/voxpupuli/rspec-puppet-facts/pull/150) ([ekohl](https://github.com/ekohl))
46
+ - Add Ruby 3.2 support [\#148](https://github.com/voxpupuli/rspec-puppet-facts/pull/148) ([bastelfreak](https://github.com/bastelfreak))
47
+
48
+ **Merged pull requests:**
49
+
50
+ - Update voxpupuli-rubocop requirement from ~\> 2.4.0 to ~\> 2.6.0 [\#168](https://github.com/voxpupuli/rspec-puppet-facts/pull/168) ([dependabot[bot]](https://github.com/apps/dependabot))
51
+ - github\_changelog\_generator: Apply best practices [\#163](https://github.com/voxpupuli/rspec-puppet-facts/pull/163) ([bastelfreak](https://github.com/bastelfreak))
52
+ - Gemfile: Add faraday as github\_changelog\_generator dep [\#162](https://github.com/voxpupuli/rspec-puppet-facts/pull/162) ([bastelfreak](https://github.com/bastelfreak))
53
+ - voxpupuli-rubocop: Pin to patch version [\#161](https://github.com/voxpupuli/rspec-puppet-facts/pull/161) ([bastelfreak](https://github.com/bastelfreak))
54
+ - Update voxpupuli-rubocop requirement from ~\> 1.3 to ~\> 2.0 [\#156](https://github.com/voxpupuli/rspec-puppet-facts/pull/156) ([dependabot[bot]](https://github.com/apps/dependabot))
55
+ - CI: add dummy job to depend on [\#155](https://github.com/voxpupuli/rspec-puppet-facts/pull/155) ([bastelfreak](https://github.com/bastelfreak))
56
+ - migrate to voxpupuli-rubocop [\#154](https://github.com/voxpupuli/rspec-puppet-facts/pull/154) ([bastelfreak](https://github.com/bastelfreak))
57
+ - Update rubocop requirement from ~\> 1.48.1 to ~\> 1.54.1 [\#153](https://github.com/voxpupuli/rspec-puppet-facts/pull/153) ([dependabot[bot]](https://github.com/apps/dependabot))
58
+ - Introduce RuboCop and fix various cops [\#146](https://github.com/voxpupuli/rspec-puppet-facts/pull/146) ([ekohl](https://github.com/ekohl))
59
+ - Update puppet agent components [\#145](https://github.com/voxpupuli/rspec-puppet-facts/pull/145) ([bastelfreak](https://github.com/bastelfreak))
60
+
3
61
  ## [2.0.5](https://github.com/voxpupuli/rspec-puppet-facts/tree/2.0.5) (2022-04-22)
4
62
 
5
63
  [Full Changelog](https://github.com/voxpupuli/rspec-puppet-facts/compare/2.0.4...2.0.5)
data/Gemfile CHANGED
@@ -2,17 +2,14 @@ source ENV['GEM_SOURCE'] || 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
4
 
5
- if facterversion = ENV['FACTER_GEM_VERSION']
6
- gem 'facter', facterversion, :require => false
7
- else
8
- gem 'facter', :require => false
9
- end
5
+ gem 'facter', ENV['FACTER_GEM_VERSION'], :require => false
10
6
 
11
7
  group :release do
12
- gem 'github_changelog_generator', require: false
8
+ gem 'faraday-retry', '~> 2.1', require: false
9
+ gem 'github_changelog_generator', '~> 1.16.4', require: false
13
10
  end
14
11
 
15
12
  group :coverage, optional: ENV['COVERAGE']!='yes' do
16
- gem 'simplecov-console', :require => false
17
13
  gem 'codecov', :require => false
14
+ gem 'simplecov-console', :require => false
18
15
  end
data/README.md CHANGED
@@ -10,7 +10,7 @@ rspec-puppet-facts
10
10
  [![Donated by Camptocamp](https://img.shields.io/badge/donated%20by-camptocamp-fb7047.svg)](#transfer-notice)
11
11
 
12
12
  Based on an original idea from [apenney](https://github.com/apenney/puppet_facts/),
13
- this gem provides a method of running your [rspec-puppet](https://github.com/rodjek/rspec-puppet)
13
+ this gem provides a method of running your [rspec-puppet](https://github.com/puppetlabs/rspec-puppet)
14
14
  tests against the facts for all your supported operating systems (provided by
15
15
  [facterdb](https://github.com/voxpupuli/facterdb)).
16
16
  This simplifies unit testing because you don't need to specify the facts yourself.
@@ -443,6 +443,28 @@ To do this, pass a lambda as the value for the custom fact. The lambda is passed
443
443
  add_custom_fact :root_home, lambda { |os,facts| "/tmp/#{facts['hostname']}" }
444
444
  ```
445
445
 
446
+ #### Merge into existing facts
447
+
448
+ You can also supply an optional input `:merge_facts` to the `add_custom_fact` method.
449
+
450
+ This allows you to merge facts values into a fact, if the fact is already present in the facts hash as oppose to overwriting the fact value.
451
+
452
+ ```ruby
453
+ add_custom_fact :identity, { 'user' => 'test_user' }, merge_facts: true
454
+ ```
455
+
456
+ Will result in a hash of the identity fact like the below:
457
+
458
+ ```ruby
459
+ {
460
+ "gid"=>0,
461
+ "group"=>"root",
462
+ "privileged"=>true,
463
+ "uid"=>0,
464
+ "user"=>"test_user"
465
+ }
466
+ ```
467
+
446
468
  ### Supplying Custom External Facts through FacterDB
447
469
  Rspec-puppet-facts uses a gem called facterdb that contains many fact sets of various combinations that are pre generated. Rspec-puppet-facts queries
448
470
  facterdb to pull out a specific fact set to use when testing.
@@ -510,7 +532,7 @@ ENV['FACTERDB_SEARCH_PATHS'] = custom_facts
510
532
  ```
511
533
  ## Running your tests
512
534
 
513
- For most cases, there is no change to how you run your tests. Running `rake spec` will run all the tests against the facts for all the supported operating systems. If you are developing a module using the [Puppet Development Kit](https://puppet.com/docs/pdk/1.x/pdk_install.html), `pdk test unit` will run all your tests against the supported operating systems listed in `metadata.json`.
535
+ For most cases, there is no change to how you run your tests. Running `rake spec` will run all the tests against the facts for all the supported operating systems. If you are developing a module using the [Puppet Development Kit](https://puppet.com/docs/pdk/3.x/pdk_install.html), `pdk test unit` will run all your tests against the supported operating systems listed in `metadata.json`.
514
536
 
515
537
  If you want to run the tests against the facts for specific operating systems, you can provide a filter in the `SPEC_FACTS_OS` environment variable and only the supported operating systems whose name starts with the specified filter will be used.
516
538
 
data/Rakefile CHANGED
@@ -1,5 +1,3 @@
1
- require 'bundler/gem_tasks'
2
-
3
1
  PUPPET_VERSIONS_PATH = File.join(__dir__, 'ext', 'puppet_agent_components.json')
4
2
 
5
3
  begin
@@ -8,6 +6,7 @@ begin
8
6
  RSpec::Core::RakeTask.new(:spec)
9
7
  YARD::Rake::YardocTask.new
10
8
  rescue LoadError
9
+ # yard is optional
11
10
  end
12
11
 
13
12
  desc 'Produce Commit history since last tag'
@@ -49,15 +48,22 @@ namespace :puppet_versions do
49
48
  end
50
49
 
51
50
  begin
52
- require 'rubygems'
53
51
  require 'github_changelog_generator/task'
54
-
52
+ rescue LoadError
53
+ # github_changelog_generator is an optional group
54
+ else
55
+ require 'rubygems'
55
56
  GitHubChangelogGenerator::RakeTask.new :changelog do |config|
56
- config.exclude_labels = %w{duplicate question invalid wontfix wont-fix skip-changelog}
57
+ config.exclude_labels = %w{duplicate question invalid wontfix wont-fix skip-changelog github_actions}
57
58
  config.user = 'voxpupuli'
58
59
  config.project = 'rspec-puppet-facts'
59
60
  gem_version = Gem::Specification.load("#{config.project}.gemspec").version
60
61
  config.future_release = gem_version
61
62
  end
63
+ end
64
+
65
+ begin
66
+ require 'voxpupuli/rubocop/rake'
62
67
  rescue LoadError
68
+ # the voxpupuli-rubocop gem is optional
63
69
  end