rspec-puppet-utils 3.0.0 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +14 -6
- data/lib/rspec_puppet_utils/rake/project_tasks.rb +26 -23
- data/rspec-puppet-utils.gemspec +1 -1
- data/spec/classes/rake/project_tasks_spec.rb +32 -3
- data/spec/require_spec.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 924d4f298027f823e62dea1fb2c6b5aaee469b61
|
4
|
+
data.tar.gz: 7b0f41dbb693412266edc0d75f4f50db282bc9ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3de55b7778ccaf128ff7ac8630e076dc6eb0c981dde9bb43f5de612977154a5554bb6ce94e32cd2b501062fead337c37b8d713dc1c708bc40c707e6971af47ff
|
7
|
+
data.tar.gz: 2367547ae235d27906bfff7b1e5647cc7ef272ad7dd6169362815813ae740cb8cf5b75cb91ea3e8e2ca751fec455081d84cfc36c68efa9fc478f15513f422f05
|
data/README.md
CHANGED
@@ -6,6 +6,14 @@ See [release notes](../../wiki/Release-Notes) about latest version
|
|
6
6
|
|
7
7
|
## Updates:
|
8
8
|
|
9
|
+
#### v3.1.0
|
10
|
+
|
11
|
+
By default the zip file now includes the version (e.g. `puppet-1.2.0.zip`). In v3.0.0 the file was just called `puppet.zip`
|
12
|
+
|
13
|
+
You can omit the version from the zip name like so: `puppet.package_versioning = false`
|
14
|
+
|
15
|
+
Given that v3.0.0 was only released the day before, I'll keep it as a minor version update
|
16
|
+
|
9
17
|
#### v3.0.0
|
10
18
|
|
11
19
|
The project is now developed against ruby 2.1.0 and so it may not be backwards compatible when running on ruby 1.8.7.
|
@@ -270,11 +278,11 @@ The `build` task will bundle all Puppet code (modules, hiera data file, environm
|
|
270
278
|
|
271
279
|
In the example above `package_version` is set as it's a required field. The other accessible properties are:
|
272
280
|
|
273
|
-
- module_path
|
274
|
-
- excluded_modules
|
275
|
-
- package_dir
|
276
|
-
- package_files
|
277
|
-
-
|
281
|
+
- module_path - The directory containing all the modules to test (default: 'modules')
|
282
|
+
- excluded_modules - Modules to exclude from rspec testing (default: [])
|
283
|
+
- package_dir - Where the puppet zip package will be created (default: 'pkg')
|
284
|
+
- package_files - Files and directories to include in the package (default: ['modules', 'modules-lib', 'config/environment.conf'])
|
285
|
+
- package_versioning - Is the version included in the package name? (default: true)
|
278
286
|
|
279
287
|
##### NB:
|
280
288
|
|
@@ -287,7 +295,7 @@ It also guarantees that the binary at the end of a build was just built, and was
|
|
287
295
|
|
288
296
|
##### ToDo:
|
289
297
|
|
290
|
-
Currently the `spec` task runs all the `spec
|
298
|
+
Currently the `spec` task runs all the `spec:<module>` tasks. If one of these fails then none of the subsequent tasks will run. This isn't ideal!
|
291
299
|
|
292
300
|
The zip commands need to be replaced by ruby zip library to avoid shelling out, this helps with support for Windows environments
|
293
301
|
|
@@ -2,7 +2,6 @@ require 'rake'
|
|
2
2
|
require 'rspec/core/rake_task'
|
3
3
|
require 'fileutils'
|
4
4
|
|
5
|
-
# ToDo: Add flag to include version in package file name or not e.g. puppet-1.2.3.zip
|
6
5
|
# ToDo: replace zip cmds with ruby zip lib to avoid shelling out
|
7
6
|
|
8
7
|
module Rake
|
@@ -10,26 +9,28 @@ module Rake
|
|
10
9
|
class Puppet
|
11
10
|
|
12
11
|
attr_accessor :module_path, :excluded_modules
|
13
|
-
attr_accessor :package_dir, :package_files, :package_version
|
12
|
+
attr_accessor :package_dir, :package_files, :package_version, :package_versioning
|
14
13
|
|
15
|
-
@module_path
|
16
|
-
@excluded_dirs
|
17
|
-
@excluded_modules
|
18
|
-
@package_dir
|
19
|
-
@package_files
|
20
|
-
@package_name
|
21
|
-
@package_version
|
14
|
+
@module_path # (string) The directory containing all the modules to test
|
15
|
+
@excluded_dirs # (string[]) Directories excluded from rspec search
|
16
|
+
@excluded_modules # (string[]) Modules excluded from rspec testing
|
17
|
+
@package_dir # (string) Where the puppet zip package will be created
|
18
|
+
@package_files # (string[]) Files and directories to include in the package
|
19
|
+
@package_name # (string) Name of the package
|
20
|
+
@package_version # (string) The version of the package (e.g. 2.1.0)
|
21
|
+
@package_versioning # (boolean) Is the version included in the package name?
|
22
22
|
|
23
23
|
def initialize
|
24
24
|
extend Rake::DSL # makes 'namespace' and 'task' methods available to instance
|
25
25
|
|
26
|
-
@module_path
|
27
|
-
@excluded_dirs
|
28
|
-
@excluded_modules
|
29
|
-
@package_dir
|
30
|
-
@package_files
|
31
|
-
@package_name
|
32
|
-
@package_version
|
26
|
+
@module_path = 'modules' # Deliberately excludes modules-lib dir
|
27
|
+
@excluded_dirs = ['.', '..']
|
28
|
+
@excluded_modules = []
|
29
|
+
@package_dir = 'pkg'
|
30
|
+
@package_files = ['modules', 'modules-lib', 'config/environment.conf']
|
31
|
+
@package_name = 'puppet'
|
32
|
+
@package_version = nil
|
33
|
+
@package_versioning = true
|
33
34
|
end
|
34
35
|
|
35
36
|
def load_tasks
|
@@ -71,10 +72,12 @@ module Rake
|
|
71
72
|
|
72
73
|
raise(ArgumentError, 'Please provide a package_version (e.g. "1.0.0")') if @package_version.nil?
|
73
74
|
|
74
|
-
|
75
|
+
# The build_dir (i.e. 'puppet') is the root dir of the files when the zip is extracted
|
76
|
+
build_dir = "#{@package_dir}/puppet"
|
77
|
+
full_package_name = @package_versioning ? "puppet-#{@package_version}.zip" : 'puppet.zip'
|
78
|
+
package_desc = @package_versioning ? full_package_name : "#{full_package_name} v#{@package_version}"
|
75
79
|
|
76
|
-
|
77
|
-
build_dir = "#{@package_dir}/puppet"
|
80
|
+
namespace :build do
|
78
81
|
|
79
82
|
# Preps build directory
|
80
83
|
task :prep do
|
@@ -94,7 +97,7 @@ module Rake
|
|
94
97
|
task :package => [:prep] do
|
95
98
|
# Exclude modules' spec directories as they're not needed once deployed
|
96
99
|
exclude_patterns = '-x puppet/modules/\*/spec/\* puppet/modules-lib/\*/spec/\*'
|
97
|
-
cmds = ["cd #{@package_dir}", '&&', "zip -qr #{
|
100
|
+
cmds = ["cd #{@package_dir}", '&&', "zip -qr #{full_package_name} . #{exclude_patterns}", '&&', 'cd -']
|
98
101
|
puts `#{cmds.join(' ')}`
|
99
102
|
end
|
100
103
|
|
@@ -104,12 +107,12 @@ module Rake
|
|
104
107
|
end
|
105
108
|
end
|
106
109
|
|
107
|
-
desc "Build #{
|
110
|
+
desc "Build #{package_desc} without tests"
|
108
111
|
task :quick_build => ['build:package', 'build:cleanup'] do
|
109
|
-
puts "Built #{
|
112
|
+
puts "Built #{package_desc}"
|
110
113
|
end
|
111
114
|
|
112
|
-
desc "Build #{
|
115
|
+
desc "Build #{package_desc}"
|
113
116
|
task :build => [:spec, :quick_build]
|
114
117
|
end
|
115
118
|
|
data/rspec-puppet-utils.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
Gem::Specification.new do |gem|
|
3
3
|
gem.name = 'rspec-puppet-utils'
|
4
|
-
gem.version = '3.
|
4
|
+
gem.version = '3.1.0'
|
5
5
|
gem.description = 'Helper classes for mock/stub functions, templates and hieradata'
|
6
6
|
gem.summary = ''
|
7
7
|
gem.author = 'Tom Poulton'
|
@@ -9,6 +9,13 @@ describe Rake::Puppet do
|
|
9
9
|
|
10
10
|
let(:puppet) { Rake::Puppet.new }
|
11
11
|
|
12
|
+
it 'allows adding to package_files list' do
|
13
|
+
initial_count = puppet.package_files.count
|
14
|
+
puppet.package_files << 'extra_file'
|
15
|
+
expect(puppet.package_files).to include 'extra_file'
|
16
|
+
expect(puppet.package_files.count).to eq initial_count + 1
|
17
|
+
end
|
18
|
+
|
12
19
|
describe 'load_spec_tasks' do
|
13
20
|
|
14
21
|
before(:each) do
|
@@ -45,20 +52,42 @@ describe Rake::Puppet do
|
|
45
52
|
let(:package_version) { '1.2.3' }
|
46
53
|
before(:each) {
|
47
54
|
puppet.package_version = package_version
|
48
|
-
puppet.load_build_tasks
|
49
55
|
}
|
50
56
|
|
51
57
|
it 'loads the "build" task' do
|
58
|
+
puppet.load_build_tasks
|
52
59
|
expect(Rake::Task.task_defined?(:build)).to eq true
|
53
60
|
end
|
54
61
|
|
55
62
|
it 'loads the "quick_build" task' do
|
63
|
+
puppet.load_build_tasks
|
56
64
|
expect(Rake::Task.task_defined?(:quick_build)).to eq true
|
57
65
|
end
|
58
66
|
|
59
|
-
it 'includes package_version in
|
67
|
+
it 'includes package_version in package name' do
|
68
|
+
puppet.load_build_tasks
|
60
69
|
build_task = Rake::Task[:build]
|
61
|
-
expect(build_task.application.last_description).to match /
|
70
|
+
expect(build_task.application.last_description).to match /puppet-#{package_version}.zip/
|
71
|
+
end
|
72
|
+
|
73
|
+
context 'when package_versioning is turned off' do
|
74
|
+
|
75
|
+
before(:each) do
|
76
|
+
puppet.package_versioning = false
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'omits the version from the package name' do
|
80
|
+
puppet.load_build_tasks
|
81
|
+
build_task = Rake::Task[:build]
|
82
|
+
expect(build_task.application.last_description).to match /puppet.zip/
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'includes the version in the task description' do
|
86
|
+
puppet.load_build_tasks
|
87
|
+
build_task = Rake::Task[:build]
|
88
|
+
expect(build_task.application.last_description).to match /v#{package_version}/
|
89
|
+
end
|
90
|
+
|
62
91
|
end
|
63
92
|
|
64
93
|
end
|
data/spec/require_spec.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-puppet-utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Poulton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-02-
|
11
|
+
date: 2017-02-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: puppet
|