puppet_spec_facts 0.0.1 → 0.1.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/.gitignore +2 -0
- data/CHANGELOG.md +3 -0
- data/README.md +7 -14
- data/lib/puppet_spec_facts/version.rb +1 -1
- data/lib/puppet_spec_facts.rb +4 -2
- data/scripts/gather_facts.sh +27 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 913f0955401c3928fce555e37dc439051d80d152
|
4
|
+
data.tar.gz: 90e913645b52b8630bfc69de8e5dd9b5acdb0ad4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7709b857e8ec19996830c55c433b5411d97ea69259149c3fcc3d4e1eab9f89619e091cb645cf5ed51a1b785927e9c928f02147829ea01b77cb1ce10828e95c2e
|
7
|
+
data.tar.gz: 76d9e737b719ae264c78976322242b919781e55584fc014ef8680c8520b189f8cbcfd7adb55dbe4b192a1bf05c6d4270736127fe03fe12c4c4f7e9fba4c53ab1
|
data/.gitignore
CHANGED
data/CHANGELOG.md
ADDED
data/README.md
CHANGED
@@ -1,13 +1,13 @@
|
|
1
|
-
# In development, do not use
|
2
|
-
|
3
1
|
# PuppetSpecFacts
|
4
|
-
[](https://travis-ci.org/danieldreier/puppet_spec_facts) [](https://codeclimate.com/github/danieldreier/puppet_spec_facts) [](https://coveralls.io/r/danieldreier/puppet_spec_facts?branch=master) [](https://gemnasium.com/danieldreier/puppet_spec_facts)
|
2
|
+
[](https://travis-ci.org/danieldreier/puppet_spec_facts) [](https://codeclimate.com/github/danieldreier/puppet_spec_facts) [](https://coveralls.io/r/danieldreier/puppet_spec_facts?branch=master) [](https://gemnasium.com/danieldreier/puppet_spec_facts) [](http://badge.fury.io/rb/puppet_spec_facts)
|
5
3
|
|
6
4
|
This gem provides facts for rspec-puppet, much like
|
7
5
|
[apenny/puppet_facts](https://github.com/apenney/puppet_facts) but targeted
|
8
6
|
toward open source puppet whereas puppet_facts seems to be aimed at Puppet
|
9
7
|
Enterprise.
|
10
8
|
|
9
|
+
This project is very (very) new. If you're successful in using it (or not) I'd really appreciate feedback.
|
10
|
+
|
11
11
|
Puppet module developers (should) use rspec-puppet to validate conditional logic. One of the most common forms
|
12
12
|
of conditional logic is to change behavior based on operating system or linux distribution. Unfortunately, most
|
13
13
|
rspec-puppet tests only include a handful of relevant facts from one or two popular Linux distributions.
|
@@ -26,10 +26,11 @@ Add this line to your puppet module's Gemfile:
|
|
26
26
|
```gemfile
|
27
27
|
gem 'puppet_spec_facts'
|
28
28
|
```
|
29
|
-
Add
|
29
|
+
Add these lines to your `spec/spec_helper.rb` file:
|
30
30
|
|
31
31
|
```ruby
|
32
|
-
require '
|
32
|
+
require 'puppet_spec_facts'
|
33
|
+
include PuppetSpecFacts
|
33
34
|
```
|
34
35
|
|
35
36
|
## Usage
|
@@ -52,7 +53,7 @@ describe 'example' do
|
|
52
53
|
# etc
|
53
54
|
describe "example class without any parameters on #{name}" do
|
54
55
|
let(:params) {{ }}
|
55
|
-
let(:facts) { facthash } # the
|
56
|
+
let(:facts) { facthash } # the fact hash from puppet_spec_facts is now available for rspec tests
|
56
57
|
|
57
58
|
it { should compile.with_all_deps }
|
58
59
|
end
|
@@ -83,11 +84,3 @@ describe 'example' do
|
|
83
84
|
end
|
84
85
|
end
|
85
86
|
```
|
86
|
-
|
87
|
-
## Contributing
|
88
|
-
|
89
|
-
1. Fork it ( https://github.com/[my-github-username]/puppet_spec_facts/fork )
|
90
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
91
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
92
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
93
|
-
5. Create a new Pull Request
|
data/lib/puppet_spec_facts.rb
CHANGED
@@ -29,8 +29,10 @@ module PuppetSpecFacts
|
|
29
29
|
|
30
30
|
# inject some additional facts to simplify lookups from rspec
|
31
31
|
def self.overload_facts(fact_hash)
|
32
|
-
fact_hash['fact_style']
|
33
|
-
fact_hash['is_pe']
|
32
|
+
fact_hash['fact_style'] = fact_style(fact_hash)
|
33
|
+
fact_hash['is_pe'] = 'true' if is_pe(fact_hash)
|
34
|
+
fact_hash['concat_basedir'] = '/fake_concat_basedir'
|
35
|
+
fact_hash['path'] = '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
|
34
36
|
return fact_hash
|
35
37
|
end
|
36
38
|
|
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
|
3
|
+
# gather facter facts on boxes with puppet already installed
|
4
|
+
kernel=$(facter kernel)
|
5
|
+
arch=$(facter architecture)
|
6
|
+
release=$(facter operatingsystemrelease)
|
7
|
+
puppetversion=$(facter puppetversion)
|
8
|
+
osfamily=$(facter osfamily)
|
9
|
+
date=$(date +"%s")
|
10
|
+
mkdir -p "/vagrant/facts/${kernel}/${osfamily}"
|
11
|
+
|
12
|
+
puppet apply -e 'package {"curl": ensure => present}'
|
13
|
+
puppet config set stringify_facts true
|
14
|
+
fact_style="stringified"
|
15
|
+
filename="${kernel}-${osfamily}-${release}-${arch}-${puppetversion}-${fact_style}-${date}"
|
16
|
+
|
17
|
+
facter --json > "/vagrant/facts/${kernel}/${osfamily}/${filename}"
|
18
|
+
facter --json | curl -H "Content-Type: application/json" -d @- http://facts.whilefork.com
|
19
|
+
|
20
|
+
puppet config set stringify_facts false
|
21
|
+
fact_style="structured"
|
22
|
+
filename="${kernel}-${osfamily}-${release}-${arch}-${puppetversion}-${fact_style}-${date}"
|
23
|
+
|
24
|
+
facter --json > "/vagrant/facts/${kernel}/${osfamily}/${filename}"
|
25
|
+
facter --json | curl -H "Content-Type: application/json" -d @- http://facts.whilefork.com
|
26
|
+
|
27
|
+
shutdown -h now
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: puppet_spec_facts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Dreier
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-12-
|
11
|
+
date: 2014-12-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -105,6 +105,7 @@ files:
|
|
105
105
|
- ".ruby-gemset"
|
106
106
|
- ".ruby-version"
|
107
107
|
- ".travis.yml"
|
108
|
+
- CHANGELOG.md
|
108
109
|
- Gemfile
|
109
110
|
- LICENSE.txt
|
110
111
|
- README.md
|
@@ -130,6 +131,7 @@ files:
|
|
130
131
|
- lib/puppet_spec_facts.rb
|
131
132
|
- lib/puppet_spec_facts/version.rb
|
132
133
|
- puppet_spec_facts.gemspec
|
134
|
+
- scripts/gather_facts.sh
|
133
135
|
- spec/lib/puppet_spec_facts_spec.rb
|
134
136
|
- spec/spec_helper.rb
|
135
137
|
homepage: https://github.com/danieldreier/puppet_spec_facts
|