voxpupuli-test 1.5.0 → 2.2.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: a801b51dc95463b84662a0e9ac1aaef27f4bb17ed6c174d0c1ea7eec26949716
4
- data.tar.gz: 0c945dade95af255fa05468cbe35c1034f08a2d866bbc59bb4ed93a3c8a10eef
3
+ metadata.gz: 5c7da6bd0c182ed7ca73d10787b1b25fe1efcda71f1a2fad94f9e978699194fc
4
+ data.tar.gz: dbe2534a132bdddb6cca76012c7f3d066fc285c28aba98c7516035e658818c74
5
5
  SHA512:
6
- metadata.gz: e3595de63e7a3106b7a1f528b1bc88dc98026b73713c3e0de9d42728cc2fa17fb005aa0ba4d97d2fd0ac2b0064ec6f237e5a67ac998bcf19436430aeec2bf335
7
- data.tar.gz: a82b72aacafe50a821e0c3d48b07276b75b2c5d1baa81677f0bb2af45d026cb5bbf398292242024a8622541ff7c8c19c866aa41fa5435c58d6fdf78cbf22291f
6
+ metadata.gz: 7ded37c0fdd619b12575b7d7b8374896b4788b3927bed7592105b2917c961585a55786344f708db4db1fc7b470dc84f9e9ca1e6b8c5bd2ef82b1f0943cabc17a
7
+ data.tar.gz: 34a67d9d9835868e4ac4c7c68da131def85703a05a273aef0d5ac516cb14291f87b24d498d0df68c723bb2edd621a2267aa5567a4dc608b0c17c92b2e2d22b7f
@@ -1,3 +1,6 @@
1
+ require 'rspec-puppet-facts'
2
+ include RspecPuppetFacts
3
+
1
4
  # Override facts
2
5
  #
3
6
  # This doesn't use deep_merge because that's highly unpredictable. It can merge
@@ -32,3 +35,63 @@ def apply_overrides!(facts, overrides, enforce_strings)
32
35
  end
33
36
  end
34
37
  end
38
+
39
+ # Add mocked facts based on the metadata present in the module
40
+ #
41
+ # This means that for some module there are hardcoded mocks, such as stdlib.
42
+ # When stdlib is present in metadata.json, facts like service_provider are
43
+ # mocked and return the correct value according to the OS facts.
44
+ def add_mocked_facts!
45
+ add_facts_for_metadata(RspecPuppetFacts.metadata)
46
+ end
47
+
48
+ def add_facts_for_metadata(metadata)
49
+ return unless metadata && metadata['dependencies']
50
+
51
+ metadata['dependencies'].each do |dependency|
52
+ case normalize_module_name(dependency['name'])
53
+ when 'camptocamp/systemd'
54
+ add_custom_fact :systemd, ->(os, facts) { facts[:service_provider] == 'systemd' }
55
+ when 'puppetlabs/stdlib'
56
+ add_stdlib_facts
57
+ end
58
+ end
59
+ end
60
+
61
+ def normalize_module_name(name)
62
+ return unless name
63
+ name.sub('-', '/')
64
+ end
65
+
66
+ def add_stdlib_facts
67
+ add_custom_fact :puppet_environmentpath, '/etc/puppetlabs/code/environments'
68
+ add_custom_fact :puppet_vardir, '/opt/puppetlabs/puppet/cache'
69
+ add_custom_fact :root_home, '/root'
70
+
71
+ # Rough conversion of grepping in the puppet source:
72
+ # grep defaultfor lib/puppet/provider/service/*.rb
73
+ add_custom_fact :service_provider, ->(os, facts) do
74
+ case facts[:osfamily].downcase
75
+ when 'archlinux'
76
+ 'systemd'
77
+ when 'darwin'
78
+ 'launchd'
79
+ when 'debian'
80
+ 'systemd'
81
+ when 'freebsd'
82
+ 'freebsd'
83
+ when 'gentoo'
84
+ 'openrc'
85
+ when 'openbsd'
86
+ 'openbsd'
87
+ when 'redhat'
88
+ facts[:operatingsystemrelease].to_i >= 7 ? 'systemd' : 'redhat'
89
+ when 'suse'
90
+ facts[:operatingsystemmajrelease].to_i >= 12 ? 'systemd' : 'redhat'
91
+ when 'windows'
92
+ 'windows'
93
+ else
94
+ 'init'
95
+ end
96
+ end
97
+ end
@@ -26,8 +26,6 @@ end
26
26
 
27
27
  require 'voxpupuli/test/facts'
28
28
  require 'puppetlabs_spec_helper/module_spec_helper'
29
- require 'rspec-puppet-facts'
30
- include RspecPuppetFacts
31
29
 
32
30
  # Generating facts is slow - this memoizes the facts between multiple classes.
33
31
  # Marshalling is used to get unique instances which helps when tests overrides
@@ -0,0 +1,555 @@
1
+ # This is a shared config for easy consumption in other modules, without having
2
+ # to sync over a large file
3
+ require: rubocop-rspec
4
+
5
+ AllCops:
6
+ # Puppet Server 5 defaults to jruby 1.7 so TargetRubyVersion must stay at 1.9 until we drop support for puppet 5
7
+ TargetRubyVersion: 1.9
8
+ Include:
9
+ - ./**/*.rb
10
+ Exclude:
11
+ - files/**/*
12
+ - vendor/**/*
13
+ - .vendor/**/*
14
+ - pkg/**/*
15
+ - spec/fixtures/**/*
16
+ - Gemfile
17
+ - Rakefile
18
+ - Guardfile
19
+ - Vagrantfile
20
+
21
+ Lint/ConditionPosition:
22
+ Enabled: True
23
+
24
+ Lint/ElseLayout:
25
+ Enabled: True
26
+
27
+ Lint/UnreachableCode:
28
+ Enabled: True
29
+
30
+ Lint/UselessComparison:
31
+ Enabled: True
32
+
33
+ Lint/EnsureReturn:
34
+ Enabled: True
35
+
36
+ Lint/HandleExceptions:
37
+ Enabled: True
38
+
39
+ Lint/LiteralInCondition:
40
+ Enabled: True
41
+
42
+ Lint/ShadowingOuterLocalVariable:
43
+ Enabled: True
44
+
45
+ Lint/LiteralInInterpolation:
46
+ Enabled: True
47
+
48
+ Style/HashSyntax:
49
+ Enabled: True
50
+
51
+ Style/RedundantReturn:
52
+ Enabled: True
53
+
54
+ Layout/EndOfLine:
55
+ Enabled: False
56
+
57
+ Lint/AmbiguousOperator:
58
+ Enabled: True
59
+
60
+ Lint/AssignmentInCondition:
61
+ Enabled: True
62
+
63
+ Layout/SpaceBeforeComment:
64
+ Enabled: True
65
+
66
+ Style/AndOr:
67
+ Enabled: True
68
+
69
+ Style/RedundantSelf:
70
+ Enabled: True
71
+
72
+ Metrics/BlockLength:
73
+ Enabled: False
74
+
75
+ # Method length is not necessarily an indicator of code quality
76
+ Metrics/MethodLength:
77
+ Enabled: False
78
+
79
+ # Module length is not necessarily an indicator of code quality
80
+ Metrics/ModuleLength:
81
+ Enabled: False
82
+
83
+ Style/WhileUntilModifier:
84
+ Enabled: True
85
+
86
+ Lint/AmbiguousRegexpLiteral:
87
+ Enabled: True
88
+
89
+ Security/Eval:
90
+ Enabled: True
91
+
92
+ Lint/BlockAlignment:
93
+ Enabled: True
94
+
95
+ Lint/DefEndAlignment:
96
+ Enabled: True
97
+
98
+ Lint/EndAlignment:
99
+ Enabled: True
100
+
101
+ Lint/DeprecatedClassMethods:
102
+ Enabled: True
103
+
104
+ Lint/Loop:
105
+ Enabled: True
106
+
107
+ Lint/ParenthesesAsGroupedExpression:
108
+ Enabled: True
109
+
110
+ Lint/RescueException:
111
+ Enabled: True
112
+
113
+ Lint/StringConversionInInterpolation:
114
+ Enabled: True
115
+
116
+ Lint/UnusedBlockArgument:
117
+ Enabled: True
118
+
119
+ Lint/UnusedMethodArgument:
120
+ Enabled: True
121
+
122
+ Lint/UselessAccessModifier:
123
+ Enabled: True
124
+
125
+ Lint/UselessAssignment:
126
+ Enabled: True
127
+
128
+ Lint/Void:
129
+ Enabled: True
130
+
131
+ Layout/AccessModifierIndentation:
132
+ Enabled: True
133
+
134
+ Style/AccessorMethodName:
135
+ Enabled: True
136
+
137
+ Style/Alias:
138
+ Enabled: True
139
+
140
+ Layout/AlignArray:
141
+ Enabled: True
142
+
143
+ Layout/AlignHash:
144
+ Enabled: True
145
+
146
+ Layout/AlignParameters:
147
+ Enabled: True
148
+
149
+ Metrics/BlockNesting:
150
+ Enabled: True
151
+
152
+ Style/AsciiComments:
153
+ Enabled: True
154
+
155
+ Style/Attr:
156
+ Enabled: True
157
+
158
+ Style/BracesAroundHashParameters:
159
+ Enabled: False
160
+
161
+ Style/CaseEquality:
162
+ Enabled: True
163
+
164
+ Style/TrailingCommaInArguments:
165
+ Enabled: False
166
+
167
+ Layout/CaseIndentation:
168
+ Enabled: True
169
+
170
+ Style/CharacterLiteral:
171
+ Enabled: True
172
+
173
+ Style/ClassAndModuleCamelCase:
174
+ Enabled: True
175
+
176
+ Style/ClassAndModuleChildren:
177
+ Enabled: False
178
+
179
+ Style/ClassCheck:
180
+ Enabled: True
181
+
182
+ # Class length is not necessarily an indicator of code quality
183
+ Metrics/ClassLength:
184
+ Enabled: False
185
+
186
+ Style/ClassMethods:
187
+ Enabled: True
188
+
189
+ Style/ClassVars:
190
+ Enabled: True
191
+
192
+ Style/WhenThen:
193
+ Enabled: True
194
+
195
+ Style/WordArray:
196
+ Enabled: True
197
+
198
+ Style/UnneededPercentQ:
199
+ Enabled: True
200
+
201
+ Layout/Tab:
202
+ Enabled: True
203
+
204
+ Layout/SpaceBeforeSemicolon:
205
+ Enabled: True
206
+
207
+ Layout/TrailingBlankLines:
208
+ Enabled: True
209
+
210
+ Layout/SpaceInsideBlockBraces:
211
+ Enabled: True
212
+
213
+ Layout/SpaceInsideBrackets:
214
+ Enabled: True
215
+
216
+ Layout/SpaceInsideHashLiteralBraces:
217
+ Enabled: True
218
+
219
+ Layout/SpaceInsideParens:
220
+ Enabled: True
221
+
222
+ Layout/LeadingCommentSpace:
223
+ Enabled: True
224
+
225
+ Layout/SpaceBeforeFirstArg:
226
+ Enabled: True
227
+
228
+ Layout/SpaceAfterColon:
229
+ Enabled: True
230
+
231
+ Layout/SpaceAfterComma:
232
+ Enabled: True
233
+
234
+ Layout/SpaceAfterMethodName:
235
+ Enabled: True
236
+
237
+ Layout/SpaceAfterNot:
238
+ Enabled: True
239
+
240
+ Layout/SpaceAfterSemicolon:
241
+ Enabled: True
242
+
243
+ Layout/SpaceAroundEqualsInParameterDefault:
244
+ Enabled: True
245
+
246
+ Layout/SpaceAroundOperators:
247
+ Enabled: True
248
+
249
+ Layout/SpaceBeforeBlockBraces:
250
+ Enabled: True
251
+
252
+ Layout/SpaceBeforeComma:
253
+ Enabled: True
254
+
255
+ Style/CollectionMethods:
256
+ Enabled: True
257
+
258
+ Layout/CommentIndentation:
259
+ Enabled: True
260
+
261
+ Style/ColonMethodCall:
262
+ Enabled: True
263
+
264
+ Style/CommentAnnotation:
265
+ Enabled: True
266
+
267
+ # 'Complexity' is very relative
268
+ Metrics/CyclomaticComplexity:
269
+ Enabled: False
270
+
271
+ Style/ConstantName:
272
+ Enabled: True
273
+
274
+ Style/Documentation:
275
+ Enabled: False
276
+
277
+ Style/DefWithParentheses:
278
+ Enabled: True
279
+
280
+ Style/PreferredHashMethods:
281
+ Enabled: True
282
+
283
+ Layout/DotPosition:
284
+ EnforcedStyle: trailing
285
+
286
+ Style/DoubleNegation:
287
+ Enabled: True
288
+
289
+ Style/EachWithObject:
290
+ Enabled: True
291
+
292
+ Layout/EmptyLineBetweenDefs:
293
+ Enabled: True
294
+
295
+ Layout/IndentArray:
296
+ Enabled: True
297
+
298
+ Layout/IndentHash:
299
+ Enabled: True
300
+
301
+ Layout/IndentationConsistency:
302
+ Enabled: True
303
+
304
+ Layout/IndentationWidth:
305
+ Enabled: True
306
+
307
+ Layout/EmptyLines:
308
+ Enabled: True
309
+
310
+ Layout/EmptyLinesAroundAccessModifier:
311
+ Enabled: True
312
+
313
+ Style/EmptyLiteral:
314
+ Enabled: True
315
+
316
+ # Configuration parameters: AllowURI, URISchemes.
317
+ Metrics/LineLength:
318
+ Enabled: False
319
+
320
+ Style/MethodCallWithoutArgsParentheses:
321
+ Enabled: True
322
+
323
+ Style/MethodDefParentheses:
324
+ Enabled: True
325
+
326
+ Style/LineEndConcatenation:
327
+ Enabled: True
328
+
329
+ Layout/TrailingWhitespace:
330
+ Enabled: True
331
+
332
+ Style/StringLiterals:
333
+ Enabled: True
334
+
335
+ Style/TrailingCommaInArguments:
336
+ Enabled: True
337
+
338
+ Style/TrailingCommaInLiteral:
339
+ Enabled: False
340
+
341
+ Style/GlobalVars:
342
+ Enabled: True
343
+
344
+ Style/GuardClause:
345
+ Enabled: True
346
+
347
+ Style/IfUnlessModifier:
348
+ Enabled: True
349
+
350
+ Style/MultilineIfThen:
351
+ Enabled: True
352
+
353
+ Style/NegatedIf:
354
+ Enabled: True
355
+
356
+ Style/NegatedWhile:
357
+ Enabled: True
358
+
359
+ Style/Next:
360
+ Enabled: True
361
+
362
+ Style/SingleLineBlockParams:
363
+ Enabled: True
364
+
365
+ Style/SingleLineMethods:
366
+ Enabled: True
367
+
368
+ Style/SpecialGlobalVars:
369
+ Enabled: True
370
+
371
+ Style/TrivialAccessors:
372
+ Enabled: True
373
+
374
+ Style/UnlessElse:
375
+ Enabled: True
376
+
377
+ Style/VariableInterpolation:
378
+ Enabled: True
379
+
380
+ Style/VariableName:
381
+ Enabled: True
382
+
383
+ Style/WhileUntilDo:
384
+ Enabled: True
385
+
386
+ Style/EvenOdd:
387
+ Enabled: True
388
+
389
+ Style/FileName:
390
+ Enabled: True
391
+
392
+ Style/For:
393
+ Enabled: True
394
+
395
+ Style/Lambda:
396
+ Enabled: True
397
+
398
+ Style/MethodName:
399
+ Enabled: True
400
+
401
+ Style/MultilineTernaryOperator:
402
+ Enabled: True
403
+
404
+ Style/NestedTernaryOperator:
405
+ Enabled: True
406
+
407
+ Style/NilComparison:
408
+ Enabled: True
409
+
410
+ Style/FormatString:
411
+ Enabled: True
412
+
413
+ Style/MultilineBlockChain:
414
+ Enabled: True
415
+
416
+ Style/Semicolon:
417
+ Enabled: True
418
+
419
+ Style/SignalException:
420
+ Enabled: True
421
+
422
+ Style/NonNilCheck:
423
+ Enabled: True
424
+
425
+ Style/Not:
426
+ Enabled: True
427
+
428
+ Style/NumericLiterals:
429
+ Enabled: True
430
+
431
+ Style/OneLineConditional:
432
+ Enabled: True
433
+
434
+ Style/OpMethod:
435
+ Enabled: True
436
+
437
+ Style/ParenthesesAroundCondition:
438
+ Enabled: True
439
+
440
+ Style/PercentLiteralDelimiters:
441
+ Enabled: True
442
+
443
+ Style/PerlBackrefs:
444
+ Enabled: True
445
+
446
+ Style/PredicateName:
447
+ Enabled: True
448
+
449
+ Style/RedundantException:
450
+ Enabled: True
451
+
452
+ Style/SelfAssignment:
453
+ Enabled: True
454
+
455
+ Style/Proc:
456
+ Enabled: True
457
+
458
+ Style/RaiseArgs:
459
+ Enabled: True
460
+
461
+ Style/RedundantBegin:
462
+ Enabled: True
463
+
464
+ Style/RescueModifier:
465
+ Enabled: True
466
+
467
+ # based on https://github.com/voxpupuli/modulesync_config/issues/168
468
+ Style/RegexpLiteral:
469
+ EnforcedStyle: percent_r
470
+ Enabled: True
471
+
472
+ Lint/UnderscorePrefixedVariableName:
473
+ Enabled: True
474
+
475
+ Metrics/ParameterLists:
476
+ Enabled: False
477
+
478
+ Lint/RequireParentheses:
479
+ Enabled: True
480
+
481
+ Style/ModuleFunction:
482
+ Enabled: True
483
+
484
+ Lint/Debugger:
485
+ Enabled: True
486
+
487
+ Style/IfWithSemicolon:
488
+ Enabled: True
489
+
490
+ Style/Encoding:
491
+ Enabled: True
492
+
493
+ Style/BlockDelimiters:
494
+ Enabled: True
495
+
496
+ Layout/MultilineBlockLayout:
497
+ Enabled: True
498
+
499
+ # 'Complexity' is very relative
500
+ Metrics/AbcSize:
501
+ Enabled: False
502
+
503
+ # 'Complexity' is very relative
504
+ Metrics/PerceivedComplexity:
505
+ Enabled: False
506
+
507
+ Lint/UselessAssignment:
508
+ Enabled: True
509
+
510
+ Layout/ClosingParenthesisIndentation:
511
+ Enabled: True
512
+
513
+ # RSpec
514
+
515
+ RSpec/BeforeAfterAll:
516
+ Exclude:
517
+ - spec/acceptance/**/*
518
+
519
+ # We don't use rspec in this way
520
+ RSpec/DescribeClass:
521
+ Enabled: False
522
+
523
+ # Example length is not necessarily an indicator of code quality
524
+ RSpec/ExampleLength:
525
+ Enabled: False
526
+
527
+ RSpec/NamedSubject:
528
+ Enabled: False
529
+
530
+ # disabled for now since they cause a lot of issues
531
+ # these issues aren't easy to fix
532
+ RSpec/RepeatedDescription:
533
+ Enabled: False
534
+
535
+ RSpec/NestedGroups:
536
+ Enabled: False
537
+
538
+ RSpec/MultipleExpectations:
539
+ Enabled: false
540
+
541
+ # this is broken on ruby1.9
542
+ Layout/IndentHeredoc:
543
+ Enabled: False
544
+
545
+ Security/YAMLLoad:
546
+ Enabled: True
547
+
548
+ # This affects hiera interpolation, as well as some configs that we push.
549
+ Style/FormatStringToken:
550
+ Enabled: false
551
+
552
+ # This is useful, but sometimes a little too picky about where unit tests files
553
+ # are located.
554
+ RSpec/FilePath:
555
+ Enabled: false
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.5.0
4
+ version: 2.2.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-06-27 00:00:00.000000000 Z
11
+ date: 2020-12-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -126,16 +126,16 @@ dependencies:
126
126
  name: rubocop-rspec
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - '='
129
+ - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: 1.15.0
131
+ version: 1.16.0
132
132
  type: :runtime
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - '='
136
+ - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: 1.15.0
138
+ version: 1.16.0
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: puppet-lint-absolute_classname-check
141
141
  requirement: !ruby/object:Gem::Requirement
@@ -290,6 +290,48 @@ dependencies:
290
290
  - - ">="
291
291
  - !ruby/object:Gem::Version
292
292
  version: '0'
293
+ - !ruby/object:Gem::Dependency
294
+ name: puppet-lint-manifest_whitespace-check
295
+ requirement: !ruby/object:Gem::Requirement
296
+ requirements:
297
+ - - ">="
298
+ - !ruby/object:Gem::Version
299
+ version: '0'
300
+ type: :runtime
301
+ prerelease: false
302
+ version_requirements: !ruby/object:Gem::Requirement
303
+ requirements:
304
+ - - ">="
305
+ - !ruby/object:Gem::Version
306
+ version: '0'
307
+ - !ruby/object:Gem::Dependency
308
+ name: puppet-lint-file_ensure-check
309
+ requirement: !ruby/object:Gem::Requirement
310
+ requirements:
311
+ - - ">="
312
+ - !ruby/object:Gem::Version
313
+ version: '0'
314
+ type: :runtime
315
+ prerelease: false
316
+ version_requirements: !ruby/object:Gem::Requirement
317
+ requirements:
318
+ - - ">="
319
+ - !ruby/object:Gem::Version
320
+ version: '0'
321
+ - !ruby/object:Gem::Dependency
322
+ name: puppet-lint-strict_indent-check
323
+ requirement: !ruby/object:Gem::Requirement
324
+ requirements:
325
+ - - ">="
326
+ - !ruby/object:Gem::Version
327
+ version: '0'
328
+ type: :runtime
329
+ prerelease: false
330
+ version_requirements: !ruby/object:Gem::Requirement
331
+ requirements:
332
+ - - ">="
333
+ - !ruby/object:Gem::Version
334
+ version: '0'
293
335
  - !ruby/object:Gem::Dependency
294
336
  name: rspec
295
337
  requirement: !ruby/object:Gem::Requirement
@@ -316,6 +358,7 @@ files:
316
358
  - lib/voxpupuli/test/facts.rb
317
359
  - lib/voxpupuli/test/rake.rb
318
360
  - lib/voxpupuli/test/spec_helper.rb
361
+ - rubocop.yml
319
362
  homepage: http://github.com/voxpupuli/voxpupuli-test
320
363
  licenses:
321
364
  - Apache-2.0
@@ -335,7 +378,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
335
378
  - !ruby/object:Gem::Version
336
379
  version: '0'
337
380
  requirements: []
338
- rubygems_version: 3.0.6
381
+ rubygems_version: 3.1.4
339
382
  signing_key:
340
383
  specification_version: 4
341
384
  summary: Helpers for testing Vox Pupuli modules