voxpupuli-test 13.2.0 → 15.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: faeae0f342ac61d23fe3ce32cf98619b893412832ac3092a02d3f02b09a4a0dd
4
- data.tar.gz: d269e93057980c6f8de427184af40f2b644553fc671126951b48b860d65696f7
3
+ metadata.gz: 9baef4ad6c44c840232ce31f3a50f1f9df2bcc74e6f5328e9326cb3e573b4d5d
4
+ data.tar.gz: '059f4f301334843412b89c5fae8661bd73391a054967fa242148c882f1fe6053'
5
5
  SHA512:
6
- metadata.gz: aa94ef8506d9acdff6039fc6bc0106a094fea9b3508bd62089bd66b3463273597fb8057526fc747bf3d0522e0fb22ba1e10c666f560ac5fed8f2c17532bf4fb2
7
- data.tar.gz: 4bf3580b0456dbb59b98a8cb7c0ecf7154efe83b13ac725bbf44a7c88efd06603ae0d1382536db6a52cd92e4aae4add7cd05354fd3c1fdde875621b8be73e726
6
+ metadata.gz: d6e97e07aa6c82ec706730423e21ab6e9ac2dd0b417fa0c438aa736e017f2f35d8d64a870c0a9776b93ed1b4c4f85f85ea932b7470fc9af18f38014a892c6bd3
7
+ data.tar.gz: 01365a55df6996d99bda1a08fa3d9ee6c2ab70c865a0f31ec515bf92f6c496387243f06c901761bece9d46f5e07ba52aa7bc1abe087fca4f1a852ba5cdbf86ee
data/README.md CHANGED
@@ -74,6 +74,12 @@ To autocorrect Ruby files:
74
74
  bundle exec rake rubocop:autocorrect
75
75
  ```
76
76
 
77
+ To generate or refresh a `.rubocop_todo.yml` file:
78
+
79
+ ```sh
80
+ bundle exec rake rubocop:regenerate_todo
81
+ ```
82
+
77
83
  ## Rake tasks
78
84
 
79
85
  ### `check:trailing_whitespace`
@@ -107,6 +113,21 @@ The tasks that currently support this feature include `lint` and `rubocop`.
107
113
 
108
114
  Note that if multiple tasks all attempt to output CodeClimate reports in a single rake call, then only the final task will be able store its report.
109
115
 
116
+ ## Shared examples
117
+
118
+ Shared examples are provided for things that are easy to get wrong in a custom type or provider.
119
+ They are opt-in, so add the ones that apply to your type:
120
+
121
+ ```ruby
122
+ require 'spec_helper'
123
+
124
+ describe Puppet::Type.type(:mytool_config) do
125
+ it_behaves_like 'a type that works with `puppet generate types`'
126
+ end
127
+ ```
128
+
129
+ See [`lib/voxpupuli/test/shared_examples/`](lib/voxpupuli/test/shared_examples) for what is available.
130
+
110
131
  ## Fact handling
111
132
 
112
133
  The recommended method is using [rspec-puppet-facts](https://github.com/mcanevet/rspec-puppet-facts) and is set up by default. This means the tests are writting as follows:
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'rubocop/rake_task'
4
+
4
5
  RuboCop::RakeTask.new(:rubocop) do |task|
5
6
  # These make the rubocop experience maybe slightly less terrible
6
7
  task.options = ['--debug', '--display-style-guide', '--extra-details']
@@ -19,3 +20,15 @@ RuboCop::RakeTask.new(:rubocop) do |task|
19
20
  task.options += ['--format', 'CodeclimateFormatter', '--out', ENV['CODECLIMATE_REPORT_FILE']]
20
21
  end
21
22
  end
23
+
24
+ namespace :rubocop do
25
+ # Do not use the `RuboCop::RakeTask` here, because it also adds the autocorrect tasks again.
26
+ desc 'Generate or refresh the RuboCop TODO file'
27
+ task :regenerate_todo do
28
+ require 'rubocop/cli'
29
+
30
+ status = RuboCop::CLI.new.run(%w[--regenerate-todo --no-auto-gen-timestamp])
31
+
32
+ abort "RuboCop failed with status #{status}" unless status.zero?
33
+ end
34
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Shared examples for the providers of custom types.
4
+ #
5
+ # describe Puppet::Type.type(:my_type).provider(:my_provider) do
6
+ # it_behaves_like 'a documented provider'
7
+ # end
8
+
9
+ # A provider's `desc` ends up in REFERENCE.md, like a type's.
10
+ RSpec.shared_examples 'a documented provider' do
11
+ it 'has documentation' do
12
+ expect(described_class.doc.to_s.strip).not_to be_empty
13
+ end
14
+ end
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'puppet/generate/models/type/type'
4
+
5
+ # Shared examples for custom types.
6
+ #
7
+ # describe Puppet::Type.type(:my_type) do
8
+ # it_behaves_like 'a type that works with `puppet generate types`'
9
+ # it_behaves_like 'a documented type'
10
+ # it_behaves_like 'an ensurable type'
11
+ # end
12
+
13
+ # `puppet generate types` accepts less than `Puppet::Type` does, and a module
14
+ # only finds out when an r10k deployment using `--generate-types` fails.
15
+ RSpec.shared_examples 'a type that works with `puppet generate types`' do
16
+ it 'does not raise an error' do
17
+ expect { Puppet::Generate::Models::Type::Type.new(described_class) }.not_to raise_error
18
+ end
19
+ end
20
+
21
+ # Anything undocumented here is an empty entry in REFERENCE.md.
22
+ RSpec.shared_examples 'a documented type' do
23
+ it 'has documentation' do
24
+ expect(described_class.doc.to_s.strip).not_to be_empty
25
+ end
26
+
27
+ it 'documents all parameters and properties' do
28
+ attributes = described_class.validproperties + described_class.parameters
29
+
30
+ undocumented = attributes.reject do |name|
31
+ klass = described_class.attrclass(name) || described_class.paramclass(name)
32
+ klass && !klass.doc.to_s.strip.empty?
33
+ end
34
+
35
+ expect(undocumented).to be_empty
36
+ end
37
+ end
38
+
39
+ # For types that manage a thing that can be created and removed. Types that use
40
+ # `ensure` for something else, e.g. `[:purgable, :purged]`, don't want this.
41
+ RSpec.shared_examples 'an ensurable type' do
42
+ it 'is ensurable' do
43
+ expect(described_class.propertybyname(:ensure)).not_to be_nil
44
+ end
45
+
46
+ it 'supports present and absent' do
47
+ values = described_class.propertybyname(:ensure)&.value_collection&.values
48
+
49
+ expect(values).to include(:present, :absent)
50
+ end
51
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'shared_examples/types'
4
+ require_relative 'shared_examples/providers'
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'voxpupuli/test/facts'
4
+ require 'voxpupuli/test/shared_examples'
4
5
  require 'rspec-puppet'
5
6
 
6
7
  spec_path = File.expand_path(File.join(Dir.pwd, 'spec'))
data/rubocop.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  # This is a shared config for easy consumption in other modules, without having
2
2
  # to sync over a large file
3
- require:
3
+ plugins:
4
4
  - rubocop-rspec
5
5
  - rubocop-rake
6
6
 
@@ -280,7 +280,7 @@ Style/PreferredHashMethods:
280
280
  Enabled: True
281
281
 
282
282
  Layout/DotPosition:
283
- EnforcedStyle: trailing
283
+ EnforcedStyle: leading
284
284
 
285
285
  Style/DoubleNegation:
286
286
  Enabled: True
@@ -333,12 +333,14 @@ Style/StringLiterals:
333
333
 
334
334
  Style/TrailingCommaInArguments:
335
335
  Enabled: True
336
+ EnforcedStyleForMultiline: comma
336
337
 
337
338
  Style/TrailingCommaInArrayLiteral:
338
- Enabled: False
339
+ Enabled: True
340
+ EnforcedStyleForMultiline: consistent_comma
339
341
 
340
342
  Style/TrailingCommaInHashLiteral:
341
- Enabled: False
343
+ EnforcedStyleForMultiline: consistent_comma
342
344
 
343
345
  Style/GlobalVars:
344
346
  Enabled: True
@@ -445,10 +447,13 @@ Style/PercentLiteralDelimiters:
445
447
  Style/PerlBackrefs:
446
448
  Enabled: True
447
449
 
448
- Naming/PredicateName:
450
+ Naming/PredicatePrefix:
449
451
  Enabled: True
450
452
  AllowedMethods: ['is_a?', 'is_to_s']
451
453
 
454
+ Naming/PredicateMethod:
455
+ Enabled: false
456
+
452
457
  Style/RedundantException:
453
458
  Enabled: True
454
459
 
@@ -496,6 +501,9 @@ Style/Encoding:
496
501
  Style/BlockDelimiters:
497
502
  Enabled: True
498
503
 
504
+ Style/TernaryParentheses:
505
+ EnforcedStyle: require_parentheses_when_complex
506
+
499
507
  Layout/MultilineBlockLayout:
500
508
  Enabled: True
501
509
 
@@ -557,9 +565,13 @@ Style/FormatStringToken:
557
565
 
558
566
  # This is useful, but sometimes a little too picky about where unit tests files
559
567
  # are located.
560
- RSpec/FilePath:
568
+ # old cop: RSpec/FilePath
569
+ RSpec/SpecFilePathFormat:
561
570
  Enabled: false
562
571
 
572
+ RSpec/SpecFilePathSuffix:
573
+ Enabled: true
574
+
563
575
  # Leaving these enabled creates too much busy work
564
576
  RSpec/ContextWording:
565
577
  Enabled: false
@@ -662,8 +674,6 @@ RSpec/IdenticalEqualityAssertion: # new in 2.4
662
674
  Enabled: true
663
675
  RSpec/SubjectDeclaration: # new in 2.5
664
676
  Enabled: true
665
- RSpec/Rails/AvoidSetupHook: # new in 2.4
666
- Enabled: true
667
677
  RSpec/ImplicitSubject:
668
678
  Enabled: false
669
679
  # new configurations since rubocop 1.50.0
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: voxpupuli-test
3
3
  version: !ruby/object:Gem::Version
4
- version: 13.2.0
4
+ version: 15.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vox Pupuli
@@ -78,7 +78,7 @@ dependencies:
78
78
  version: '5.0'
79
79
  - - "<"
80
80
  - !ruby/object:Gem::Version
81
- version: '7'
81
+ version: '8'
82
82
  type: :runtime
83
83
  prerelease: false
84
84
  version_requirements: !ruby/object:Gem::Requirement
@@ -88,7 +88,7 @@ dependencies:
88
88
  version: '5.0'
89
89
  - - "<"
90
90
  - !ruby/object:Gem::Version
91
- version: '7'
91
+ version: '8'
92
92
  - !ruby/object:Gem::Dependency
93
93
  name: parallel_tests
94
94
  requirement: !ruby/object:Gem::Requirement
@@ -173,16 +173,22 @@ dependencies:
173
173
  name: rspec-puppet
174
174
  requirement: !ruby/object:Gem::Requirement
175
175
  requirements:
176
- - - "~>"
176
+ - - ">="
177
177
  - !ruby/object:Gem::Version
178
- version: '5.0'
178
+ version: '5'
179
+ - - "<"
180
+ - !ruby/object:Gem::Version
181
+ version: '7'
179
182
  type: :runtime
180
183
  prerelease: false
181
184
  version_requirements: !ruby/object:Gem::Requirement
182
185
  requirements:
183
- - - "~>"
186
+ - - ">="
184
187
  - !ruby/object:Gem::Version
185
- version: '5.0'
188
+ version: '5'
189
+ - - "<"
190
+ - !ruby/object:Gem::Version
191
+ version: '7'
186
192
  - !ruby/object:Gem::Dependency
187
193
  name: rspec-puppet-facts
188
194
  requirement: !ruby/object:Gem::Requirement
@@ -207,58 +213,70 @@ dependencies:
207
213
  name: syslog
208
214
  requirement: !ruby/object:Gem::Requirement
209
215
  requirements:
210
- - - "~>"
216
+ - - ">="
217
+ - !ruby/object:Gem::Version
218
+ version: '0.3'
219
+ - - "<"
211
220
  - !ruby/object:Gem::Version
212
- version: 0.3.0
221
+ version: '0.5'
213
222
  type: :runtime
214
223
  prerelease: false
215
224
  version_requirements: !ruby/object:Gem::Requirement
216
225
  requirements:
217
- - - "~>"
226
+ - - ">="
227
+ - !ruby/object:Gem::Version
228
+ version: '0.3'
229
+ - - "<"
218
230
  - !ruby/object:Gem::Version
219
- version: 0.3.0
231
+ version: '0.5'
220
232
  - !ruby/object:Gem::Dependency
221
233
  name: rubocop
222
234
  requirement: !ruby/object:Gem::Requirement
223
235
  requirements:
224
236
  - - "~>"
225
237
  - !ruby/object:Gem::Version
226
- version: 1.50.0
238
+ version: 1.91.0
227
239
  type: :runtime
228
240
  prerelease: false
229
241
  version_requirements: !ruby/object:Gem::Requirement
230
242
  requirements:
231
243
  - - "~>"
232
244
  - !ruby/object:Gem::Version
233
- version: 1.50.0
245
+ version: 1.91.0
234
246
  - !ruby/object:Gem::Dependency
235
247
  name: rubocop-rake
236
248
  requirement: !ruby/object:Gem::Requirement
237
249
  requirements:
238
250
  - - "~>"
239
251
  - !ruby/object:Gem::Version
240
- version: 0.6.0
252
+ version: 0.7.1
241
253
  type: :runtime
242
254
  prerelease: false
243
255
  version_requirements: !ruby/object:Gem::Requirement
244
256
  requirements:
245
257
  - - "~>"
246
258
  - !ruby/object:Gem::Version
247
- version: 0.6.0
259
+ version: 0.7.1
248
260
  - !ruby/object:Gem::Dependency
249
261
  name: rubocop-rspec
250
262
  requirement: !ruby/object:Gem::Requirement
251
263
  requirements:
252
- - - "~>"
264
+ - - ">="
265
+ - !ruby/object:Gem::Version
266
+ version: '3.9'
267
+ - - "<"
253
268
  - !ruby/object:Gem::Version
254
- version: 2.20.0
269
+ version: '3.11'
255
270
  type: :runtime
256
271
  prerelease: false
257
272
  version_requirements: !ruby/object:Gem::Requirement
258
273
  requirements:
259
- - - "~>"
274
+ - - ">="
275
+ - !ruby/object:Gem::Version
276
+ version: '3.9'
277
+ - - "<"
260
278
  - !ruby/object:Gem::Version
261
- version: 2.20.0
279
+ version: '3.11'
262
280
  - !ruby/object:Gem::Dependency
263
281
  name: voxpupuli-puppet-lint-plugins
264
282
  requirement: !ruby/object:Gem::Requirement
@@ -312,9 +330,12 @@ files:
312
330
  - lib/voxpupuli/test/rake/spec.rb
313
331
  - lib/voxpupuli/test/rake/validate.rb
314
332
  - lib/voxpupuli/test/rubocop_formatters/codeclimate.rb
333
+ - lib/voxpupuli/test/shared_examples.rb
334
+ - lib/voxpupuli/test/shared_examples/providers.rb
335
+ - lib/voxpupuli/test/shared_examples/types.rb
315
336
  - lib/voxpupuli/test/spec_helper.rb
316
337
  - rubocop.yml
317
- homepage: http://github.com/voxpupuli/voxpupuli-test
338
+ homepage: https://github.com/voxpupuli/voxpupuli-test
318
339
  licenses:
319
340
  - Apache-2.0
320
341
  metadata: {}
@@ -332,7 +353,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
332
353
  - !ruby/object:Gem::Version
333
354
  version: '0'
334
355
  requirements: []
335
- rubygems_version: 3.6.9
356
+ rubygems_version: 4.0.20
336
357
  specification_version: 4
337
358
  summary: Helpers for testing Vox Pupuli modules
338
359
  test_files: []