rspec-puppet 2.6.1 → 2.6.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a0e8acfd6bedb13be688133733c083494c88e9a7
4
- data.tar.gz: eea4578b689eb7cf0907e0018201ffd41dcd764c
3
+ metadata.gz: fedfa152ac9857ea6c8546a70342cf148c3f89e9
4
+ data.tar.gz: ed8fbef4a778aae5e62f2726333013b6a7ebdcf9
5
5
  SHA512:
6
- metadata.gz: f4907f8744a4a6d789d7516cea4dfe0efb916385850628a2e21a3b1bb8bf5c297ed710793640fd40ba1803663e183dcb40205fdd5ac0d8fcb1ef937a42d3487b
7
- data.tar.gz: c32d0f3ce0bd57ae412a192135c93a7806dd4bdf40ab0cd1d05941463784e0a7ea33f1d6247dbe1bf1cfcb9eff294a06dd443c0f304d7c72ab1e95ac47cbc29e
6
+ metadata.gz: ab88d6b0992c638114272cdfd820a0be3a50e5cfa118ec07b5f39f52a5d4c4b657b9bf9c40a83d1a7cb805bf7d5241e95c1e5dfe3e12910709b5144824ad97f9
7
+ data.tar.gz: a5a51096595b4074a91626363e01158f14724e9907e2569a5a801e1acfde5d21de9a1be06d6c664d80dbfb1ec87fba0193f0a541f7e49e91fec880dc4c4a390a
data/CHANGELOG.md CHANGED
@@ -2,6 +2,29 @@
2
2
  All notable changes to this project will be documented in this file. This
3
3
  project adheres to [Semantic Versioning](http://semver.org/).
4
4
 
5
+ ## [2.6.2]
6
+
7
+ ### Changed
8
+
9
+ * Puppet 5.0.x added to the CI test matrices.
10
+ * The automatic setup code now checks for the presence of `metadata.json` in
11
+ the working directory. If not present, it assumes that rspec-puppet is
12
+ running from inside a control repo instead of a module and skips creating
13
+ the `spec/fixtures` directory structure and link.
14
+
15
+ ### Added
16
+
17
+ * A new configuration option has been added
18
+ (`RSpec.configuration.setup_fixtures`) that controls whether rspec-puppet
19
+ will manage the `spec/fixtures` link.
20
+
21
+ ### Fixed
22
+
23
+ * A race condition when running rspec-puppet under parallel\_tests causing
24
+ errors when creating the `spec/fixtures` link.
25
+ * The contents of the `networking` fact hash is no longer cleared when merging
26
+ in the facts derived from the node name.
27
+
5
28
  ## [2.6.1]
6
29
 
7
30
  ### Fixed
data/README.md CHANGED
@@ -61,36 +61,36 @@ The path to the directory containing your basic manifests like `site.pp`.
61
61
 
62
62
  #### module\_path
63
63
  Type | Default | Puppet Version(s)
64
- ------ | -------- | -----------------
65
- String | Required | 2.x, 3.x, 4.x
64
+ ------ | -------- | ------------------
65
+ String | Required | 2.x, 3.x, 4.x, 5.x
66
66
 
67
67
  The path to the directory containing your Puppet modules.
68
68
 
69
69
  #### default\_facts
70
70
  Type | Default | Puppet Version(s)
71
- ---- | ------- | -----------------
72
- Hash | `{}` | 2.x, 3.x, 4.x
71
+ ---- | ------- | ------------------
72
+ Hash | `{}` | 2.x, 3.x, 4.x, 5.x
73
73
 
74
74
  A hash of default facts that should be used for all the tests.
75
75
 
76
76
  #### hiera\_config
77
77
  Type | Default | Puppet Version(s)
78
78
  ------ | ------------- | -----------------
79
- String | `"/dev/null"` | 3.x, 4.x
79
+ String | `"/dev/null"` | 3.x, 4.x, 5.x
80
80
 
81
81
  The path to your `hiera.yaml` file (if used).
82
82
 
83
83
  #### default\_node\_params
84
84
  Type | Default | Puppet Version(s)
85
85
  ---- | ------- | -----------------
86
- Hash | `{}` | 4.x
86
+ Hash | `{}` | 4.x, 5.x
87
87
 
88
88
  A hash of default node parameters that should be used for all the tests.
89
89
 
90
90
  #### default\_trusted\_facts
91
91
  Type | Default | Puppet Version(s)
92
92
  ---- | ------- | -----------------
93
- Hash | `{}` | 4.x
93
+ Hash | `{}` | 4.x, 5.x
94
94
 
95
95
  A hash of default trusted facts that should be used for all the tests
96
96
  (available in the manifests as the `$trusted` hash). In order to use this, the
@@ -99,22 +99,22 @@ A hash of default trusted facts that should be used for all the tests
99
99
  #### trusted\_node\_data
100
100
  Type | Default | Puppet Version(s)
101
101
  ------- | ------- | -----------------
102
- Boolean | `false` | 3.x, 4.x
102
+ Boolean | `false` | 3.x, 4.x, 5.x
103
103
 
104
104
  Configures rspec-puppet to use the `$trusted` hash when compiling the
105
105
  catalogues.
106
106
 
107
107
  #### confdir
108
108
  Type | Default | Puppet Version(s)
109
- ------ | --------------- | -----------------
110
- String | `"/etc/puppet"` | 2.x, 3.x, 4.x
109
+ ------ | --------------- | ------------------
110
+ String | `"/etc/puppet"` | 2.x, 3.x, 4.x, 5.x
111
111
 
112
112
  The path to the main Puppet configuration directory.
113
113
 
114
114
  #### config
115
115
  Type | Default | Puppet Version(s)
116
- ------ | ---------------------- | -----------------
117
- String | Puppet's default value | 2.x, 3.x, 4.x
116
+ ------ | ---------------------- | ------------------
117
+ String | Puppet's default value | 2.x, 3.x, 4.x, 5.x
118
118
 
119
119
  The path to `puppet.conf`.
120
120
 
@@ -136,7 +136,7 @@ stored outside of modules.
136
136
  #### environmentpath
137
137
  Type | Default | Puppet Version(s)
138
138
  ------ | ------------------------------------- | -----------------
139
- String | `"/etc/puppetlabs/code/environments"` | 4.x
139
+ String | `"/etc/puppetlabs/code/environments"` | 4.x, 5.x
140
140
 
141
141
  The search path for environment directories.
142
142
 
@@ -150,7 +150,7 @@ This switches between the 3.x (`current`) and 4.x (`future`) parsers.
150
150
  #### ordering
151
151
  Type | Default | Puppet Version(s)
152
152
  ------ | -------------- | -----------------
153
- String | `"title-hash"` | 3.x, 4.x
153
+ String | `"title-hash"` | 3.x, 4.x, 5.x
154
154
 
155
155
  How unrelated resources should be ordered when applying a catalogue.
156
156
  * `manifest` - Use the order in which the resources are declared in the
@@ -162,7 +162,7 @@ How unrelated resources should be ordered when applying a catalogue.
162
162
  #### strict\_variables
163
163
  Type | Default | Puppet Version(s)
164
164
  ------- | ------- | -----------------
165
- Boolean | `false` | 3.x, 4.x
165
+ Boolean | `false` | 3.x, 4.x, 5.x
166
166
 
167
167
  Makes Puppet raise an error when it tries to reference a variable that hasn't
168
168
  been defined (not including variables that have been explicitly set to
@@ -171,21 +171,29 @@ been defined (not including variables that have been explicitly set to
171
171
  #### stringify\_facts
172
172
  Type | Default | Puppet Version(s)
173
173
  ------- | ------- | -----------------
174
- Boolean | `true` | 3.x, 4.x
174
+ Boolean | `true` | 3.x, 4.x, 5.x
175
175
 
176
176
  Makes rspec-puppet coerce all the fact values into strings (matching the
177
177
  behaviour of older versions of Puppet).
178
178
 
179
179
  #### enable\_pathname\_stubbing
180
180
  Type | Default | Puppet Version(s)
181
- ------- | ------- | -----------------
182
- Boolean |`false` | 2.x, 3.x, 4.x
181
+ ------- | ------- | ------------------
182
+ Boolean |`false` | 2.x, 3.x, 4.x, 5.x
183
183
 
184
184
  Configures rspec-puppet to stub out `Pathname#absolute?` with it's own
185
185
  implementation. This should only be enabled if you're running into an issue
186
186
  running cross-platform tests where you have Ruby code (types, providers,
187
187
  functions, etc) that use `Pathname#absolute?`.
188
188
 
189
+ #### setup\_fixtures
190
+ Type | Default | Puppet Version(s)
191
+ ------- | ------- | ------------------
192
+ Boolean | `true` | 2.x, 3.x, 4.x, 5.x
193
+
194
+ Configures rspec-puppet to automatically create a link from the root of your
195
+ module to `spec/fixtures/<module name>` at the beginning of the test run.
196
+
189
197
  ## Naming conventions
190
198
 
191
199
  For clarity and consistency, I recommend that you use the following directory
@@ -20,10 +20,15 @@ module RSpec::Puppet
20
20
  end
21
21
 
22
22
  def self.safe_setup_directories(module_name=nil, verbose=true)
23
+ if control_repo?
24
+ $stderr.puts "Unable to setup rspec-puppet automatically in a control repo" if verbose
25
+ return false
26
+ end
27
+
23
28
  if module_name.nil?
24
29
  module_name = get_module_name
25
30
  if module_name.nil?
26
- $stderr.puts "Unable to determine module name. Aborting"
31
+ $stderr.puts "Unable to determine module name. Aborting" if verbose
27
32
  return false
28
33
  end
29
34
  end
@@ -58,6 +63,10 @@ module RSpec::Puppet
58
63
  end
59
64
  end
60
65
  protected
66
+ def self.control_repo?
67
+ !File.exist?('metadata.json')
68
+ end
69
+
61
70
  def self.get_module_name
62
71
  module_name = nil
63
72
  Dir["manifests/*.pp"].entries.each do |manifest|
@@ -97,7 +106,11 @@ module RSpec::Puppet
97
106
  $stderr.puts "!! #{dir} already exists and is not a directory"
98
107
  end
99
108
  else
100
- FileUtils.mkdir dir
109
+ begin
110
+ FileUtils.mkdir dir
111
+ rescue Errno::EEXIST => e
112
+ raise e unless File.directory? dir
113
+ end
101
114
  puts " + #{dir}/" if verbose
102
115
  end
103
116
  end
@@ -145,7 +158,11 @@ module RSpec::Puppet
145
158
  abort
146
159
  end
147
160
  else
148
- FileUtils.ln_s(File.expand_path(source), target)
161
+ begin
162
+ FileUtils.ln_s(File.expand_path(source), target)
163
+ rescue Errno::EEXIST => e
164
+ raise e unless File.symlink?(target) && File.readlink(target) == File.expand_path(source)
165
+ end
149
166
  end
150
167
  puts " + #{target}" if verbose
151
168
  end
@@ -214,11 +214,12 @@ module RSpec::Puppet
214
214
  'fqdn' => node,
215
215
  'domain' => node.split('.', 2).last,
216
216
  'clientcert' => node,
217
- 'networking' => {
218
- 'fqdn' => node,
219
- 'domain' => node.split('.', 2).last,
220
- 'hostname' => node.split('.').first
221
- }
217
+ }
218
+
219
+ networking_facts = {
220
+ 'hostname' => node_facts['hostname'],
221
+ 'fqdn' => node_facts['fqdn'],
222
+ 'domain' => node_facts['domain'],
222
223
  }
223
224
 
224
225
  result_facts = if RSpec.configuration.default_facts.any?
@@ -231,6 +232,8 @@ module RSpec::Puppet
231
232
  result_facts.merge!(munge_facts(facts)) if self.respond_to?(:facts)
232
233
  result_facts.merge!(munge_facts(node_facts))
233
234
 
235
+ (result_facts['networking'] ||= {}).merge!(networking_facts)
236
+
234
237
  # Facter currently supports lower case facts. Bug FACT-777 has been submitted to support case sensitive
235
238
  # facts.
236
239
  downcase_facts = Hash[result_facts.map { |k, v| [k.downcase, v] }]
data/lib/rspec-puppet.rb CHANGED
@@ -38,9 +38,12 @@ RSpec.configure do |c|
38
38
  c.add_setting :stringify_facts, :default => true
39
39
  c.add_setting :strict_variables, :default => false
40
40
  c.add_setting :adapter
41
+ c.add_setting :setup_fixtures, :default => true
41
42
 
42
43
  c.before(:all) do
43
- RSpec::Puppet::Setup.safe_setup_directories(nil, false)
44
+ if RSpec.configuration.setup_fixtures?
45
+ RSpec::Puppet::Setup.safe_setup_directories(nil, false)
46
+ end
44
47
  end
45
48
 
46
49
  if defined?(Puppet::Test::TestHelper)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-puppet
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.1
4
+ version: 2.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Sharpe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-02 00:00:00.000000000 Z
11
+ date: 2017-07-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec