simp-rspec-puppet-facts 1.0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f42b73da013ea101eaaee7f729927cd1302d0094
4
+ data.tar.gz: 307243764caf9c137fa1c81e9779366d9e4867c9
5
+ SHA512:
6
+ metadata.gz: 9e9d1122e7136829e3980e16769be53279eba934224bc888b8f90e01968cb7decdd786765e92f6f97aacea0408d7616e576ca9214316271f21299a355f7b70a8
7
+ data.tar.gz: 450b6207e71e970cc0066ebad04cf2db0bd48effb05b6162a1303cf72b7540aa1b99253e018d3f6b893fa27c1a52ea2dd14af4b5a44967ab638f343af6ab8497
data/LICENSE ADDED
@@ -0,0 +1,25 @@
1
+ simp-rspec-puppet-facts - a shim to adapt rspec-puppet-facts for testing SIMP
2
+
3
+ Per Section 105 of the Copyright Act of 1976, these works are not entitled to
4
+ domestic copyright protection under US Federal law.
5
+
6
+ The US Government retains the right to pursue copyright protections outside of
7
+ the United States.
8
+
9
+ The United States Government has unlimited rights in this software and all
10
+ derivatives thereof, pursuant to the contracts under which it was developed and
11
+ the License under which it falls.
12
+
13
+ ---
14
+
15
+ Licensed under the Apache License, Version 2.0 (the "License");
16
+ you may not use this file except in compliance with the License.
17
+ You may obtain a copy of the License at
18
+
19
+ http://www.apache.org/licenses/LICENSE-2.0
20
+
21
+ Unless required by applicable law or agreed to in writing, software
22
+ distributed under the License is distributed on an "AS IS" BASIS,
23
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24
+ See the License for the specific language governing permissions and
25
+ limitations under the License.
data/README.md ADDED
@@ -0,0 +1,12 @@
1
+ # simp-rspec-puppet-facts
2
+
3
+ [![Build Status](https://img.shields.io/travis/simp/simp-rspec-puppet-facts/master.svg)](https://travis-ci.org/simp/simp-rspec-puppet-facts)
4
+ [![Gem Version](https://img.shields.io/gem/v/simp-rspec-puppet-facts.svg)](https://rubygems.org/gems/simp-rspec-puppet-facts)
5
+
6
+
7
+ Simplify (ahem: "SIMPlify") your unit tests by looping on every supported Operating System and populating facts.
8
+
9
+ This gem acts as a shim in front of the most excellent [mcanevet/rspec-puppet-facts](https://github.com/mcanevet/rspec-puppet-facts) and can be used as a drop-in replacement when testing for SIMP.
10
+
11
+ ## Motivation
12
+ The `on_supported_os` method provided by rspec-puppet-facts provides facts captured from actual systems (captured in a brilliantly elegant [Vagrantfile](https://github.com/mcanevet/rspec-puppet-facts/blob/master/facts/Vagrantfile)). However, many SIMP tests require additional custom facts.
data/Rakefile ADDED
@@ -0,0 +1,5 @@
1
+ begin
2
+ require 'rspec/core/rake_task'
3
+ RSpec::Core::RakeTask.new(:spec)
4
+ rescue LoadError
5
+ end
@@ -0,0 +1 @@
1
+ require 'simp/rspec-puppet-facts'
@@ -0,0 +1,57 @@
1
+ module Simp; end
2
+ module Simp::RspecPuppetFacts
3
+ VERSION = '1.0.0'
4
+
5
+ # TODO: roll this into files
6
+ def extra_os_facts
7
+ {
8
+ 'CentOS' => {
9
+ '6' => {
10
+ 'x86_64' => {
11
+ :grub_version => '0.97',
12
+ :uid_min => '500',
13
+ },
14
+ },
15
+ '7' => {
16
+ 'x86_64' => {
17
+ :grub_version => '2.02~beta2',
18
+ :uid_min => '500',
19
+ },
20
+ },
21
+ },
22
+ 'RedHat' => {
23
+ '6' => {
24
+ 'x86_64' => {
25
+ :grub_version => '0.97',
26
+ :uid_min => '500',
27
+ },
28
+ },
29
+ '7' => {
30
+ 'x86_64' => {
31
+ :grub_version => '2.02~beta2',
32
+ :uid_min => '500',
33
+ },
34
+ },
35
+ },
36
+ }
37
+ end
38
+
39
+ def on_supported_os( opts = {} )
40
+ h = Simp::RspecPuppetFacts::Shim.on_supported_os( opts )
41
+ h.each do | os, facts |
42
+ facts[:lsbmajdistrelease] = facts[:operatingsystemmajrelease]
43
+ extra_facts = extra_os_facts.fetch( facts.fetch(:operatingsystem) ).fetch( facts.fetch(:operatingsystemmajrelease) ).fetch( facts.fetch(:architecture) )
44
+ extra_opts_facts = opts.fetch( :extra_facts, {} )
45
+
46
+ facts.merge! extra_facts
47
+ facts.merge! extra_opts_facts
48
+ end
49
+
50
+ h
51
+ end
52
+
53
+ class Shim
54
+ require 'rspec-puppet-facts'
55
+ extend ::RspecPuppetFacts
56
+ end
57
+ end
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "simp-dummy",
3
+ "version": "0.1.0",
4
+ "author": "simp",
5
+ "summary": "A dummy module for testing",
6
+ "license": "Apache-2.0",
7
+ "source": "https://github.com/op-ct/pupmod-simp-dummy",
8
+ "project_page": "https://github.com/op-ct/pupmod-simp-dummy",
9
+ "issues_url": "https://github.com/op-ct/pupmod-simp-dummy/issues",
10
+ "dependencies": [
11
+ ],
12
+ "requirements": [
13
+ ],
14
+ "operatingsystem_support": [
15
+ {
16
+ "operatingsystem": "RedHat",
17
+ "operatingsystemrelease": [
18
+ "6",
19
+ "7"
20
+ ]
21
+ },
22
+ {
23
+ "operatingsystem": "CentOS",
24
+ "operatingsystemrelease": [
25
+ "6",
26
+ "7"
27
+ ]
28
+ }
29
+ ],
30
+ "puppet_version": [
31
+ "2.7",
32
+ "3.0",
33
+ "3.1",
34
+ "3.2",
35
+ "3.3",
36
+ "3.4",
37
+ "3.5",
38
+ "3.6",
39
+ "3.7"
40
+ ]
41
+ }
@@ -0,0 +1,25 @@
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
+ "puppet_version": [
15
+ "2.7",
16
+ "3.0",
17
+ "3.1",
18
+ "3.2",
19
+ "3.3",
20
+ "3.4",
21
+ "3.5",
22
+ "3.6",
23
+ "3.7"
24
+ ]
25
+ }
@@ -0,0 +1,124 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Simp::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 { expect { subject }.to raise_error(StandardError, /Can't find metadata.json/) }
12
+ end
13
+
14
+ context 'With a metadata.json' do
15
+
16
+ context 'With a broken metadata.json' do
17
+
18
+ context 'With missing operatingsystem_support section' do
19
+ before :all do
20
+ fixture = File.read('spec/fixtures/metadata.json_with_missing_operatingsystem_support')
21
+ File.expects(:file?).with('metadata.json').returns true
22
+ File.expects(:read).with('metadata.json').returns fixture
23
+ end
24
+
25
+ it { expect { subject }.to raise_error(StandardError, /Unknown operatingsystem support/) }
26
+ end
27
+ end
28
+
29
+ context 'With a valid metadata.json' do
30
+ before :all do
31
+ fixture = File.read('spec/fixtures/metadata.json')
32
+ File.expects(:file?).with('metadata.json').returns true
33
+ File.expects(:read).with('metadata.json').returns fixture
34
+ end
35
+
36
+ it 'should return a hash' do
37
+ expect( on_supported_os().class ).to eq Hash
38
+ end
39
+ it 'should have 4 elements' do
40
+ expect(subject.size).to eq 4
41
+ end
42
+ it 'should return supported OS' do
43
+ expect(subject.keys.sort).to eq [
44
+ 'centos-6-x86_64',
45
+ 'centos-7-x86_64',
46
+ 'redhat-6-x86_64',
47
+ 'redhat-7-x86_64',
48
+ ]
49
+ end
50
+ it 'should return SIMP-specific OS facts' do
51
+ expect(subject.map{ |os,data| {os =>
52
+ data.select{ |x,v| x == :uid_min || x == :grub_version }}}
53
+ ).to eq [
54
+ {"redhat-6-x86_64"=>{:grub_version=>"0.97", :uid_min=>"500"}},
55
+ {"redhat-7-x86_64"=>{:grub_version=>"2.02~beta2", :uid_min=>"500"}},
56
+ {"centos-6-x86_64"=>{:grub_version=>"0.97", :uid_min=>"500"}},
57
+ {"centos-7-x86_64"=>{:grub_version=>"2.02~beta2", :uid_min=>"500"}}
58
+ ]
59
+ end
60
+ end
61
+ end
62
+ end
63
+
64
+ context 'When specifying supported_os' do
65
+ subject {
66
+ on_supported_os(
67
+ {
68
+ :supported_os => [
69
+ {
70
+ "operatingsystem" => "RedHat",
71
+ "operatingsystemrelease" => [
72
+ "6",
73
+ "7"
74
+ ]
75
+ }
76
+ ]
77
+ }
78
+ )
79
+ }
80
+ it 'should return a hash' do
81
+ expect(subject.class).to eq Hash
82
+ end
83
+ it 'should have 2 elements' do
84
+ expect(subject.size).to eq 2
85
+ end
86
+ it 'should return supported OS' do
87
+ expect(subject.keys.sort).to eq [
88
+ 'redhat-6-x86_64',
89
+ 'redhat-7-x86_64',
90
+ ]
91
+ end
92
+ it 'should return SIMP-specific OS facts' do
93
+ expect(subject.map{ |os,data| {os =>
94
+ data.select{ |x,v| x == :uid_min || x == :grub_version }}}
95
+ ).to eq [
96
+ {"redhat-6-x86_64"=>{:grub_version=>"0.97", :uid_min=>"500"}},
97
+ {"redhat-7-x86_64"=>{:grub_version=>"2.02~beta2", :uid_min=>"500"}},
98
+ ]
99
+ end
100
+ end
101
+
102
+
103
+ context 'When specifying wrong supported_os' do
104
+ subject {
105
+ on_supported_os(
106
+ {
107
+ :supported_os => [
108
+ {
109
+ "operatingsystem" => "Debian",
110
+ "operatingsystemrelease" => [
111
+ "4",
112
+ ],
113
+ },
114
+ ]
115
+ }
116
+ )
117
+ }
118
+
119
+ it 'should output warning message' do
120
+ expect { subject }.to output(/Can't find facts for 'debian-4-x86_64'/).to_stderr
121
+ end
122
+ end
123
+ end
124
+ end
@@ -0,0 +1,11 @@
1
+ require 'coveralls'
2
+ Coveralls.wear!
3
+
4
+ require 'rspec'
5
+ require 'mocha/api'
6
+ require 'simp/rspec-puppet-facts'
7
+ include Simp::RspecPuppetFacts
8
+
9
+ RSpec.configure do |config|
10
+ config.mock_framework = :mocha
11
+ end
metadata ADDED
@@ -0,0 +1,200 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: simp-rspec-puppet-facts
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Chris Tessmer
8
+ - Mickaël Canévet
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2015-06-29 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec-puppet-facts
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '0'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: rake
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '10'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '10'
42
+ - !ruby/object:Gem::Dependency
43
+ name: rspec
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '3'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '3'
56
+ - !ruby/object:Gem::Dependency
57
+ name: mime-types
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: '2'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '2'
70
+ - !ruby/object:Gem::Dependency
71
+ name: coveralls
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - "~>"
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - "~>"
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ - !ruby/object:Gem::Dependency
85
+ name: mocha
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - "~>"
89
+ - !ruby/object:Gem::Version
90
+ version: '1'
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - "~>"
96
+ - !ruby/object:Gem::Version
97
+ version: '1'
98
+ - !ruby/object:Gem::Dependency
99
+ name: json
100
+ requirement: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - "~>"
103
+ - !ruby/object:Gem::Version
104
+ version: '1'
105
+ type: :runtime
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - "~>"
110
+ - !ruby/object:Gem::Version
111
+ version: '1'
112
+ - !ruby/object:Gem::Dependency
113
+ name: facter
114
+ requirement: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - "~>"
117
+ - !ruby/object:Gem::Version
118
+ version: '2'
119
+ type: :runtime
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - "~>"
124
+ - !ruby/object:Gem::Version
125
+ version: '2'
126
+ - !ruby/object:Gem::Dependency
127
+ name: pry
128
+ requirement: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - "~>"
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ type: :development
134
+ prerelease: false
135
+ version_requirements: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - "~>"
138
+ - !ruby/object:Gem::Version
139
+ version: '0'
140
+ - !ruby/object:Gem::Dependency
141
+ name: pry-doc
142
+ requirement: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ - - "~>"
145
+ - !ruby/object:Gem::Version
146
+ version: '0'
147
+ type: :development
148
+ prerelease: false
149
+ version_requirements: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - "~>"
152
+ - !ruby/object:Gem::Version
153
+ version: '0'
154
+ description: shim that injects SIMP-related facts into rspec-puppet-facts
155
+ email: simp@simp-project.org
156
+ executables: []
157
+ extensions: []
158
+ extra_rdoc_files: []
159
+ files:
160
+ - LICENSE
161
+ - README.md
162
+ - Rakefile
163
+ - lib/simp-rspec-puppet-facts.rb
164
+ - lib/simp/rspec-puppet-facts.rb
165
+ - spec/fixtures/metadata.json
166
+ - spec/fixtures/metadata.json_with_missing_operatingsystem_support
167
+ - spec/simp_rspec_puppet_facts_spec.rb
168
+ - spec/spec_helper.rb
169
+ homepage: https://github.com/simp/rubygem-simp-rspec-puppet-facts
170
+ licenses:
171
+ - Apache-2.0
172
+ metadata: {}
173
+ post_install_message:
174
+ rdoc_options: []
175
+ require_paths:
176
+ - lib
177
+ required_ruby_version: !ruby/object:Gem::Requirement
178
+ requirements:
179
+ - - ">="
180
+ - !ruby/object:Gem::Version
181
+ version: '0'
182
+ required_rubygems_version: !ruby/object:Gem::Requirement
183
+ requirements:
184
+ - - ">="
185
+ - !ruby/object:Gem::Version
186
+ version: '0'
187
+ requirements:
188
+ - rspec-puppet-facts
189
+ rubyforge_project:
190
+ rubygems_version: 2.4.6
191
+ signing_key:
192
+ specification_version: 4
193
+ summary: standard SIMP facts fixtures for Puppet
194
+ test_files:
195
+ - Rakefile
196
+ - spec/spec_helper.rb
197
+ - spec/fixtures/metadata.json
198
+ - spec/fixtures/metadata.json_with_missing_operatingsystem_support
199
+ - spec/simp_rspec_puppet_facts_spec.rb
200
+ has_rdoc: