rspec-puppet-facts 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 897f38860a4b9a2225c4b860aafe7c5e6e479a96
4
- data.tar.gz: 52310c6ede44116e97494fce31583cd21e1b32e6
3
+ metadata.gz: f41a4eb01ece38f5295c387a1fe4efb27197d5cd
4
+ data.tar.gz: 1296bd2cbd04897d780d4f29e84e126d9b72ee59
5
5
  SHA512:
6
- metadata.gz: 3c5482257bbca9c83ba78a14eb5379891df04ed75f4800947ae0ae1693ed6ed708c77b86b02d1bb68ec9d5f3db2de043561fa09e69d9038012e2550658e42229
7
- data.tar.gz: 47151a11e40973783d0b501a141ba6d0ff94263b4e39ef992d22732b5f581aeadcf860b8cb069be4d5329ef46029a7b1a33027ee1c52620876b9a556b2fb1524
6
+ metadata.gz: 0e5784286b72d614a16e3aec427b0400745a5a5541cf92f02fb34d43e692d77b97d0c334493f0914345f934c978c772d4266a124abdc37b6b684d902806dee8d
7
+ data.tar.gz: e4713f095d37044a32ddb3a52b5b069ba94ad0b45cb91a55354ff2374104516b9267c9617502d9304b83b0aca187f4a8758a1d1b82866008c1c38fdd491668aa
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ##2015-04-26 - Release 0.7.0
2
+ - Add support for Operating System minor release
3
+ - Update README.md
4
+
1
5
  ##2015-03-06 - Release 0.6.0
2
6
  - Add facts for FreeBSD 9
3
7
 
data/README.md CHANGED
@@ -1,17 +1,20 @@
1
1
  rspec-puppet-facts
2
2
  ==================
3
3
 
4
- [![Build Status](https://travis-ci.org/mcanevet/rspec-puppet-facts.png?branch=master)](https://travis-ci.org/mcanevet/rspec-puppet-facts)
5
- [![Code Climate](https://codeclimate.com/github/mcanevet/rspec-puppet-facts/badges/gpa.svg)](https://codeclimate.com/github/mcanevet/rspec-puppet-facts)
6
- [![Gem Version](https://badge.fury.io/rb/rspec-puppet-facts.svg)](http://badge.fury.io/rb/rspec-puppet-facts)
4
+ [![Build Status](https://img.shields.io/travis/mcanevet/rspec-puppet-facts/master.svg)](https://travis-ci.org/mcanevet/rspec-puppet-facts)
5
+ [![Code Climate](https://img.shields.io/codeclimate/github/mcanevet/rspec-puppet-facts.svg)](https://codeclimate.com/github/mcanevet/rspec-puppet-facts)
6
+ [![Gem Version](https://img.shields.io/gem/v/rspec-puppet-facts.svg)](https://rubygems.org/gems/rspec-puppet-facts)
7
+ [![Gem Downloads](https://img.shields.io/gem/dt/rspec-puppet-facts.svg)](https://rubygems.org/gems/rspec-puppet-facts)
7
8
  [![Coverage Status](https://img.shields.io/coveralls/mcanevet/rspec-puppet-facts.svg)](https://coveralls.io/r/mcanevet/rspec-puppet-facts?branch=master)
8
9
 
9
10
  Based on an original idea from [apenney](https://github.com/apenney/puppet_facts/).
10
11
 
11
12
  Simplify your unit tests by looping on every supported Operating System and populating facts.
12
13
 
13
- Before
14
- ------
14
+ Testing a class or define
15
+ -------------------------
16
+
17
+ ### Before
15
18
 
16
19
  ```ruby
17
20
  require 'spec_helper'
@@ -27,7 +30,7 @@ describe 'myclass' do
27
30
  ...
28
31
  }
29
32
 
30
- it { should compile.with_all_deps }
33
+ it { is_expected.to compile.with_all_deps }
31
34
  ...
32
35
  end
33
36
  end
@@ -41,7 +44,7 @@ describe 'myclass' do
41
44
  ...
42
45
  }
43
46
 
44
- it { should compile.with_all_deps }
47
+ it { is_expected.to compile.with_all_deps }
45
48
  ...
46
49
  end
47
50
  end
@@ -50,8 +53,7 @@ describe 'myclass' do
50
53
  end
51
54
  ```
52
55
 
53
- After
54
- -----
56
+ ### After
55
57
 
56
58
  ```ruby
57
59
  require 'spec_helper'
@@ -64,15 +66,136 @@ describe 'myclass' do
64
66
  facts
65
67
  end
66
68
 
67
- it { should compile.with_all_deps }
69
+ it { is_expected.to compile.with_all_deps }
70
+ ...
71
+ case facts[:osfamily]
72
+ when 'Debian'
73
+ ...
74
+ else
75
+ ...
76
+ end
77
+ end
78
+ end
79
+ end
80
+ ```
81
+
82
+ Testing a type or provider
83
+ --------------------------
84
+
85
+ ### Before
86
+
87
+ ```ruby
88
+ require 'spec_helper'
89
+
90
+ describe Puppet::Type.type(:mytype) do
91
+
92
+ context "on debian-7-x86_64" do
93
+ before :each do
94
+ Facter.clear
95
+ Facter.stubs(:fact).with(:osfamily).returns Facter.add(:osfamily) { setcode { 'Debian' } }
96
+ Facter.stubs(:fact).with(:operatingsystem).returns Facter.add(:operatingsystem) { setcode { 'Debian' } }
97
+ Facter.stubs(:fact).with(:operatingsystemmajrelease).returns Facter.add(:operatingsystemmajrelease) { setcode { '7' } }
98
+ end
99
+ ...
100
+ end
101
+
102
+ context "on redhat-7-x86_64" do
103
+ before :each do
104
+ Facter.clear
105
+ Facter.stubs(:fact).with(:osfamily).returns Facter.add(:osfamily) { setcode { 'RedHat' } }
106
+ Facter.stubs(:fact).with(:operatingsystem).returns Facter.add(:operatingsystem) { setcode { 'RedHat' } }
107
+ Facter.stubs(:fact).with(:operatingsystemmajrelease).returns Facter.add(:operatingsystemmajrelease) { setcode { '7' } }
108
+ end
109
+ ...
110
+ end
111
+ end
112
+
113
+ ```
114
+
115
+ ### After
116
+
117
+ ```ruby
118
+ require 'spec_helper'
119
+
120
+ describe Puppet::Type.type(:mytype) do
121
+
122
+ on_supported_os.each do |os, facts|
123
+ context "on #{os}" do
124
+ before :each do
125
+ Facter.clear
126
+ facts.each do |k, v|
127
+ Facter.stubs(:fact).with(k).returns Facter.add(k) { setcode { v } }
128
+ end
129
+ end
68
130
  ...
69
131
  case facts[:osfamily]
70
132
  when 'Debian'
71
133
  ...
72
- when 'RedHat'
134
+ else
73
135
  ...
74
136
  end
137
+ ...
138
+ end
139
+ end
140
+ end
141
+
142
+ ```
143
+
144
+ Testing a function
145
+ ------------------
146
+
147
+ ### Before
148
+
149
+ ```ruby
150
+ require 'spec_helper'
151
+
152
+ describe Puppet::Parser::Functions.function(:myfunction) do
153
+ let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
154
+
155
+ context "on debian-7-x86_64" do
156
+ before :each do
157
+ scope.stubs(:lookupvar).with('::osfamily').returns('Debian')
158
+ scope.stubs(:lookupvar).with('osfamily').returns('Debian')
159
+ scope.stubs(:lookupvar).with('::operatingsystem').returns('Debian')
160
+ scope.stubs(:lookupvar).with('operatingsystem').returns('Debian')
161
+ ...
162
+ end
163
+ ...
164
+ end
165
+
166
+ context "on redhat-7-x86_64" do
167
+ before :each do
168
+ scope.stubs(:lookupvar).with('::osfamily').returns('RedHat')
169
+ scope.stubs(:lookupvar).with('osfamily').returns('RedHat')
170
+ scope.stubs(:lookupvar).with('::operatingsystem').returns('RedHat')
171
+ scope.stubs(:lookupvar).with('operatingsystem').returns('RedHat')
172
+ ...
173
+ end
174
+ ...
175
+ end
176
+ end
177
+ ```
178
+
179
+ ### After
180
+
181
+ ```ruby
182
+ require 'spec_helper'
183
+
184
+ describe Puppet::Parser::Functions.function(:myfunction) do
185
+ let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
186
+
187
+ on_supported_os.each do |os, facts|
188
+ context "on #{os}" do
189
+ before :each do
190
+ facts.each do |k, v|
191
+ scope.stubs(:lookupvar).with("::#{k}").returns(v)
192
+ scope.stubs(:lookupvar).with(k).returns(v)
193
+ end
194
+ end
75
195
  end
196
+
197
+ ...
198
+
76
199
  end
77
200
  end
78
201
  ```
@@ -108,7 +231,7 @@ describe 'myclass' do
108
231
  facts
109
232
  end
110
233
 
111
- it { should compile.with_all_deps }
234
+ it { is_expected.to compile.with_all_deps }
112
235
  ...
113
236
  end
114
237
  end
@@ -130,7 +253,7 @@ describe 'myclass' do
130
253
  })
131
254
  end
132
255
 
133
- it { should compile.with_all_deps }
256
+ it { is_expected.to compile.with_all_deps }
134
257
  ...
135
258
  end
136
259
  end
@@ -13,7 +13,7 @@ module RspecPuppetFacts
13
13
  operatingsystem = os_sup['operatingsystem'].downcase
14
14
  os_sup['operatingsystemrelease'].map do |operatingsystemmajrelease|
15
15
  opts[:hardwaremodels].each do |hardwaremodel|
16
- os = "#{operatingsystem}-#{operatingsystemmajrelease.split(" ")[0]}-#{hardwaremodel}"
16
+ os = "#{operatingsystem}-#{operatingsystemmajrelease.split(/[ \.]/)[0]}-#{hardwaremodel}"
17
17
  # TODO: use SemVer here
18
18
  facter_minor_version = Facter.version[0..2]
19
19
  file = File.expand_path(File.join(File.dirname(__FILE__), "../facts/#{facter_minor_version}/#{os}.facts"))
@@ -52,10 +52,3 @@ module RspecPuppetFacts
52
52
  JSON.parse(File.read('metadata.json'))
53
53
  end
54
54
  end
55
-
56
- RSpec.configure do |c|
57
- begin
58
- c.formatter = 'NyanCatFormatter' if Date.today.strftime('%m%d') == '0401'
59
- rescue LoadError
60
- end
61
- end
@@ -1,5 +1,5 @@
1
1
  module RspecPuppetFacts
2
2
  module Version
3
- STRING = '0.6.0'
3
+ STRING = '0.7.0'
4
4
  end
5
5
  end
@@ -23,5 +23,4 @@ Gem::Specification.new do |s|
23
23
  s.add_development_dependency 'mocha'
24
24
  s.add_runtime_dependency 'json'
25
25
  s.add_runtime_dependency 'facter'
26
- s.add_runtime_dependency 'nyan-cat-formatter' if Date.today.strftime('%m%d') == '0401'
27
26
  end
@@ -139,5 +139,38 @@ describe 'RspecPuppetFacts' do
139
139
  expect { subject }.to output(/Can't find facts for 'debian-4-x86_64'/).to_stderr
140
140
  end
141
141
  end
142
+
143
+ context 'When operatingsystemrelease has minor release' do
144
+ subject {
145
+ on_supported_os(
146
+ {
147
+ :supported_os => [
148
+ {
149
+ "operatingsystem" => "RedHat",
150
+ "operatingsystemrelease" => [
151
+ "5",
152
+ "6.5",
153
+ "6.6",
154
+ "7.1"
155
+ ]
156
+ }
157
+ ]
158
+ }
159
+ )
160
+ }
161
+ it 'should return a hash' do
162
+ expect(subject.class).to eq Hash
163
+ end
164
+ it 'should have 3 elements' do
165
+ expect(subject.size).to eq 3
166
+ end
167
+ it 'should return supported OS' do
168
+ expect(subject.keys.sort).to eq [
169
+ 'redhat-5-x86_64',
170
+ 'redhat-6-x86_64',
171
+ 'redhat-7-x86_64',
172
+ ]
173
+ end
174
+ end
142
175
  end
143
176
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-puppet-facts
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mickaël Canévet
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-15 00:00:00.000000000 Z
11
+ date: 2015-04-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mime-types