puppetlabs_spec_helper 1.1.1 → 2.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/.gitignore +9 -0
- data/.rspec +2 -0
- data/.rubocop.yml +504 -0
- data/.travis.yml +17 -6
- data/CHANGELOG.md +70 -4
- data/CONTRIBUTING.md +5 -46
- data/Gemfile +15 -9
- data/{README.markdown → README.md} +190 -65
- data/Rakefile +5 -40
- data/lib/puppetlabs_spec_helper/module_spec_helper.rb +2 -8
- data/lib/puppetlabs_spec_helper/puppetlabs_spec/puppet_internals.rb +2 -0
- data/lib/puppetlabs_spec_helper/rake_tasks.rb +175 -24
- data/lib/puppetlabs_spec_helper/version.rb +4 -1
- data/puppetlabs_spec_helper.gemspec +28 -83
- metadata +79 -54
- data/spec/lib/puppet/type/spechelper.rb +0 -6
- data/spec/spec_helper.rb +0 -2
- data/spec/unit/puppetlabs_spec_helper/puppetlabs_spec/puppet_internals_spec.rb +0 -91
- data/spec/watchr.rb +0 -79
data/Gemfile
CHANGED
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
source 'https://rubygems.org'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
gem 'puppet-syntax'
|
|
7
|
-
gem 'mocha'
|
|
3
|
+
# Specify the global dependencies in puppetlabs_spec_helper.gemspec
|
|
4
|
+
# Note that only ruby 1.9 compatible dependencies may go there, everything else needs to be documented and pulled in manually, and optionally by everyone who wants to use the extended features.
|
|
5
|
+
gemspec
|
|
8
6
|
|
|
9
7
|
group :development do
|
|
10
|
-
gem '
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
gem "puppet", ENV['PUPPET_GEM_VERSION'] || ENV['PUPPET_VERSION'] || '~> 4.0'
|
|
9
|
+
if RUBY_VERSION =~ /^1\./
|
|
10
|
+
gem 'rubocop', '0.41.2'
|
|
11
|
+
else
|
|
12
|
+
gem 'rubocop'
|
|
13
|
+
gem 'rubocop-rspec', '~> 1.6' if RUBY_VERSION >= '2.3.0'
|
|
14
|
+
end
|
|
14
15
|
end
|
|
15
16
|
|
|
17
|
+
# json_pure 2.0.2 added a requirement on ruby >= 2. We pin to json_pure 2.0.1
|
|
18
|
+
# if using ruby 1.x
|
|
19
|
+
gem 'json_pure', '<=2.0.1', :require => false if RUBY_VERSION =~ /^1\./
|
|
20
|
+
gem 'rack', '~> 1'
|
|
21
|
+
|
|
16
22
|
# vim:filetype=ruby
|
|
@@ -23,12 +23,12 @@ Usage
|
|
|
23
23
|
=====
|
|
24
24
|
|
|
25
25
|
When developing or testing modules, simply clone this repository and install the
|
|
26
|
-
gem it contains.
|
|
26
|
+
gem it contains. The recommended way to do this is using [bundler](http://bundler.io/#getting-started).
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
Example Gemfile:
|
|
29
|
+
|
|
30
|
+
source 'https://rubygems.org'
|
|
31
|
+
gem 'puppetlabs_spec_helper'
|
|
32
32
|
|
|
33
33
|
Add this to your project's spec\_helper.rb:
|
|
34
34
|
|
|
@@ -61,6 +61,21 @@ Host github.com
|
|
|
61
61
|
|
|
62
62
|
Note: parallel downloads is only available for repositories and not forge modules.
|
|
63
63
|
|
|
64
|
+
### Parallel tests
|
|
65
|
+
It is also possible to use the `parallel_tests` Gem via the `:parallel_spec` Rake task to run rspec commands in parallel on groups of spec files.
|
|
66
|
+
|
|
67
|
+
Use of parallelization at this level can result in large performance benefits when the Rspec examples tend to cause a number of large, CPU-intensive catalog compilations to occur. An example of where this might be the case is in a complex module with a lot of tests or a control repo with many hosts.
|
|
68
|
+
|
|
69
|
+
Be aware however that in other circumstances this parallelization can result in the tests actually taking longer to run. The best thing to do is time `rspec spec` and `rspec parallel_spec` and use the parallelization only when there is a clear benefit.
|
|
70
|
+
|
|
71
|
+
To enable this feature, add the `parallel_tests` Gem to your project's Gemfile:
|
|
72
|
+
|
|
73
|
+
gem 'parallel_tests'
|
|
74
|
+
|
|
75
|
+
And then to run spec tests in parallel:
|
|
76
|
+
|
|
77
|
+
$ rake parallel_spec
|
|
78
|
+
|
|
64
79
|
Issues
|
|
65
80
|
======
|
|
66
81
|
|
|
@@ -93,6 +108,17 @@ branch of this project from github, and install it as a rubygem.
|
|
|
93
108
|
There should be few or no cases where you would want to have any other
|
|
94
109
|
branch of this project besides master/HEAD.
|
|
95
110
|
|
|
111
|
+
Running on non-current ruby versions
|
|
112
|
+
------------------------------------
|
|
113
|
+
|
|
114
|
+
Since gem and bundler, ruby's package management tools, do not take the target ruby version into account when downloading packages, the puppetlabs_spec_helper gem can only depend on gems that are available for all supported ruby versions. If you can/want to use features from other packages, install those additional packages manually, or have a look at the Gemfile, which provides code to specify those dependencies in a more "friendly" way. This currently affects the following gems:
|
|
115
|
+
|
|
116
|
+
* puppet
|
|
117
|
+
* rubocop
|
|
118
|
+
* rubocop-rspec
|
|
119
|
+
* json_pure
|
|
120
|
+
* rack
|
|
121
|
+
|
|
96
122
|
Initializing Puppet for Testing
|
|
97
123
|
===============================
|
|
98
124
|
|
|
@@ -119,9 +145,10 @@ variables for the spec run. These are:
|
|
|
119
145
|
* ``FUTURE_PARSER`` - set to "yes" to enable the [future parser](http://docs.puppetlabs.com/puppet/latest/reference/experiments_future.html),
|
|
120
146
|
the equivalent of setting [parser=future](http://docs.puppetlabs.com/references/latest/configuration.html#parser)
|
|
121
147
|
in puppet.conf.
|
|
122
|
-
* ``STRICT_VARIABLES`` - set to "yes" to enable strict variable checking
|
|
123
|
-
|
|
124
|
-
|
|
148
|
+
* ``STRICT_VARIABLES`` - set to "yes" to enable set to strict variable checking when using Puppet versions between 3.5 and 4.0;
|
|
149
|
+
set to "no" to disable strict variable checking on Puppet versions 4.0, and later.
|
|
150
|
+
See [strict_variables](http://docs.puppetlabs.com/references/latest/configuration.html#strictvariables)
|
|
151
|
+
in puppet.conf for details.
|
|
125
152
|
* ``ORDERING`` - set to the desired ordering method ("title-hash", "manifest", or "random")
|
|
126
153
|
to set the order of unrelated resources when applying a catalog. Leave unset for the default
|
|
127
154
|
behavior, currently "random". This is equivalent to setting [ordering](http://docs.puppetlabs.com/references/latest/configuration.html#ordering)
|
|
@@ -140,6 +167,18 @@ and manifest ordering, you would:
|
|
|
140
167
|
|
|
141
168
|
FUTURE_PARSER=yes STRICT_VARIABLES=yes ORDERING=manifest rake spec
|
|
142
169
|
|
|
170
|
+
When executing tests in a matrix CI environment, tests can be split up to run
|
|
171
|
+
a share of specs per CI node in parallel. Set the ``CI_NODE_TOTAL`` environment
|
|
172
|
+
variable to the total number of nodes, and the ``CI_NODE_INDEX`` to a number
|
|
173
|
+
between 1 and the ``CI_NODE_TOTAL``.
|
|
174
|
+
|
|
175
|
+
If using Travis CI, add new lines to the "env" section of .travis.yml per node,
|
|
176
|
+
remembering to duplicate any existing environment variables:
|
|
177
|
+
|
|
178
|
+
env:
|
|
179
|
+
- FUTURE_PARSER=yes CI_NODE_TOTAL=2 CI_NODE_INDEX=1
|
|
180
|
+
- FUTURE_PARSER=yes CI_NODE_TOTAL=2 CI_NODE_INDEX=2
|
|
181
|
+
|
|
143
182
|
Using Utility Classes
|
|
144
183
|
=====================
|
|
145
184
|
If you'd like to use the Utility classes (PuppetlabsSpec::Files,
|
|
@@ -158,24 +197,32 @@ Using Fixtures
|
|
|
158
197
|
`puppetlabs_spec_helper` has the ability to populate the
|
|
159
198
|
`spec/fixtures/modules` directory with dependent modules when `rake spec` or
|
|
160
199
|
`rake spec_prep` is run. To do so, all required modules should be listed in a
|
|
161
|
-
file named `.fixtures.yml` in the root of the project.
|
|
200
|
+
file named `.fixtures.yml` in the root of the project. You can specify a alternate location for that file in the `FIXTURES_YML` environment variable.
|
|
201
|
+
|
|
202
|
+
You can use the `MODULE_WORKING_DIR` environment variable to specify a diffent location when installing module fixtures via the forge. By default the
|
|
203
|
+
working directory is `<module directory>/spec/fixtures/work-dir`.
|
|
162
204
|
|
|
163
205
|
When specifying the repo source of the fixture you have a few options as to which revision of the codebase you wish to use.
|
|
164
206
|
|
|
165
207
|
* repo - the url to the repo
|
|
166
208
|
* scm - options include git or hg. This is an optional step as the helper code will figure out which scm is used.
|
|
209
|
+
|
|
167
210
|
```yaml
|
|
168
211
|
scm: git
|
|
169
212
|
scm: hg
|
|
170
213
|
```
|
|
214
|
+
|
|
171
215
|
* target - the directory name to clone the repo into ie. `target: mymodule` defaults to the repo name (Optional)
|
|
216
|
+
* subdir - directory to be removed from the cloned repo. Its contents will be moved to the root directory (Optional)
|
|
172
217
|
* ref - used to specify the tag name like version hash of commit (Optional)
|
|
218
|
+
|
|
173
219
|
```yaml
|
|
174
220
|
ref: 1.0.0
|
|
175
221
|
ref: 880fca52c
|
|
176
222
|
```
|
|
177
223
|
* branch - used to specify the branch name you want to use ie. `branch: development`
|
|
178
224
|
* flags - additional flags passed to the module installer (both puppet and scm)
|
|
225
|
+
|
|
179
226
|
```yaml
|
|
180
227
|
flags: --verbose
|
|
181
228
|
```
|
|
@@ -187,86 +234,164 @@ Fixtures Examples
|
|
|
187
234
|
Basic fixtures that will symlink `spec/fixtures/modules/my_modules` to the
|
|
188
235
|
project root:
|
|
189
236
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
237
|
+
```yaml
|
|
238
|
+
fixtures:
|
|
239
|
+
symlinks:
|
|
240
|
+
my_module: "#{source_dir}"
|
|
241
|
+
```
|
|
193
242
|
|
|
243
|
+
This is the same as specifying no symlinks fixtures at all.
|
|
194
244
|
|
|
195
245
|
Add `firewall` and `stdlib` as required module fixtures:
|
|
196
246
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
247
|
+
```yaml
|
|
248
|
+
fixtures:
|
|
249
|
+
repositories:
|
|
250
|
+
firewall: "git://github.com/puppetlabs/puppetlabs-firewall"
|
|
251
|
+
stdlib: "git://github.com/puppetlabs/puppetlabs-stdlib"
|
|
252
|
+
```
|
|
203
253
|
|
|
204
254
|
Specify that the git tag `2.4.2` of `stdlib' should be checked out:
|
|
205
255
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
256
|
+
```yaml
|
|
257
|
+
fixtures:
|
|
258
|
+
repositories:
|
|
259
|
+
firewall: "git://github.com/puppetlabs/puppetlabs-firewall"
|
|
260
|
+
stdlib:
|
|
261
|
+
repo: "git://github.com/puppetlabs/puppetlabs-stdlib"
|
|
262
|
+
ref: "2.6.0"
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
Move manifests and siblings to root directory when they are inside a `code` directory:
|
|
266
|
+
|
|
267
|
+
```yaml
|
|
268
|
+
fixtures:
|
|
269
|
+
repositories:
|
|
270
|
+
stdlib:
|
|
271
|
+
repo: "git://github.com/puppetlabs/puppetlabs-extradirectory"
|
|
272
|
+
subdir: "code"
|
|
273
|
+
```
|
|
214
274
|
|
|
215
275
|
Install modules from Puppet Forge:
|
|
216
276
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
277
|
+
```yaml
|
|
278
|
+
fixtures:
|
|
279
|
+
forge_modules:
|
|
280
|
+
firewall: "puppetlabs/firewall"
|
|
281
|
+
stdlib:
|
|
282
|
+
repo: "puppetlabs/stdlib"
|
|
283
|
+
ref: "2.6.0"
|
|
284
|
+
```
|
|
223
285
|
|
|
224
286
|
Pass additional flags to module installation:
|
|
225
287
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
288
|
+
```yaml
|
|
289
|
+
fixtures:
|
|
290
|
+
forge_modules:
|
|
291
|
+
stdlib:
|
|
292
|
+
repo: "puppetlabs/stdlib"
|
|
293
|
+
ref: "2.6.0"
|
|
294
|
+
flags: "--module_repository https://my_repo.com"
|
|
295
|
+
repositories:
|
|
296
|
+
firewall:
|
|
297
|
+
repo: "git://github.com/puppetlabs/puppetlabs-firewall"
|
|
298
|
+
ref: "2.6.0"
|
|
299
|
+
flags: "--verbose"
|
|
300
|
+
```
|
|
237
301
|
|
|
238
302
|
Testing Parser Functions
|
|
239
303
|
========================
|
|
240
304
|
|
|
241
|
-
This
|
|
242
|
-
|
|
243
|
-
|
|
305
|
+
This whole section is superseded by improved support of accessing the scope in
|
|
306
|
+
rspec-puppet.
|
|
307
|
+
|
|
308
|
+
Generating code coverage reports
|
|
309
|
+
================================
|
|
310
|
+
|
|
311
|
+
This section describes how to add code coverage reports for Ruby files (types, providers, ...).
|
|
312
|
+
See the documentation of [RSpec-Puppet](https://github.com/rodjek/rspec-puppet)
|
|
313
|
+
for Puppet manifest coverage reports.
|
|
314
|
+
|
|
315
|
+
Starting with Ruby 1.9, the *de facto* standard for Ruby code coverage is
|
|
316
|
+
[SimpleCov](https://github.com/colszowka/simplecov).
|
|
317
|
+
You can add it to your module like this:
|
|
318
|
+
|
|
319
|
+
```Ruby
|
|
320
|
+
# First line of spec/spec_helper.rb
|
|
321
|
+
require 'simplecov'
|
|
322
|
+
|
|
323
|
+
SimpleCov.start do
|
|
324
|
+
add_filter '/spec/'
|
|
325
|
+
# Exclude bundled Gems in `/.vendor/`
|
|
326
|
+
add_filter '/.vendor/'
|
|
327
|
+
end
|
|
328
|
+
|
|
329
|
+
require 'puppetlabs_spec_helper/module_spec_helper'
|
|
330
|
+
# Further content
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
The reports will then be generated every time you invoke RSpec, e.g. via `rake spec`,
|
|
334
|
+
and are written to `/coverage/`, which you should add to `.gitignore`.
|
|
335
|
+
|
|
336
|
+
Remember to add `gem 'simplecov', require: false` to your `Gemfile`.
|
|
337
|
+
|
|
338
|
+
Using Code Climate
|
|
339
|
+
------------------
|
|
244
340
|
|
|
245
|
-
|
|
341
|
+
You can also use [Code Climate](https://codeclimate.com/) together with SimpleCov:
|
|
246
342
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
scope.function_split(['one;two', ';']).should == [ 'one', 'two' ]
|
|
251
|
-
end
|
|
252
|
-
end
|
|
343
|
+
```Ruby
|
|
344
|
+
# First line of spec/spec_helper.rb
|
|
345
|
+
require 'codeclimate-test-reporter'
|
|
253
346
|
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
347
|
+
SimpleCov.formatters = [
|
|
348
|
+
SimpleCov::Formatter::HTMLFormatter,
|
|
349
|
+
CodeClimate::TestReporter::Formatter
|
|
350
|
+
]
|
|
257
351
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
352
|
+
SimpleCov.start do
|
|
353
|
+
add_filter '/spec/'
|
|
354
|
+
# Exclude bundled Gems in `/.vendor/`
|
|
355
|
+
add_filter '/.vendor/'
|
|
356
|
+
end
|
|
357
|
+
|
|
358
|
+
require 'puppetlabs_spec_helper/module_spec_helper'
|
|
359
|
+
# Further content
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
Remember to add `gem 'codeclimate-test-reporter', require: false` to your `Gemfile`.
|
|
363
|
+
|
|
364
|
+
Using Coveralls
|
|
365
|
+
---------------
|
|
366
|
+
|
|
367
|
+
You can also use [Coveralls](https://coveralls.io/) together with SimpleCov:
|
|
368
|
+
|
|
369
|
+
```Ruby
|
|
370
|
+
# First line of spec/spec_helper.rb
|
|
371
|
+
require 'simplecov'
|
|
372
|
+
require 'coveralls'
|
|
373
|
+
|
|
374
|
+
SimpleCov.formatters = [
|
|
375
|
+
SimpleCov::Formatter::HTMLFormatter,
|
|
376
|
+
Coveralls::SimpleCov::Formatter
|
|
377
|
+
]
|
|
378
|
+
|
|
379
|
+
SimpleCov.start do
|
|
380
|
+
add_filter '/spec/'
|
|
381
|
+
# Exclude bundled Gems in `/.vendor/`
|
|
382
|
+
add_filter '/.vendor/'
|
|
383
|
+
end
|
|
384
|
+
|
|
385
|
+
require 'puppetlabs_spec_helper/module_spec_helper'
|
|
386
|
+
# Further content
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
Remember to add `gem 'coveralls', require: false` to your `Gemfile`.
|
|
265
390
|
|
|
266
391
|
Some Notes for Windows Users
|
|
267
|
-
|
|
392
|
+
============================
|
|
268
393
|
|
|
269
|
-
A windows users may need to do one of two things to execute
|
|
394
|
+
A windows users may need to do one of two things to execute `rake spec`.
|
|
270
395
|
|
|
271
396
|
Although things may appear to work, the init.pp may not transfer to the fixtures folder as needed
|
|
272
397
|
or may transfer as an empty file.
|
data/Rakefile
CHANGED
|
@@ -1,50 +1,15 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
|
+
require "bundler/gem_tasks"
|
|
3
|
+
require "rspec/core/rake_task"
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
require 'bundler'
|
|
5
|
-
begin
|
|
6
|
-
Bundler.setup(:default, :development)
|
|
7
|
-
rescue Bundler::BundlerError => e
|
|
8
|
-
$stderr.puts e.message
|
|
9
|
-
$stderr.puts "Run `bundle install` to install missing gems"
|
|
10
|
-
exit e.status_code
|
|
11
|
-
end
|
|
12
|
-
require 'rake'
|
|
13
|
-
require_relative 'lib/puppetlabs_spec_helper/version'
|
|
14
|
-
require 'jeweler'
|
|
15
|
-
Jeweler::Tasks.new do |gem|
|
|
16
|
-
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
|
17
|
-
gem.name = "puppetlabs_spec_helper"
|
|
18
|
-
gem.version = "#{PuppetlabsSpecHelper::Version::STRING}"
|
|
19
|
-
gem.homepage = "http://github.com/puppetlabs/puppetlabs_spec_helper"
|
|
20
|
-
gem.license = "Apache-2.0"
|
|
21
|
-
gem.summary = %Q{Standard tasks and configuration for module spec tests}
|
|
22
|
-
gem.description = %Q{Contains rake tasks and a standard spec_helper for running spec tests on puppet modules}
|
|
23
|
-
gem.email = ["modules-dept@puppetlabs.com"]
|
|
24
|
-
gem.authors = ["Puppet Labs"]
|
|
25
|
-
# dependencies defined in Gemfile
|
|
26
|
-
end
|
|
27
|
-
Jeweler::RubygemsDotOrgTasks.new
|
|
5
|
+
task :default => :spec
|
|
28
6
|
|
|
29
|
-
require 'rspec/core'
|
|
30
|
-
require 'rspec/core/rake_task'
|
|
31
7
|
RSpec::Core::RakeTask.new(:spec) do |spec|
|
|
32
8
|
spec.pattern = FileList['spec/**/*_spec.rb'].exclude('spec/fixtures/**/*_spec.rb')
|
|
33
9
|
end
|
|
34
10
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
task :tag do
|
|
38
|
-
`git tag -m '#{PuppetlabsSpecHelper::Version::STRING}'`
|
|
39
|
-
end
|
|
40
|
-
desc "Tag and push to master"
|
|
41
|
-
task :pl_release do
|
|
42
|
-
Rake::Task["git:tag"].invoke
|
|
43
|
-
`git push origin master --tags`
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
task :default => :spec
|
|
11
|
+
require 'rubocop/rake_task'
|
|
12
|
+
RuboCop::RakeTask.new
|
|
48
13
|
|
|
49
14
|
require 'yard'
|
|
50
15
|
YARD::Rake::YardocTask.new
|
|
@@ -8,7 +8,7 @@ end
|
|
|
8
8
|
|
|
9
9
|
def verify_contents(subject, title, expected_lines)
|
|
10
10
|
content = subject.resource('file', title).send(:parameters)[:content]
|
|
11
|
-
(content.split("\n") & expected_lines).
|
|
11
|
+
expect(content.split("\n") & expected_lines).to match_array expected_lines.uniq
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
spec_path = File.expand_path(File.join(Dir.pwd, 'spec'))
|
|
@@ -24,12 +24,6 @@ RSpec.configure do |c|
|
|
|
24
24
|
c.module_path = module_path
|
|
25
25
|
c.manifest_dir = File.join(fixture_path, 'manifests')
|
|
26
26
|
c.parser = 'future' if ENV['FUTURE_PARSER'] == 'yes'
|
|
27
|
-
## This depends on rspec-puppet #209 being released
|
|
28
|
-
#c.strict_variables = true if ENV['STRICT_VARIABLES'] == 'yes'
|
|
29
|
-
## These depend on rspec-puppet #212 being released
|
|
30
|
-
#c.stringify_facts = false if ENV['STRINGIFY_FACTS'] == 'no'
|
|
31
|
-
#c.trusted_node_data = true if ENV['TRUSTED_NODE_DATA'] == 'yes'
|
|
32
|
-
#c.ordering = ENV['ORDERING'] if ENV['ORDERING']
|
|
33
27
|
|
|
34
28
|
c.before :each do
|
|
35
29
|
Puppet.features.stubs(:root?).returns(true)
|
|
@@ -38,7 +32,7 @@ RSpec.configure do |c|
|
|
|
38
32
|
Puppet.settings[:stringify_facts] = false if ENV['STRINGIFY_FACTS'] == 'no'
|
|
39
33
|
Puppet.settings[:trusted_node_data] = true if ENV['TRUSTED_NODE_DATA'] == 'yes'
|
|
40
34
|
end
|
|
41
|
-
Puppet.settings[:strict_variables] = true if ENV['STRICT_VARIABLES'] == 'yes'
|
|
35
|
+
Puppet.settings[:strict_variables] = true if ENV['STRICT_VARIABLES'] == 'yes' || (Puppet.version.to_f >= 4.0 && ENV['STRICT_VARIABLES'] != 'no')
|
|
42
36
|
Puppet.settings[:ordering] = ENV['ORDERING'] if ENV['ORDERING']
|
|
43
37
|
end
|
|
44
38
|
end
|
|
@@ -8,6 +8,8 @@ module PuppetlabsSpec
|
|
|
8
8
|
# instance suitable for placing in a test harness with the intent of
|
|
9
9
|
# testing parser functions from modules.
|
|
10
10
|
def scope(parts = {})
|
|
11
|
+
RSpec.deprecate('scope', :replacement => 'rspec-puppet 2.2.0 provides a scope property')
|
|
12
|
+
|
|
11
13
|
if Puppet.version =~ /^2\.[67]/
|
|
12
14
|
# loadall should only be necessary prior to 3.x
|
|
13
15
|
# Please note, loadall needs to happen first when creating a scope, otherwise
|