puppet-spec 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/puppet/application/spec.rb +9 -3
- data/lib/puppet/type/assertion.rb +2 -6
- data/lib/puppet/util/assertion/reporter.rb +26 -2
- 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: dfe83006bafdc547d6c9273c69557da9e14c997b
|
4
|
+
data.tar.gz: d96e02b801e4f3ceb54cef275a0b91a68dec29f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2c2b240d52d96c39bad354306d011fccdc82e002fccb7a34730f12fdca12ce2cc8cd7395464fbd49ef60ad6d4c093074ffef804307f10c60d9ef3ea796ec848
|
7
|
+
data.tar.gz: 6b0cc48d798e60fca66f146c59e59be7b1b6770cf1949e0036a6fc11ca04870ab097c430d70ba646396bc677836380f95f7cc5e0af66026bc078eef74230762b
|
@@ -38,15 +38,21 @@ class Puppet::Application::Spec < Puppet::Application
|
|
38
38
|
|
39
39
|
def process_spec(path)
|
40
40
|
catalog = catalog(path)
|
41
|
-
assertions = catalog.resources.select {|res| res.type == 'Assertion' }
|
42
41
|
|
42
|
+
assertions = catalog.resources.select {|res| res.type == 'Assertion' }
|
43
43
|
assertions.each do |res|
|
44
44
|
# Get the subject resource from the catalog rather than the
|
45
45
|
# reference provided from the parser. The reference's resource
|
46
46
|
# object does not contain any parameters for whatever reason.
|
47
|
-
|
47
|
+
catalog_subject = catalog.resource(res[:subject].to_s)
|
48
|
+
|
49
|
+
if catalog_subject
|
50
|
+
res[:subject] = catalog_subject
|
51
|
+
reporter << res.to_ral
|
52
|
+
else
|
53
|
+
reporter.missing_subject(res)
|
54
|
+
end
|
48
55
|
|
49
|
-
reporter << res.to_ral
|
50
56
|
end
|
51
57
|
end
|
52
58
|
|
@@ -1,10 +1,6 @@
|
|
1
1
|
Puppet::Type.newtype(:assertion) do
|
2
2
|
|
3
|
-
@doc = "
|
4
|
-
|
5
|
-
The assertion type defines an assertion that will be evaluated by the
|
6
|
-
spec application.
|
7
|
-
"
|
3
|
+
@doc = "An assertion on the state of a resource in the catalog"
|
8
4
|
|
9
5
|
validate do
|
10
6
|
fail Puppet::Error, "a subject is required" unless @parameters[:subject]
|
@@ -13,7 +9,7 @@ Puppet::Type.newtype(:assertion) do
|
|
13
9
|
end
|
14
10
|
|
15
11
|
newparam(:name) do
|
16
|
-
desc "A plain text message describing what the assertion is
|
12
|
+
desc "A plain text message describing what the assertion is attempting to prove.
|
17
13
|
|
18
14
|
The given text should form a sentence using the type's name.
|
19
15
|
Example: assertion { 'that the configuration file has the correct contents': }
|
@@ -30,9 +30,11 @@ module Puppet::Util
|
|
30
30
|
|
31
31
|
style do
|
32
32
|
if reporter.evaluated == 1
|
33
|
-
yellow "Evaluated 1 assertion
|
33
|
+
yellow "Evaluated 1 assertion"
|
34
|
+
newline
|
34
35
|
else
|
35
|
-
yellow "Evaluated #{reporter.evaluated} assertions
|
36
|
+
yellow "Evaluated #{reporter.evaluated} assertions"
|
37
|
+
newline
|
36
38
|
end
|
37
39
|
end
|
38
40
|
end
|
@@ -41,6 +43,28 @@ module Puppet::Util
|
|
41
43
|
fail #Mark an assertion so the application exits 1
|
42
44
|
style do
|
43
45
|
red err.message
|
46
|
+
newline
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
# Print the appropriate error message when an assertion's
|
51
|
+
# subject is not found in the catalog. Called by the application
|
52
|
+
# because the resource must be evaluated prior to calling
|
53
|
+
# .to_ral to avoid the validation raising an error.
|
54
|
+
def missing_subject(assertion)
|
55
|
+
fail
|
56
|
+
|
57
|
+
# Shim the value of failed into the
|
58
|
+
# local scope in order to access it
|
59
|
+
# from the style proc.
|
60
|
+
failed = @failed
|
61
|
+
|
62
|
+
style do
|
63
|
+
red "#{failed}) Assertion #{assertion[:name]} failed on #{assertion[:subject].to_s}"
|
64
|
+
newline
|
65
|
+
blue " Subject was not in the catalog"
|
66
|
+
newline
|
67
|
+
newline
|
44
68
|
end
|
45
69
|
end
|
46
70
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: puppet-spec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jordan Olshevski
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-09-
|
11
|
+
date: 2015-09-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: puppet
|