voxpupuli-test 14.0.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 +4 -4
- data/README.md +21 -0
- data/lib/voxpupuli/test/rake/rubocop.rb +13 -0
- data/lib/voxpupuli/test/shared_examples/providers.rb +14 -0
- data/lib/voxpupuli/test/shared_examples/types.rb +51 -0
- data/lib/voxpupuli/test/shared_examples.rb +4 -0
- data/lib/voxpupuli/test/spec_helper.rb +1 -0
- metadata +27 -12
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9baef4ad6c44c840232ce31f3a50f1f9df2bcc74e6f5328e9326cb3e573b4d5d
|
|
4
|
+
data.tar.gz: '059f4f301334843412b89c5fae8661bd73391a054967fa242148c882f1fe6053'
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
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:
|
|
4
|
+
version: 15.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Vox Pupuli
|
|
@@ -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
|
|
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
|
|
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
|
|
@@ -229,14 +235,14 @@ dependencies:
|
|
|
229
235
|
requirements:
|
|
230
236
|
- - "~>"
|
|
231
237
|
- !ruby/object:Gem::Version
|
|
232
|
-
version: 1.
|
|
238
|
+
version: 1.91.0
|
|
233
239
|
type: :runtime
|
|
234
240
|
prerelease: false
|
|
235
241
|
version_requirements: !ruby/object:Gem::Requirement
|
|
236
242
|
requirements:
|
|
237
243
|
- - "~>"
|
|
238
244
|
- !ruby/object:Gem::Version
|
|
239
|
-
version: 1.
|
|
245
|
+
version: 1.91.0
|
|
240
246
|
- !ruby/object:Gem::Dependency
|
|
241
247
|
name: rubocop-rake
|
|
242
248
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -255,16 +261,22 @@ dependencies:
|
|
|
255
261
|
name: rubocop-rspec
|
|
256
262
|
requirement: !ruby/object:Gem::Requirement
|
|
257
263
|
requirements:
|
|
258
|
-
- - "
|
|
264
|
+
- - ">="
|
|
265
|
+
- !ruby/object:Gem::Version
|
|
266
|
+
version: '3.9'
|
|
267
|
+
- - "<"
|
|
259
268
|
- !ruby/object:Gem::Version
|
|
260
|
-
version: 3.
|
|
269
|
+
version: '3.11'
|
|
261
270
|
type: :runtime
|
|
262
271
|
prerelease: false
|
|
263
272
|
version_requirements: !ruby/object:Gem::Requirement
|
|
264
273
|
requirements:
|
|
265
|
-
- - "
|
|
274
|
+
- - ">="
|
|
275
|
+
- !ruby/object:Gem::Version
|
|
276
|
+
version: '3.9'
|
|
277
|
+
- - "<"
|
|
266
278
|
- !ruby/object:Gem::Version
|
|
267
|
-
version: 3.
|
|
279
|
+
version: '3.11'
|
|
268
280
|
- !ruby/object:Gem::Dependency
|
|
269
281
|
name: voxpupuli-puppet-lint-plugins
|
|
270
282
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -318,6 +330,9 @@ files:
|
|
|
318
330
|
- lib/voxpupuli/test/rake/spec.rb
|
|
319
331
|
- lib/voxpupuli/test/rake/validate.rb
|
|
320
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
|
|
321
336
|
- lib/voxpupuli/test/spec_helper.rb
|
|
322
337
|
- rubocop.yml
|
|
323
338
|
homepage: https://github.com/voxpupuli/voxpupuli-test
|
|
@@ -338,7 +353,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
338
353
|
- !ruby/object:Gem::Version
|
|
339
354
|
version: '0'
|
|
340
355
|
requirements: []
|
|
341
|
-
rubygems_version: 4.0.
|
|
356
|
+
rubygems_version: 4.0.20
|
|
342
357
|
specification_version: 4
|
|
343
358
|
summary: Helpers for testing Vox Pupuli modules
|
|
344
359
|
test_files: []
|