rspec-puppet-facts 0.2.1 → 0.2.2
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/.gitignore +2 -0
- data/.rspec +4 -0
- data/.travis.yml +25 -0
- data/CHANGELOG.md +4 -0
- data/Gemfile +4 -1
- data/README.md +44 -3
- data/Rakefile +5 -0
- data/lib/rspec-puppet-facts.rb +7 -6
- data/lib/rspec-puppet-facts/version.rb +1 -1
- data/spec/fixtures/metadata.json +42 -0
- data/spec/rspec_puppet_facts_spec.rb +100 -0
- data/spec/spec_helper.rb +8 -0
- metadata +7 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 854e99fe14fb999a75972ef8514595b06ff02ec6
|
4
|
+
data.tar.gz: 74aff87a118d7f8d93786acf2d6d26f2d5f8aefc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9bee90cd268e6193725f2daa5158f8bcf724ccde3222eb581e6bbd7a409d022a157df3855b19789182f9ab767ad5ea6f995a8584aef6f53e922ca52690d8f3f8
|
7
|
+
data.tar.gz: dd59f80cae1f4c2bf41ed9eecf680657b6f117c630f665c22aca4d22b19498226a889dd0f0484d90583557d38ece37a01467b0dc343b0b8ba712a8f9805ffca3
|
data/.gitignore
CHANGED
data/.rspec
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
---
|
2
|
+
language: ruby
|
3
|
+
sudo: false
|
4
|
+
cache:
|
5
|
+
directories:
|
6
|
+
- vendor/bundle
|
7
|
+
bundler_args: --path vendor/bundle
|
8
|
+
script:
|
9
|
+
- bundle exec rake spec
|
10
|
+
rvm:
|
11
|
+
- 1.8.7
|
12
|
+
- 1.9.3
|
13
|
+
- 2.0.0
|
14
|
+
- 2.1.5
|
15
|
+
env:
|
16
|
+
- FACTER_GEM_VERSION="~> 1.6.0"
|
17
|
+
- FACTER_GEM_VERSION="~> 1.7.0"
|
18
|
+
- FACTER_GEM_VERSION="~> 2.0.0"
|
19
|
+
- FACTER_GEM_VERSION="~> 2.1.0"
|
20
|
+
- FACTER_GEM_VERSION="~> 2.2.0"
|
21
|
+
- FACTER_GEM_VERSION="~> 2.3.0"
|
22
|
+
matrix:
|
23
|
+
fast_finish: true
|
24
|
+
notifications:
|
25
|
+
email: false
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
@@ -1,7 +1,10 @@
|
|
1
1
|
source ENV['GEM_SOURCE'] || "https://rubygems.org"
|
2
2
|
|
3
3
|
group :development, :test do
|
4
|
-
gem '
|
4
|
+
gem 'json', :require => false
|
5
|
+
gem 'mocha', :require => false
|
6
|
+
gem 'rake', :require => false
|
7
|
+
gem 'rspec', :require => false
|
5
8
|
end
|
6
9
|
|
7
10
|
if facterversion = ENV['FACTER_GEM_VERSION']
|
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
rspec-puppet-facts
|
2
2
|
==================
|
3
3
|
|
4
|
+
[](https://travis-ci.org/mcanevet/rspec-puppet-facts)
|
5
|
+
|
4
6
|
Based on an original idea from [apenney](https://github.com/apenney/puppet_facts/).
|
5
7
|
|
6
8
|
Simplify your unit tests by looping on every supported Operating System and populating facts.
|
@@ -81,7 +83,22 @@ describe 'myclass' do
|
|
81
83
|
|
82
84
|
on_supported_os({
|
83
85
|
:hardwaremodels => ['i386', 'x86_64'],
|
84
|
-
:supported_os => [
|
86
|
+
:supported_os => [
|
87
|
+
{
|
88
|
+
"operatingsystem" => "Debian",
|
89
|
+
"operatingsystemrelease" => [
|
90
|
+
"6",
|
91
|
+
"7"
|
92
|
+
]
|
93
|
+
},
|
94
|
+
{
|
95
|
+
"operatingsystem" => "RedHat",
|
96
|
+
"operatingsystemrelease" => [
|
97
|
+
"5",
|
98
|
+
"6"
|
99
|
+
]
|
100
|
+
}
|
101
|
+
],
|
85
102
|
}).each do |os, facts|
|
86
103
|
context "on #{os}" do
|
87
104
|
let(:facts) do
|
@@ -156,8 +173,32 @@ matrix:
|
|
156
173
|
...
|
157
174
|
```
|
158
175
|
|
159
|
-
|
160
|
-
|
176
|
+
Operating Systems and facter versions supported
|
177
|
+
-----------------------------------------------
|
178
|
+
|
179
|
+
| 1.6 | 1.7 | 2.0 | 2.1 | 2.2 | 2.3
|
180
|
+
-------------|-----|-----|-----|-----|-----|-----
|
181
|
+
CentOS 5 | Y | Y | Y | Y | Y | Y
|
182
|
+
CentOS 6 | Y | Y | Y | Y | Y | Y
|
183
|
+
CentOS 7 | Y | Y | Y | Y | Y | Y
|
184
|
+
Debian 6 | Y | Y | Y | Y | Y | Y
|
185
|
+
Debian 7 | Y | Y | Y | Y | Y | Y
|
186
|
+
Debian 8 | N | N | Y | Y | Y | Y
|
187
|
+
Fedora 19 | Y | Y | Y | Y | Y | Y
|
188
|
+
Oracle 5 | Y | Y | Y | Y | Y | Y
|
189
|
+
Oracle 6 | Y | Y | Y | Y | Y | Y
|
190
|
+
Oracle 7 | Y | Y | Y | Y | Y | Y
|
191
|
+
RedHat 5 | Y | Y | Y | Y | Y | Y
|
192
|
+
RedHat 6 | Y | Y | Y | Y | Y | Y
|
193
|
+
RedHat 7 | Y | Y | Y | Y | Y | Y
|
194
|
+
Scientific 5 | Y | Y | Y | Y | Y | Y
|
195
|
+
Scientific 6 | Y | Y | Y | Y | Y | Y
|
196
|
+
Scientific 7 | Y | Y | Y | Y | Y | Y
|
197
|
+
Ubuntu 12.04 | Y | Y | Y | Y | Y | Y
|
198
|
+
Ubuntu 14.04 | Y | Y | Y | Y | Y | Y
|
199
|
+
|
200
|
+
Add new Operating System support
|
201
|
+
--------------------------------
|
161
202
|
|
162
203
|
There is `Vagrantfile` to automagically populate `facts` directory by spawning a new VM and launches a provisioning scripts.
|
163
204
|
|
data/Rakefile
ADDED
data/lib/rspec-puppet-facts.rb
CHANGED
@@ -3,12 +3,10 @@ require 'json'
|
|
3
3
|
|
4
4
|
module RspecPuppetFacts
|
5
5
|
|
6
|
-
def on_supported_os(
|
7
|
-
opts
|
8
|
-
|
9
|
-
|
10
|
-
}
|
11
|
-
)
|
6
|
+
def on_supported_os( opts = {} )
|
7
|
+
opts[:hardwaremodels] ||= ['x86_64']
|
8
|
+
opts[:supported_os] ||= RspecPuppetFacts.meta_supported_os
|
9
|
+
|
12
10
|
h = {}
|
13
11
|
|
14
12
|
opts[:supported_os].map do |os_sup|
|
@@ -20,6 +18,9 @@ module RspecPuppetFacts
|
|
20
18
|
# TODO: use SemVer here
|
21
19
|
facter_minor_version = Facter.version[0..2]
|
22
20
|
file = File.expand_path(File.join(File.dirname(__FILE__), "../facts/#{facter_minor_version}/#{os}.facts"))
|
21
|
+
if ! File.file?(file)
|
22
|
+
fail StandardError, "Can't find facts for '#{os}' for facter #{facter_minor_version}"
|
23
|
+
end
|
23
24
|
File.read(file).each_line do |line|
|
24
25
|
key, value = line.split(' => ')
|
25
26
|
facts[key.to_sym] = value.chomp unless value.nil?
|
@@ -0,0 +1,42 @@
|
|
1
|
+
{
|
2
|
+
"name": "mcanevet-mymodule",
|
3
|
+
"version": "1.0.0",
|
4
|
+
"author": "Mickaël Canévet",
|
5
|
+
"summary": "My puppet modules",
|
6
|
+
"license": "Apache-2.0",
|
7
|
+
"source": "https://github.com/mcanevet/puppet-mymodule",
|
8
|
+
"project_page": "https://github.com/mcanevet/puppet-mymodule",
|
9
|
+
"issues_url": "https://github.com/mcanevet/puppet-mymodule/issues",
|
10
|
+
"dependencies": [
|
11
|
+
],
|
12
|
+
"requirements": [
|
13
|
+
],
|
14
|
+
"operatingsystem_support": [
|
15
|
+
{
|
16
|
+
"operatingsystem": "Debian",
|
17
|
+
"operatingsystemrelease": [
|
18
|
+
"6",
|
19
|
+
"7"
|
20
|
+
]
|
21
|
+
},
|
22
|
+
{
|
23
|
+
"operatingsystem": "RedHat",
|
24
|
+
"operatingsystemrelease": [
|
25
|
+
"5",
|
26
|
+
"6",
|
27
|
+
"7"
|
28
|
+
]
|
29
|
+
}
|
30
|
+
],
|
31
|
+
"puppet_version": [
|
32
|
+
"2.7",
|
33
|
+
"3.0",
|
34
|
+
"3.1",
|
35
|
+
"3.2",
|
36
|
+
"3.3",
|
37
|
+
"3.4",
|
38
|
+
"3.5",
|
39
|
+
"3.6",
|
40
|
+
"3.7"
|
41
|
+
]
|
42
|
+
}
|
@@ -0,0 +1,100 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'RspecPuppetFacts' do
|
4
|
+
|
5
|
+
describe '#on_supported_os' do
|
6
|
+
|
7
|
+
context 'Without parameter' do
|
8
|
+
subject { on_supported_os() }
|
9
|
+
|
10
|
+
context 'Without metadata.json' do
|
11
|
+
it 'should fail' do
|
12
|
+
expect { subject }.to raise_error(StandardError)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'With a metadata.json' do
|
17
|
+
fixture = File.read('spec/fixtures/metadata.json')
|
18
|
+
File.stubs('file?')
|
19
|
+
File.stubs('read')
|
20
|
+
File.expects('file?').with('metadata.json').returns true
|
21
|
+
File.expects('read').with('metadata.json').returns fixture
|
22
|
+
it 'should return a hash' do
|
23
|
+
expect( on_supported_os().class ).to eq Hash
|
24
|
+
end
|
25
|
+
it 'should have 5 elements' do
|
26
|
+
expect(subject.size).to eq 5
|
27
|
+
end
|
28
|
+
it 'should return supported OS' do
|
29
|
+
expect(subject.keys.sort).to eq [
|
30
|
+
'debian-6-x86_64',
|
31
|
+
'debian-7-x86_64',
|
32
|
+
'redhat-5-x86_64',
|
33
|
+
'redhat-6-x86_64',
|
34
|
+
'redhat-7-x86_64',
|
35
|
+
]
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
context 'When specifying supported_os' do
|
41
|
+
subject {
|
42
|
+
on_supported_os(
|
43
|
+
{
|
44
|
+
:supported_os => [
|
45
|
+
{
|
46
|
+
"operatingsystem" => "Debian",
|
47
|
+
"operatingsystemrelease" => [
|
48
|
+
"6",
|
49
|
+
"7"
|
50
|
+
]
|
51
|
+
},
|
52
|
+
{
|
53
|
+
"operatingsystem" => "RedHat",
|
54
|
+
"operatingsystemrelease" => [
|
55
|
+
"5",
|
56
|
+
"6"
|
57
|
+
]
|
58
|
+
}
|
59
|
+
]
|
60
|
+
}
|
61
|
+
)
|
62
|
+
}
|
63
|
+
it 'should return a hash' do
|
64
|
+
expect(subject.class).to eq Hash
|
65
|
+
end
|
66
|
+
it 'should have 4 elements' do
|
67
|
+
expect(subject.size).to eq 4
|
68
|
+
end
|
69
|
+
it 'should return supported OS' do
|
70
|
+
expect(subject.keys.sort).to eq [
|
71
|
+
'debian-6-x86_64',
|
72
|
+
'debian-7-x86_64',
|
73
|
+
'redhat-5-x86_64',
|
74
|
+
'redhat-6-x86_64',
|
75
|
+
]
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
context 'When specifying wrong supported_os' do
|
80
|
+
subject {
|
81
|
+
on_supported_os(
|
82
|
+
{
|
83
|
+
:supported_os => [
|
84
|
+
{
|
85
|
+
"operatingsystem" => "Debian",
|
86
|
+
"operatingsystemrelease" => [
|
87
|
+
"4",
|
88
|
+
],
|
89
|
+
},
|
90
|
+
]
|
91
|
+
}
|
92
|
+
)
|
93
|
+
}
|
94
|
+
|
95
|
+
it 'should fail' do
|
96
|
+
expect { subject }.to raise_error(StandardError, /Can't find facts for 'debian-4-x86_64'/)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-puppet-facts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mickaël Canévet
|
@@ -18,9 +18,12 @@ extensions: []
|
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
20
|
- ".gitignore"
|
21
|
+
- ".rspec"
|
22
|
+
- ".travis.yml"
|
21
23
|
- CHANGELOG.md
|
22
24
|
- Gemfile
|
23
25
|
- README.md
|
26
|
+
- Rakefile
|
24
27
|
- Vagrantfile
|
25
28
|
- facts/1.6/centos-5-i386.facts
|
26
29
|
- facts/1.6/centos-5-x86_64.facts
|
@@ -238,6 +241,9 @@ files:
|
|
238
241
|
- lib/rspec-puppet-facts.rb
|
239
242
|
- lib/rspec-puppet-facts/version.rb
|
240
243
|
- rspec-puppet-facts.gemspec
|
244
|
+
- spec/fixtures/metadata.json
|
245
|
+
- spec/rspec_puppet_facts_spec.rb
|
246
|
+
- spec/spec_helper.rb
|
241
247
|
homepage: http://github.com/mcanevet/rspec-puppet-facts
|
242
248
|
licenses:
|
243
249
|
- Apache-2.0
|