rspec-puppet-utils 2.0.5 → 2.0.6
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 +5 -5
- data/README.md +1 -1
- data/lib/hieradata/yaml_validator.rb +8 -4
- data/rspec-puppet-utils.gemspec +1 -1
- data/spec/classes/hieradata/yaml_validator_spec.rb +14 -6
- data/spec/fixtures/hieradata/invalid/invalid.yaml +2 -2
- data/spec/fixtures/hieradata/valid/sub2/nested.dot.yaml +2 -0
- data/spec/fixtures/hieradata/valid/sub2/nested.dot.yml +2 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
SHA1:
|
3
|
-
data.tar.gz: 9c4d6d2970af159ab900e47f39b656d0fef11739
|
4
|
-
metadata.gz: 946d6dec16dcfa5ee307065eea16b1b84dc6aaa8
|
5
2
|
SHA512:
|
6
|
-
|
7
|
-
|
3
|
+
metadata.gz: 106fa2607e4f29ce28dee277ad33e57af9172a0950ff6d7e1603aced6853511a71dc826e56e9224865d8671437a1e531b6d64fc89f5551b5e7224a062988d88c
|
4
|
+
data.tar.gz: faa7027e9499454bf5ae605921f64356485385025b5da3b290bf2bb37cd48435237d42cbf8d185f99d56d5a17e2c9ad6d754c7e242b829e31dc52a2b9e9a9b61
|
5
|
+
SHA1:
|
6
|
+
metadata.gz: f268650abcc12899be821391c1c8442983cbecb8
|
7
|
+
data.tar.gz: 962eb0d4da79073e942b5e8000a34abf2b5eb491
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
This is a more refined version of a previous project about [rspec-puppet unit testing](https://github.com/TomPoulton/rspec-puppet-unit-testing), it provides a class for mocking functions, a harness for testing templates, and a simple tool for testing hiera data files. The motivation for mocking functions etc is provided in that project so I won't go over it here.
|
4
4
|
|
5
|
-
See [release notes
|
5
|
+
See [release notes](../../wiki/Release-Notes) about latest version
|
6
6
|
|
7
7
|
## Usage
|
8
8
|
|
@@ -29,13 +29,17 @@ module RSpecPuppetUtils
|
|
29
29
|
|
30
30
|
private
|
31
31
|
|
32
|
+
# For presentation, return just the subpath within hieradata.
|
33
|
+
# e.g., /path/hieradata/subdir/foo.yaml becomes subdir/foo.yaml
|
34
|
+
def subpath(file)
|
35
|
+
file.sub(/#{@directory}/, '').sub(/#{File::SEPARATOR}/, '')
|
36
|
+
end
|
37
|
+
|
32
38
|
def load_data_for_file(file, ignore_empty)
|
33
|
-
|
34
|
-
# Allow dots in filename i.e. thing.something.yaml
|
35
|
-
file_name = File.basename(file, File.extname(file))
|
39
|
+
file_name = subpath(file)
|
36
40
|
begin
|
37
41
|
yaml = File.open(file) { |yf| YAML::load( yf ) }
|
38
|
-
rescue
|
42
|
+
rescue => e
|
39
43
|
@load_errors.push "Error in file #{file}: #{e.message}"
|
40
44
|
return
|
41
45
|
end
|
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 = '2.0.
|
4
|
+
gem.version = '2.0.6'
|
5
5
|
gem.description = 'Helper classes for mock/stub functions, templates and hierdata'
|
6
6
|
gem.summary = ''
|
7
7
|
gem.author = 'Tom Poulton'
|
@@ -22,15 +22,23 @@ describe HieraData::YamlValidator do
|
|
22
22
|
end
|
23
23
|
|
24
24
|
it 'should load yaml files recursively' do
|
25
|
-
expect(validator.data.keys).to include :nested
|
25
|
+
expect(validator.data.keys).to include :'sub/nested.yaml'
|
26
26
|
end
|
27
27
|
|
28
28
|
it 'should load yaml data from files' do
|
29
|
-
expect(validator.data[:valid]['string-value']).to eq 'a string'
|
29
|
+
expect(validator.data[:'valid.yaml']['string-value']).to eq 'a string'
|
30
30
|
end
|
31
31
|
|
32
32
|
it 'should load yaml data from files with dot in filename' do
|
33
|
-
expect(validator.data.keys).to include :'nested.dot'
|
33
|
+
expect(validator.data.keys).to include :'sub/nested.dot.yaml'
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'should load yaml data from files with same name but different dir' do
|
37
|
+
expect(validator.data.keys).to include :'sub2/nested.dot.yaml'
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'should load yaml data from files with same name but different ext' do
|
41
|
+
expect(validator.data.keys).to include :'sub2/nested.dot.yml'
|
34
42
|
end
|
35
43
|
|
36
44
|
it 'should not add any load errors' do
|
@@ -46,7 +54,7 @@ describe HieraData::YamlValidator do
|
|
46
54
|
validator.load_data
|
47
55
|
|
48
56
|
it 'should load yml files into data' do
|
49
|
-
expect(validator.data).to have_key :other
|
57
|
+
expect(validator.data).to have_key :'other.foo'
|
50
58
|
end
|
51
59
|
|
52
60
|
end
|
@@ -105,7 +113,7 @@ describe HieraData::YamlValidator do
|
|
105
113
|
|
106
114
|
it 'should add non empty files to data' do
|
107
115
|
validator.load_data :ignore_empty
|
108
|
-
expect(validator.data.keys).to include :not_empty
|
116
|
+
expect(validator.data.keys).to include :'not_empty.yaml'
|
109
117
|
end
|
110
118
|
|
111
119
|
end
|
@@ -126,7 +134,7 @@ describe HieraData::YamlValidator do
|
|
126
134
|
|
127
135
|
it 'should support old #load method' do
|
128
136
|
expect { validator.load true }.to_not raise_error
|
129
|
-
expect(validator.data.keys).to include :not_empty
|
137
|
+
expect(validator.data.keys).to include :'not_empty.yaml'
|
130
138
|
end
|
131
139
|
|
132
140
|
it 'should still throw errors if necessary' do
|
@@ -1,3 +1,3 @@
|
|
1
1
|
---
|
2
|
-
#
|
3
|
-
'hello' 'world'
|
2
|
+
# really gross yaml
|
3
|
+
{'hello') 'world'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-puppet-utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Poulton
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2015-01-
|
12
|
+
date: 2015-01-16 00:00:00 Z
|
13
13
|
dependencies: []
|
14
14
|
|
15
15
|
description: Helper classes for mock/stub functions, templates and hierdata
|
@@ -42,6 +42,8 @@ files:
|
|
42
42
|
- spec/fixtures/hieradata/valid/other.foo
|
43
43
|
- spec/fixtures/hieradata/valid/sub/nested.dot.yaml
|
44
44
|
- spec/fixtures/hieradata/valid/sub/nested.yaml
|
45
|
+
- spec/fixtures/hieradata/valid/sub2/nested.dot.yaml
|
46
|
+
- spec/fixtures/hieradata/valid/sub2/nested.dot.yml
|
45
47
|
- spec/fixtures/hieradata/valid/valid.yaml
|
46
48
|
- spec/fixtures/templates/returns_elephant.erb
|
47
49
|
- spec/spec_helper.rb
|
@@ -83,6 +85,8 @@ test_files:
|
|
83
85
|
- spec/fixtures/hieradata/valid/other.foo
|
84
86
|
- spec/fixtures/hieradata/valid/sub/nested.dot.yaml
|
85
87
|
- spec/fixtures/hieradata/valid/sub/nested.yaml
|
88
|
+
- spec/fixtures/hieradata/valid/sub2/nested.dot.yaml
|
89
|
+
- spec/fixtures/hieradata/valid/sub2/nested.dot.yml
|
86
90
|
- spec/fixtures/hieradata/valid/valid.yaml
|
87
91
|
- spec/fixtures/templates/returns_elephant.erb
|
88
92
|
- spec/spec_helper.rb
|