puppetlabs_spec_helper 0.10.3 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/CHANGELOG.md +17 -1
- data/README.markdown +18 -1
- data/lib/puppetlabs_spec_helper/puppet_spec_helper.rb +9 -42
- data/lib/puppetlabs_spec_helper/rake_tasks.rb +31 -17
- data/lib/puppetlabs_spec_helper/version.rb +1 -1
- metadata +17 -18
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
MDhkZjY5NmZlY2FhMjAzY2E4YWZlODlmMzEyNWVjZDRjMjFkNGFmYg==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b731a22b64d8bfbdd59ff39f43eda181e29802ef
|
4
|
+
data.tar.gz: 1a7cf2a4677943474c5df7055222dc99cd726c2a
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
NThmMWYwOWU4NDFkMzU4YzQ1YzBlY2NmZjFkMjk5YjFiNTkzZDYwMjRjNDk3
|
11
|
-
ZDlkM2E4NzllZDNhMWZlMjJlMmJmMzUyOWNjN2I0NjMyMjJkYmM=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
NDlhNGU0OTIxZmNlM2I3MjJjMDY0MDEwNDhiOGE5ZjAyZGNjNmYzMjAyYWZh
|
14
|
-
YzVlY2M5N2IzN2Q3YTQ0OGMyZTgzNDE5MWZkN2FkMjI4YWU3NzM0MDZmZDVl
|
15
|
-
YThkMWM3NmUwODQ0ZmVjYzhmMWE2NTg2YjkzMzMxMzg4YzdjNzE=
|
6
|
+
metadata.gz: 26e1e8a4edb8177f53f09a70a4dcab81a02768c43f47cd6ab069033557ebf8e3bf2a497c55ca9fd6fc2f8d157243f013aebed27f4ab19114e1aca9afacd0947b
|
7
|
+
data.tar.gz: 47ccbe214b1f858632c9a7286f59e2d40f872dd3b8761eebe35d72c3b13714c68c0aad1b5a3975f3e316ee46e7284340ba0bfde0447039ed9b0c6fc1d324dd2d
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,20 @@
|
|
2
2
|
All notable changes to this project will be documented in this file.
|
3
3
|
This project adheres to [Semantic Versioning](http://semver.org/).
|
4
4
|
|
5
|
+
## [1.0.0] - 2015-11-04
|
6
|
+
### Summary:
|
7
|
+
The first 1.0 release, though the gem has been considered stable for a while.
|
8
|
+
|
9
|
+
### Added:
|
10
|
+
- `flags` value for fixtures to allow passing CLI flags when installing modules
|
11
|
+
- `spec_standalone` rake task also runs `spec/types` specs
|
12
|
+
- Can now use `.fixtures.yaml` instead of `.fixtures.yml`
|
13
|
+
|
14
|
+
### Fixed:
|
15
|
+
- Remove double-initialization that was conflicting with rspec-puppet
|
16
|
+
- Better error handling on malformed fixtures yaml
|
17
|
+
- Bug in rake task's ignore\_paths
|
18
|
+
|
5
19
|
## [0.10.3] - 2015-05-11
|
6
20
|
### Summary:
|
7
21
|
A bugfix for puppet 3 and puppet 4 tests being able to run with the same environment variables.
|
@@ -194,7 +208,9 @@ compatible yet.
|
|
194
208
|
### Added
|
195
209
|
* Initial release
|
196
210
|
|
197
|
-
[unreleased]: https://github.com/puppetlabs/puppetlabs_spec_helper/compare/0.
|
211
|
+
[unreleased]: https://github.com/puppetlabs/puppetlabs_spec_helper/compare/1.0.0...master
|
212
|
+
[1.0.0]: https://github.com/puppetlabs/puppetlabs_spec_helper/compare/0.10.3...1.0.0
|
213
|
+
[0.10.3]: https://github.com/puppetlabs/puppetlabs_spec_helper/compare/0.10.2...0.10.3
|
198
214
|
[0.10.2]: https://github.com/puppetlabs/puppetlabs_spec_helper/compare/0.10.1...0.10.2
|
199
215
|
[0.10.1]: https://github.com/puppetlabs/puppetlabs_spec_helper/compare/0.10.0...0.10.1
|
200
216
|
[0.10.0]: https://github.com/puppetlabs/puppetlabs_spec_helper/compare/0.9.1...0.10.0
|
data/README.markdown
CHANGED
@@ -157,7 +157,11 @@ When specifying the repo source of the fixture you have a few options as to whic
|
|
157
157
|
ref: 880fca52c
|
158
158
|
```
|
159
159
|
* branch - used to specify the branch name you want to use ie. `branch: development`
|
160
|
-
|
160
|
+
* flags - additional flags passed to the module installer (both puppet and scm)
|
161
|
+
```yaml
|
162
|
+
flags: --verbose
|
163
|
+
```
|
164
|
+
|
161
165
|
**Note:** ref and branch can be used together to get a specific revision on a specific branch
|
162
166
|
|
163
167
|
Fixtures Examples
|
@@ -199,6 +203,19 @@ Install modules from Puppet Forge:
|
|
199
203
|
repo: "puppetlabs/stdlib"
|
200
204
|
ref: "2.6.0"
|
201
205
|
|
206
|
+
Pass additional flags to module installation:
|
207
|
+
|
208
|
+
fixtures:
|
209
|
+
forge_modules:
|
210
|
+
stdlib:
|
211
|
+
repo: "puppetlabs/stdlib"
|
212
|
+
ref: "2.6.0"
|
213
|
+
flags: "--module_repository https://my_repo.com"
|
214
|
+
repositories:
|
215
|
+
firewall:
|
216
|
+
repo: "git://github.com/puppetlabs/puppetlabs-firewall"
|
217
|
+
ref: "2.6.0"
|
218
|
+
flags: "--verbose"
|
202
219
|
|
203
220
|
Testing Parser Functions
|
204
221
|
========================
|
@@ -32,46 +32,24 @@ require 'puppetlabs_spec_helper/puppetlabs_spec/files'
|
|
32
32
|
# You may want to hold your nose before you proceed. :)
|
33
33
|
#
|
34
34
|
|
35
|
+
# Here we attempt to load the new TestHelper API, and print a warning if we are falling back
|
36
|
+
# to compatibility mode for older versions of puppet.
|
37
|
+
begin
|
38
|
+
require 'puppet/test/test_helper'
|
39
|
+
rescue LoadError => err
|
40
|
+
end
|
35
41
|
|
36
42
|
# This is just a utility class to allow us to isolate the various version-specific
|
37
43
|
# branches of initialization logic into methods without polluting the global namespace.#
|
38
44
|
module Puppet
|
39
45
|
class PuppetSpecInitializer
|
40
|
-
# This method uses the "new"/preferred approach of delegating all of the test
|
41
|
-
# state initialization to puppet itself, via Puppet::Test::TestHelper API. This
|
42
|
-
# should be fairly future-proof as long as that API doesn't change, which it
|
43
|
-
# hopefully will not need to.
|
44
|
-
def self.initialize_via_testhelper(config)
|
45
|
-
begin
|
46
|
-
Puppet::Test::TestHelper.initialize
|
47
|
-
rescue NoMethodError
|
48
|
-
Puppet::Test::TestHelper.before_each_test
|
49
|
-
end
|
50
|
-
|
51
|
-
# connect rspec hooks to TestHelper methods.
|
52
|
-
config.before :all do
|
53
|
-
Puppet::Test::TestHelper.before_all_tests
|
54
|
-
end
|
55
|
-
|
56
|
-
config.after :all do
|
57
|
-
Puppet::Test::TestHelper.after_all_tests
|
58
|
-
end
|
59
|
-
|
60
|
-
config.before :each do
|
61
|
-
Puppet::Test::TestHelper.before_each_test
|
62
|
-
end
|
63
|
-
|
64
|
-
config.after :each do
|
65
|
-
Puppet::Test::TestHelper.after_each_test
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
46
|
# This method is for initializing puppet state for testing for older versions
|
70
47
|
# of puppet that do not support the new TestHelper API. As you can see,
|
71
48
|
# this involves explicitly modifying global variables, directly manipulating
|
72
49
|
# Puppet's Settings singleton object, and other fun implementation details
|
73
50
|
# that code external to puppet should really never know about.
|
74
51
|
def self.initialize_via_fallback_compatibility(config)
|
52
|
+
$stderr.puts("Warning: you appear to be using an older version of puppet; spec_helper will use fallback compatibility mode.")
|
75
53
|
config.before :all do
|
76
54
|
# nothing to do for now
|
77
55
|
end
|
@@ -112,17 +90,6 @@ module Puppet
|
|
112
90
|
end
|
113
91
|
end
|
114
92
|
|
115
|
-
|
116
|
-
|
117
|
-
# Here we attempt to load the new TestHelper API, and print a warning if we are falling back
|
118
|
-
# to compatibility mode for older versions of puppet.
|
119
|
-
begin
|
120
|
-
require 'puppet/test/test_helper'
|
121
|
-
rescue LoadError => err
|
122
|
-
$stderr.puts("Warning: you appear to be using an older version of puppet; spec_helper will use fallback compatibility mode.")
|
123
|
-
end
|
124
|
-
|
125
|
-
|
126
93
|
# JJM Hack to make the stdlib tests run in Puppet 2.6 (See puppet commit cf183534)
|
127
94
|
if not Puppet.constants.include? "Test" then
|
128
95
|
module Puppet::Test
|
@@ -149,14 +116,14 @@ if not Puppet.constants.include? "Test" then
|
|
149
116
|
end
|
150
117
|
end
|
151
118
|
|
152
|
-
|
153
119
|
# And here is where we do the main rspec configuration / setup.
|
154
120
|
RSpec.configure do |config|
|
121
|
+
# Some modules depend on having mocha set up for them
|
155
122
|
config.mock_with :mocha
|
156
123
|
|
157
124
|
# determine whether we can use the new API or not, and call the appropriate initializer method.
|
158
125
|
if (defined?(Puppet::Test::TestHelper))
|
159
|
-
|
126
|
+
# This case is handled by rspec-puppet since v1.0.0 (via 41257b33cb1f9ade4426b044f70be511b0c89112)
|
160
127
|
else
|
161
128
|
Puppet::PuppetSpecInitializer.initialize_via_fallback_compatibility(config)
|
162
129
|
end
|
@@ -7,7 +7,7 @@ task :default => [:help]
|
|
7
7
|
desc "Run spec tests on an existing fixtures directory"
|
8
8
|
RSpec::Core::RakeTask.new(:spec_standalone) do |t|
|
9
9
|
t.rspec_opts = ['--color']
|
10
|
-
t.pattern = 'spec/{classes,defines,unit,functions,hosts,integration}/**/*_spec.rb'
|
10
|
+
t.pattern = 'spec/{classes,defines,unit,functions,hosts,integration,types}/**/*_spec.rb'
|
11
11
|
end
|
12
12
|
|
13
13
|
desc "Run beaker acceptance tests"
|
@@ -28,14 +28,20 @@ def source_dir
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def fixtures(category)
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
31
|
+
if File.exists?('.fixtures.yml')
|
32
|
+
fixtures_yaml = '.fixtures.yml'
|
33
|
+
elsif File.exists?('.fixtures.yaml')
|
34
|
+
fixtures_yaml = '.fixtures.yaml'
|
35
|
+
else
|
36
|
+
fixtures_yaml = ''
|
35
37
|
end
|
36
38
|
|
37
|
-
|
38
|
-
|
39
|
+
begin
|
40
|
+
fixtures = YAML.load_file(fixtures_yaml)["fixtures"]
|
41
|
+
rescue Error::ENOENT
|
42
|
+
return {}
|
43
|
+
rescue Psych::SyntaxError => e
|
44
|
+
abort("Found malformed YAML in #{fixtures_yaml} on line #{e.line} column #{e.column}: #{e.problem}")
|
39
45
|
end
|
40
46
|
|
41
47
|
result = {}
|
@@ -49,24 +55,26 @@ def fixtures(category)
|
|
49
55
|
elsif opts.instance_of?(Hash)
|
50
56
|
target = "spec/fixtures/modules/#{fixture}"
|
51
57
|
real_source = eval('"'+opts["repo"]+'"')
|
52
|
-
result[real_source] = { "target" => target, "ref" => opts["ref"], "branch" => opts["branch"], "scm" => opts["scm"] }
|
58
|
+
result[real_source] = { "target" => target, "ref" => opts["ref"], "branch" => opts["branch"], "scm" => opts["scm"], "flags" => opts["flags"]}
|
53
59
|
end
|
54
60
|
end
|
55
61
|
end
|
56
62
|
return result
|
57
63
|
end
|
58
64
|
|
59
|
-
def clone_repo(scm, remote, target, ref=nil, branch=nil)
|
65
|
+
def clone_repo(scm, remote, target, ref=nil, branch=nil, flags = nil)
|
60
66
|
args = []
|
61
67
|
case scm
|
62
68
|
when 'hg'
|
63
69
|
args.push('clone')
|
64
70
|
args.push('-u', ref) if ref
|
71
|
+
args.push(flags) if flags
|
65
72
|
args.push(remote, target)
|
66
73
|
when 'git'
|
67
74
|
args.push('clone')
|
68
75
|
args.push('--depth 1') unless ref
|
69
76
|
args.push('-b', branch) if branch
|
77
|
+
args.push(flags) if flags
|
70
78
|
args.push(remote, target)
|
71
79
|
else
|
72
80
|
fail "Unfortunately #{scm} is not supported yet"
|
@@ -109,9 +117,10 @@ task :spec_prep do
|
|
109
117
|
ref = opts["ref"]
|
110
118
|
scm = opts["scm"] if opts["scm"]
|
111
119
|
branch = opts["branch"] if opts["branch"]
|
120
|
+
flags = opts["flags"]
|
112
121
|
end
|
113
122
|
|
114
|
-
unless File::exists?(target) || clone_repo(scm, remote, target, ref, branch)
|
123
|
+
unless File::exists?(target) || clone_repo(scm, remote, target, ref, branch, flags)
|
115
124
|
fail "Failed to clone #{scm} repository #{remote} into #{target}"
|
116
125
|
end
|
117
126
|
revision(scm, target, ref) if ref
|
@@ -128,18 +137,23 @@ task :spec_prep do
|
|
128
137
|
end
|
129
138
|
|
130
139
|
fixtures("forge_modules").each do |remote, opts|
|
140
|
+
ref = ""
|
141
|
+
flags = ""
|
131
142
|
if opts.instance_of?(String)
|
132
143
|
target = opts
|
133
|
-
ref = ""
|
134
144
|
elsif opts.instance_of?(Hash)
|
135
145
|
target = opts["target"]
|
136
|
-
ref = "--version #{opts['ref']}"
|
146
|
+
ref = " --version #{opts['ref']}" if not opts['ref'].nil?
|
147
|
+
flags = " #{opts['flags']}" if opts['flags']
|
137
148
|
end
|
138
149
|
next if File::exists?(target)
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
150
|
+
|
151
|
+
command = "puppet module install" + ref + flags + \
|
152
|
+
" --ignore-dependencies" \
|
153
|
+
" --force" \
|
154
|
+
" --target-dir spec/fixtures/modules #{remote}"
|
155
|
+
|
156
|
+
unless system(command)
|
143
157
|
fail "Failed to install module #{remote} to #{target}"
|
144
158
|
end
|
145
159
|
end
|
@@ -224,7 +238,7 @@ PuppetLint::RakeTask.new(:lint) do |config|
|
|
224
238
|
'class_parameter_defaults',
|
225
239
|
'documentation',
|
226
240
|
'single_quote_string_with_variables']
|
227
|
-
config.ignore_paths = ["tests/**/*.pp", "vendor/**/*.pp","examples/**/*.pp" "spec/**/*.pp", "pkg/**/*.pp"]
|
241
|
+
config.ignore_paths = ["tests/**/*.pp", "vendor/**/*.pp","examples/**/*.pp", "spec/**/*.pp", "pkg/**/*.pp"]
|
228
242
|
end
|
229
243
|
|
230
244
|
require 'puppet-syntax/tasks/puppet-syntax'
|
metadata
CHANGED
@@ -1,83 +1,83 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: puppetlabs_spec_helper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Puppet Labs
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-11-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rspec-puppet
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: puppet-lint
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: puppet-syntax
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: mocha
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
description: Contains rake tasks and a standard spec_helper for running spec tests
|
@@ -88,8 +88,8 @@ executables: []
|
|
88
88
|
extensions: []
|
89
89
|
extra_rdoc_files: []
|
90
90
|
files:
|
91
|
-
- .gitignore
|
92
|
-
- .noexec.yaml
|
91
|
+
- ".gitignore"
|
92
|
+
- ".noexec.yaml"
|
93
93
|
- CHANGELOG.md
|
94
94
|
- Gemfile
|
95
95
|
- LICENSE
|
@@ -121,17 +121,17 @@ require_paths:
|
|
121
121
|
- lib
|
122
122
|
required_ruby_version: !ruby/object:Gem::Requirement
|
123
123
|
requirements:
|
124
|
-
- -
|
124
|
+
- - ">="
|
125
125
|
- !ruby/object:Gem::Version
|
126
126
|
version: '0'
|
127
127
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
|
-
- -
|
129
|
+
- - ">="
|
130
130
|
- !ruby/object:Gem::Version
|
131
131
|
version: '0'
|
132
132
|
requirements: []
|
133
133
|
rubyforge_project:
|
134
|
-
rubygems_version: 2.
|
134
|
+
rubygems_version: 2.2.3
|
135
135
|
signing_key:
|
136
136
|
specification_version: 4
|
137
137
|
summary: Standard tasks and configuration for module spec tests
|
@@ -140,4 +140,3 @@ test_files:
|
|
140
140
|
- spec/unit/puppetlabs_spec_helper/puppetlabs_spec/puppet_internals_spec.rb
|
141
141
|
- spec/unit/spechelper_spec.rb
|
142
142
|
- spec/watchr.rb
|
143
|
-
has_rdoc:
|