onceover 3.3.3 → 3.4.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/README.md +11 -1
- data/lib/onceover/testconfig.rb +13 -9
- data/onceover.gemspec +1 -1
- data/templates/test_spec.rb.erb +16 -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: fbd681c6ca1d609e55aee2198acff4fa441202f0
|
4
|
+
data.tar.gz: 29cdca53f97cfa82509f52352b0290b36f00b513
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 57c18aa22e76170b33ebb9d69d18b719cbd19632947dc0d7a76b299db15e11673ce8349c548c385588ba3a5a335b3ad95532fd833aebb51319dc0481cd58d506
|
7
|
+
data.tar.gz: f804fd467e69d54b70f1109bb6492b17d583cd8aca62fd6f16fb4ad3a6edb7d9ea8985771822bc58cf612cad42573d4e9a6f5900a588b867045547cd681d5fed
|
data/README.md
CHANGED
@@ -110,10 +110,20 @@ Why an array of hashes? Well, that is so that we can refer to the same node or n
|
|
110
110
|
|
111
111
|
In the example below we have referred to `centos6a` and `centos7b` in all of our tests as they are in `all_nodes`, `non_windows_servers` and `centos_severs`. However we have *left the more specific references to last*. This is because entries in the test_matrix will override entries above them if applicable. Meaning that we are still only testing each class on the two Centos servers once (Because the gem does de-duplication before running the tests), but also making sure we run `roles::frontend_webserver` twice before checking for idempotency.
|
112
112
|
|
113
|
-
**functions** In this section we can add functions that we want to mock when running spec tests. Each function takes the following
|
113
|
+
**functions** In this section we can add functions that we want to mock when running spec tests. Each function takes the following arguments:
|
114
114
|
- **type** *statement or rvalue*
|
115
115
|
- **returns** *Optional: A value to return*
|
116
116
|
|
117
|
+
**before and after conditions** We can set `before` and `after` blocks before each spec test. These are usually used when the functions to stub are conditional: stub functionx if the OS is windows, stub functiony if the fact java_installed is true. The facts are available through the `node_facts` hash.
|
118
|
+
|
119
|
+
```yaml
|
120
|
+
before:
|
121
|
+
- "Puppet::Util::Platform.stubs(:'windows?').returns(node_facts['kernel'] == 'windows')"
|
122
|
+
|
123
|
+
after:
|
124
|
+
- "puts 'Test finished running'"
|
125
|
+
```
|
126
|
+
|
117
127
|
**opts** The `opts` section overrides defaults for the `Onceover::Controlrepo` class' `opts` hash.
|
118
128
|
|
119
129
|
```yaml
|
data/lib/onceover/testconfig.rb
CHANGED
@@ -23,6 +23,8 @@ class Onceover
|
|
23
23
|
attr_accessor :filter_classes
|
24
24
|
attr_accessor :filter_nodes
|
25
25
|
attr_accessor :mock_functions
|
26
|
+
attr_accessor :before_conditions
|
27
|
+
attr_accessor :after_conditions
|
26
28
|
attr_accessor :skip_r10k
|
27
29
|
attr_accessor :strict_variables
|
28
30
|
|
@@ -35,15 +37,17 @@ class Onceover
|
|
35
37
|
raise "Could not parse #{file}, check that it is valid YAML and that the encoding is correct"
|
36
38
|
end
|
37
39
|
|
38
|
-
@classes
|
39
|
-
@nodes
|
40
|
-
@node_groups
|
41
|
-
@class_groups
|
42
|
-
@spec_tests
|
43
|
-
@acceptance_tests
|
44
|
-
@opts
|
45
|
-
@mock_functions
|
46
|
-
@
|
40
|
+
@classes = []
|
41
|
+
@nodes = []
|
42
|
+
@node_groups = []
|
43
|
+
@class_groups = []
|
44
|
+
@spec_tests = []
|
45
|
+
@acceptance_tests = []
|
46
|
+
@opts = opts
|
47
|
+
@mock_functions = config['functions']
|
48
|
+
@before_conditions = config['before']
|
49
|
+
@after_conditions = config['after']
|
50
|
+
@strict_variables = opts[:strict_variables] ? 'yes' : 'no'
|
47
51
|
|
48
52
|
# Initialise all of the classes and nodes
|
49
53
|
config['classes'].each { |clarse| Onceover::Class.new(clarse) } unless config['classes'] == nil
|
data/onceover.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
6
6
|
s.name = "onceover"
|
7
|
-
s.version = "3.
|
7
|
+
s.version = "3.4.0"
|
8
8
|
s.authors = ["Dylan Ratcliffe"]
|
9
9
|
s.email = ["dylan.ratcliffe@puppet.com"]
|
10
10
|
s.homepage = "https://github.com/dylanratcliffe/onceover"
|
data/templates/test_spec.rb.erb
CHANGED
@@ -18,7 +18,22 @@ let!(:<%= function %>) { MockFunction.new('<%= function %>') { |f|
|
|
18
18
|
<% end -%>
|
19
19
|
<% test.nodes.each do |node| -%>
|
20
20
|
context "using fact set <%= node.name %>" do
|
21
|
-
|
21
|
+
node_facts = <%= node.fact_set %>
|
22
|
+
let(:facts) { node_facts }
|
23
|
+
<% if @before_conditions -%>
|
24
|
+
before :each do
|
25
|
+
<% @before_conditions.each do |function| -%>
|
26
|
+
<%= function %>
|
27
|
+
<% end -%>
|
28
|
+
end
|
29
|
+
<% end -%>
|
30
|
+
<% if @after_conditions -%>
|
31
|
+
after :each do
|
32
|
+
<% @after_conditions.each do |function| -%>
|
33
|
+
<%= function %>
|
34
|
+
<% end -%>
|
35
|
+
end
|
36
|
+
<% end -%>
|
22
37
|
<% if pre_condition -%>
|
23
38
|
let(:pre_condition) {
|
24
39
|
pp = <%= '<<' %>-END
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: onceover
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dylan Ratcliffe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-02-
|
11
|
+
date: 2018-02-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|