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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e1b2a6f102ca870df851cd6b7e8b3fe181466d71
4
- data.tar.gz: fbf64c3b18cda7e63ffd17261dae625ecd7dab38
3
+ metadata.gz: dfe83006bafdc547d6c9273c69557da9e14c997b
4
+ data.tar.gz: d96e02b801e4f3ceb54cef275a0b91a68dec29f5
5
5
  SHA512:
6
- metadata.gz: f14eb73db5ebfe8cf67ff076159ef9ba3dc1bd9fe6ff0082a0780be50475316e799a7c9108db91e51ee0130cd2bf23193894550f4a658b882045a4eab61ff6ff
7
- data.tar.gz: 656f782afe6f0ce5b44b57a5cc77e0a7a60dbd0565885a884bf10c7012fa218e5389a3832497f7a77af1e3710541dccd9794c5545266d86f84d93a56264e4c27
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
- res[:subject] = catalog.resource(res[:subject].to_s)
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 = "Makes assertions on the state of a resource in the catalog.
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 intended to prove.
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\n"
33
+ yellow "Evaluated 1 assertion"
34
+ newline
34
35
  else
35
- yellow "Evaluated #{reporter.evaluated} assertions\n"
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.0
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-08 00:00:00.000000000 Z
11
+ date: 2015-09-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: puppet