puppetmodule-netdev_stdlib 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +27 -0
- data/.travis.yml +9 -0
- data/Gemfile +4 -0
- data/Guardfile +15 -0
- data/LICENSE +202 -0
- data/Modulefile +9 -0
- data/README.md +330 -0
- data/Rakefile +1 -0
- data/lib/netdev_stdlib.rb +4 -0
- data/lib/netdev_stdlib/version.rb +3 -0
- data/lib/puppet/type/domain_name.rb +17 -0
- data/lib/puppet/type/name_server.rb +17 -0
- data/lib/puppet/type/network_interface.rb +60 -0
- data/lib/puppet/type/network_trunk.rb +83 -0
- data/lib/puppet/type/network_vlan.rb +53 -0
- data/lib/puppet/type/ntp_config.rb +25 -0
- data/lib/puppet/type/ntp_server.rb +20 -0
- data/lib/puppet/type/port_channel.rb +82 -0
- data/lib/puppet/type/radius.rb +20 -0
- data/lib/puppet/type/radius_global.rb +40 -0
- data/lib/puppet/type/radius_server.rb +95 -0
- data/lib/puppet/type/radius_server_group.rb +25 -0
- data/lib/puppet/type/search_domain.rb +17 -0
- data/lib/puppet/type/snmp_community.rb +29 -0
- data/lib/puppet/type/snmp_contact.rb +17 -0
- data/lib/puppet/type/snmp_location.rb +17 -0
- data/lib/puppet/type/snmp_notification.rb +20 -0
- data/lib/puppet/type/snmp_notification_receiver.rb +77 -0
- data/lib/puppet/type/snmp_protocol.rb +20 -0
- data/lib/puppet/type/snmp_user.rb +77 -0
- data/lib/puppet/type/syslog_server.rb +42 -0
- data/lib/puppet/type/syslog_settings.rb +25 -0
- data/lib/puppet/type/tacacs.rb +20 -0
- data/lib/puppet/type/tacacs_global.rb +40 -0
- data/lib/puppet/type/tacacs_server.rb +50 -0
- data/lib/puppet/type/tacacs_server_group.rb +25 -0
- data/netdev_stdlib.gemspec +36 -0
- data/spec/spec_helper.rb +15 -0
- data/spec/support/shared_examples_for_types.rb +412 -0
- data/spec/unit/puppet/type/domain_name_spec.rb +8 -0
- data/spec/unit/puppet/type/name_server_spec.rb +8 -0
- data/spec/unit/puppet/type/network_interface_spec.rb +44 -0
- data/spec/unit/puppet/type/network_trunk_spec.rb +55 -0
- data/spec/unit/puppet/type/network_vlan_spec.rb +57 -0
- data/spec/unit/puppet/type/ntp_config_spec.rb +8 -0
- data/spec/unit/puppet/type/ntp_server_spec.rb +8 -0
- data/spec/unit/puppet/type/port_channel_spec.rb +87 -0
- data/spec/unit/puppet/type/radius_global_spec.rb +27 -0
- data/spec/unit/puppet/type/radius_server_group_spec.rb +12 -0
- data/spec/unit/puppet/type/radius_server_spec.rb +51 -0
- data/spec/unit/puppet/type/radius_spec.rb +8 -0
- data/spec/unit/puppet/type/search_domain_spec.rb +8 -0
- data/spec/unit/puppet/type/snmp_community_spec.rb +27 -0
- data/spec/unit/puppet/type/snmp_contact_spec.rb +8 -0
- data/spec/unit/puppet/type/snmp_location_spec.rb +8 -0
- data/spec/unit/puppet/type/snmp_notification_receiver_spec.rb +50 -0
- data/spec/unit/puppet/type/snmp_notification_spec.rb +8 -0
- data/spec/unit/puppet/type/snmp_protocol_spec.rb +8 -0
- data/spec/unit/puppet/type/snmp_user_spec.rb +63 -0
- data/spec/unit/puppet/type/syslog_server_spec.rb +20 -0
- data/spec/unit/puppet/type/syslog_settings_spec.rb +19 -0
- data/spec/unit/puppet/type/tacacs_global_spec.rb +27 -0
- data/spec/unit/puppet/type/tacacs_server_group_spec.rb +12 -0
- data/spec/unit/puppet/type/tacacs_server_spec.rb +25 -0
- data/spec/unit/puppet/type/tacacs_spec.rb +8 -0
- metadata +338 -0
@@ -0,0 +1,25 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
Puppet::Type.newtype(:tacacs_server_group) do
|
4
|
+
@doc = 'Configure a tacacs server group'
|
5
|
+
|
6
|
+
newparam(:name, namevar: true) do
|
7
|
+
desc 'The name of the tacacs server group'
|
8
|
+
|
9
|
+
validate do |value|
|
10
|
+
if value.is_a? String then super(value)
|
11
|
+
else fail "value #{value.inspect} is invalid, must be a String."
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
newproperty(:servers, array_matching: :all) do
|
17
|
+
desc 'Array of servers associated with this group'
|
18
|
+
|
19
|
+
validate do |value|
|
20
|
+
if value.is_a? String then super(value)
|
21
|
+
else fail "value #{value.inspect} is invalid, must be a String."
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'netdev_stdlib/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'puppetmodule-netdev_stdlib'
|
8
|
+
spec.version = NetdevStdlib::VERSION
|
9
|
+
spec.authors = ['Jeff McCune']
|
10
|
+
spec.email = ['jeff@puppetlabs.com']
|
11
|
+
spec.description = %q{NetDev Standard Library provides Puppet types to configure network devices}
|
12
|
+
spec.summary = %q{Type definitions for Networking Device (NetDev) Standard Library}
|
13
|
+
spec.homepage = 'https://github.com/puppetlabs/netdev_stdlib'
|
14
|
+
spec.license = 'Apache 2.0'
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
# Development
|
22
|
+
spec.add_development_dependency 'bundler', '~> 1.3'
|
23
|
+
spec.add_development_dependency 'rake'
|
24
|
+
spec.add_development_dependency 'guard'
|
25
|
+
spec.add_development_dependency 'guard-rspec'
|
26
|
+
spec.add_development_dependency 'guard-rubocop'
|
27
|
+
spec.add_development_dependency 'pry-doc'
|
28
|
+
spec.add_development_dependency 'pry'
|
29
|
+
# Testing
|
30
|
+
spec.add_development_dependency 'rspec-puppet'
|
31
|
+
spec.add_development_dependency 'rspec', '~> 2.13.0'
|
32
|
+
spec.add_development_dependency 'puppetlabs_spec_helper'
|
33
|
+
spec.add_development_dependency 'simplecov'
|
34
|
+
|
35
|
+
spec.add_dependency 'puppet'
|
36
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'simplecov'
|
4
|
+
SimpleCov.start do
|
5
|
+
add_filter '/spec/'
|
6
|
+
add_filter '/.bundle/'
|
7
|
+
end
|
8
|
+
|
9
|
+
dir = File.expand_path(File.dirname(__FILE__))
|
10
|
+
|
11
|
+
require 'puppet'
|
12
|
+
require 'rspec-puppet'
|
13
|
+
require 'puppetlabs_spec_helper/module_spec_helper'
|
14
|
+
|
15
|
+
Dir["#{dir}/support/**/*.rb"].sort.each { |f| require f }
|
@@ -0,0 +1,412 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
RSpec.shared_examples 'property' do
|
4
|
+
it 'is a property' do
|
5
|
+
expect(described_class.attrtype(attribute)).to eq(:property)
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
RSpec.shared_examples 'parameter' do
|
10
|
+
it 'is a parameter' do
|
11
|
+
expect(described_class.attrtype(attribute)).to eq(:param)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
RSpec.shared_examples 'an ensurable type' do |opts = { name: 'emanon' }|
|
16
|
+
describe 'ensure' do
|
17
|
+
let(:catalog) { Puppet::Resource::Catalog.new }
|
18
|
+
let(:type) do
|
19
|
+
described_class.new(name: opts[:name], catalog: catalog)
|
20
|
+
end
|
21
|
+
|
22
|
+
let(:attribute) { :ensure }
|
23
|
+
subject { described_class.attrclass(attribute) }
|
24
|
+
|
25
|
+
include_examples 'property'
|
26
|
+
include_examples '#doc Documentation'
|
27
|
+
|
28
|
+
%w(absent present).each do |val|
|
29
|
+
it "accepts #{val.inspect}" do
|
30
|
+
type[attribute] = val
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
%w(true false).each do |val|
|
35
|
+
it "rejects #{val.inspect}" do
|
36
|
+
expect { type[attribute] = val }.to raise_error Puppet::ResourceError
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
RSpec.shared_examples 'boolean parameter' do
|
43
|
+
it 'is a parameter' do
|
44
|
+
expect(described_class.attrtype(attribute)).to eq(:param)
|
45
|
+
end
|
46
|
+
|
47
|
+
include_examples 'boolean value'
|
48
|
+
end
|
49
|
+
|
50
|
+
RSpec.shared_examples 'boolean' do |opts|
|
51
|
+
attribute = opts[:attribute]
|
52
|
+
fail unless attribute
|
53
|
+
name = opts[:name] || 'emanon'
|
54
|
+
|
55
|
+
describe "#{attribute}" do
|
56
|
+
let(:catalog) { Puppet::Resource::Catalog.new }
|
57
|
+
let(:attribute) { attribute }
|
58
|
+
let(:type) { described_class.new(name: name, catalog: catalog) }
|
59
|
+
subject { described_class.attrclass(attribute) }
|
60
|
+
|
61
|
+
include_examples 'boolean value'
|
62
|
+
include_examples '#doc Documentation'
|
63
|
+
include_examples 'rejects values', [0, [1], { two: :three }]
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
RSpec.shared_examples 'boolean value' do
|
68
|
+
[true, false, 'true', 'false', :true, :false].each do |val|
|
69
|
+
it "accepts #{val.inspect}" do
|
70
|
+
type[attribute] = val
|
71
|
+
end
|
72
|
+
|
73
|
+
it "munges #{val.inspect} to #{val.to_s.intern.inspect}" do
|
74
|
+
type[attribute] = val
|
75
|
+
expect(type[attribute]).to eq(val.to_s.intern)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
[1, -1, { foo: 1 }, [1], 'baz', nil].each do |val|
|
80
|
+
it "rejects #{val.inspect} with Puppet::Error" do
|
81
|
+
expect { type[attribute] = val }.to raise_error Puppet::Error
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
RSpec.shared_examples 'name is the namevar' do
|
87
|
+
describe 'name' do
|
88
|
+
let(:catalog) { Puppet::Resource::Catalog.new }
|
89
|
+
let(:type) do
|
90
|
+
described_class.new(name: 'emanon', catalog: catalog)
|
91
|
+
end
|
92
|
+
|
93
|
+
let(:attribute) { :name }
|
94
|
+
subject { described_class.attrclass(attribute) }
|
95
|
+
|
96
|
+
include_examples '#doc Documentation'
|
97
|
+
|
98
|
+
it 'is a parameter' do
|
99
|
+
expect(described_class.attrtype(:name)).to eq(:param)
|
100
|
+
end
|
101
|
+
|
102
|
+
['Engineering'].each do |val|
|
103
|
+
it "accepts #{val.inspect}" do
|
104
|
+
type[attribute] = val
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
[0, %w(Marketing Sales), { two: :three }].each do |val|
|
109
|
+
it "rejects #{val.inspect}" do
|
110
|
+
expect { type[attribute] = val }
|
111
|
+
.to raise_error Puppet::ResourceError, /is invalid, must be a String/
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
RSpec.shared_examples '#doc Documentation' do
|
118
|
+
it '#doc is a String' do
|
119
|
+
expect(subject.doc).to be_a_kind_of(String)
|
120
|
+
end
|
121
|
+
|
122
|
+
it '#doc is not only whitespace' do
|
123
|
+
expect(subject.doc.gsub(/\s+/, '')).not_to be_empty
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
RSpec.shared_examples 'rejected parameter values' do
|
128
|
+
[{ two: :three }, nil, :undef, :undefined, 'foobar'].each do |val|
|
129
|
+
it "rejects #{val.inspect} with a Puppet::Error" do
|
130
|
+
expect { type[attribute] = val }.to raise_error Puppet::Error
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
RSpec.shared_examples 'vlan id value' do
|
136
|
+
[1, 10, 100, 4095].each do |val|
|
137
|
+
it "accepts #{val.inspect}" do
|
138
|
+
type[attribute] = val
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
it 'munges [10, 20] to 10' do
|
143
|
+
type[attribute] = [10, 20]
|
144
|
+
expect(type[attribute]).to eq(10)
|
145
|
+
end
|
146
|
+
|
147
|
+
[-1, 4096, 8192, 'asdf', { foo: 1 }, true, false, nil].each do |val|
|
148
|
+
it "rejects #{val.inspect} with a Puppet::Error" do
|
149
|
+
expect { type[attribute] = val }.to raise_error Puppet::Error
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
RSpec.shared_examples 'vlan range value' do
|
155
|
+
[1, 10, 100, 4095].each do |val|
|
156
|
+
it "munges #{val.inspect} to [#{val}]" do
|
157
|
+
type[attribute] = val
|
158
|
+
expect(type[attribute]).to eq([val])
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
it 'munges [10, 20] to [10, 20]' do
|
163
|
+
type[attribute] = [10, 20]
|
164
|
+
expect(type[attribute]).to eq([10, 20])
|
165
|
+
end
|
166
|
+
|
167
|
+
[-1, 4096, 8192, 'asdf', { foo: 1 }, true, false, nil].each do |val|
|
168
|
+
it "rejects #{val.inspect} with a Puppet::Error" do
|
169
|
+
expect { type[attribute] = val }.to raise_error Puppet::Error
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
RSpec.shared_examples 'interface list value' do
|
175
|
+
['Ethernet1', 'Ethernet2', 'ethernet 4/2'].each do |val|
|
176
|
+
it "accepts #{val.inspect}" do
|
177
|
+
type[attribute] = val
|
178
|
+
expect(type[attribute]).to eq([val])
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
[-1, 4096, 8192, 'asdf', { foo: 1 }, true, false, nil].each do |val|
|
183
|
+
it "rejects #{val.inspect} with a Puppet::Error" do
|
184
|
+
expect { type[attribute] = val }.to raise_error Puppet::Error
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
RSpec.shared_examples 'array of strings property' do |opts|
|
190
|
+
attribute = opts[:attribute]
|
191
|
+
name = opts[:name] || 'emanon'
|
192
|
+
describe "#{attribute}" do
|
193
|
+
let(:catalog) { Puppet::Resource::Catalog.new }
|
194
|
+
let(:type) { described_class.new(name: name, catalog: catalog) }
|
195
|
+
let(:attribute) { attribute }
|
196
|
+
subject { described_class.attrclass(attribute) }
|
197
|
+
|
198
|
+
include_examples '#doc Documentation'
|
199
|
+
include_examples 'array of strings value'
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
RSpec.shared_examples 'array of strings value' do
|
204
|
+
['foo', 'bar', 'foo bar baz'].each do |val|
|
205
|
+
it "accepts #{val.inspect}" do
|
206
|
+
type[attribute] = val
|
207
|
+
expect(type[attribute]).to eq([val])
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
[-1, 4096, 8192, { foo: 1 }, true, false, nil].each do |val|
|
212
|
+
it "rejects #{val.inspect} with a Puppet::Error" do
|
213
|
+
expect { type[attribute] = val }.to raise_error Puppet::Error
|
214
|
+
end
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
218
|
+
RSpec.shared_examples 'numeric parameter' do |opts|
|
219
|
+
min = opts[:min]
|
220
|
+
max = opts[:max]
|
221
|
+
[min, max].each do |val|
|
222
|
+
it "accepts #{val.inspect}" do
|
223
|
+
type[attribute] = val
|
224
|
+
expect(type[attribute]).to eq(val)
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
228
|
+
[min, min.to_s, " #{min}", " #{min} ", "#{min} "].each do |val|
|
229
|
+
it "munges #{val.inspect} to #{min}" do
|
230
|
+
type[attribute] = val
|
231
|
+
expect(type[attribute]).to eq(val.to_i)
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
it "munges [#{min}, #{max}] to #{min}" do
|
236
|
+
type[attribute] = [min, max]
|
237
|
+
expect(type[attribute]).to eq(min)
|
238
|
+
end
|
239
|
+
end
|
240
|
+
|
241
|
+
RSpec.shared_examples 'description property' do
|
242
|
+
it 'is a property' do
|
243
|
+
expect(described_class.attrtype(attribute)).to eq(:property)
|
244
|
+
end
|
245
|
+
|
246
|
+
['Engineering VLAN'].each do |desc|
|
247
|
+
it "accepts #{desc.inspect}" do
|
248
|
+
type[attribute] = desc
|
249
|
+
end
|
250
|
+
end
|
251
|
+
|
252
|
+
[0, [1], { two: :three }].each do |val|
|
253
|
+
it "rejects #{val.inspect}" do
|
254
|
+
expect { type[attribute] = val }.to raise_error Puppet::ResourceError
|
255
|
+
end
|
256
|
+
end
|
257
|
+
end
|
258
|
+
|
259
|
+
RSpec.shared_examples 'speed property' do
|
260
|
+
include_examples 'property'
|
261
|
+
|
262
|
+
%w(auto 1g 10g 40g 56g 100g 100m 10m).each do |val|
|
263
|
+
it "accepts #{val.inspect}" do
|
264
|
+
type[attribute] = val
|
265
|
+
end
|
266
|
+
end
|
267
|
+
|
268
|
+
[0, 15, '0', '15', { two: :three }, 'abc'].each do |val|
|
269
|
+
it "rejects #{val.inspect} with Puppet::ResourceError" do
|
270
|
+
expect { type[attribute] = val }.to raise_error Puppet::ResourceError
|
271
|
+
end
|
272
|
+
end
|
273
|
+
end
|
274
|
+
|
275
|
+
RSpec.shared_examples 'duplex property' do
|
276
|
+
include_examples 'property'
|
277
|
+
|
278
|
+
%w(auto full half).each do |val|
|
279
|
+
it "accepts #{val.inspect}" do
|
280
|
+
type[attribute] = val
|
281
|
+
end
|
282
|
+
end
|
283
|
+
|
284
|
+
[0, 15, '0', '15', { two: :three }, 'abc'].each do |val|
|
285
|
+
it "rejects #{val.inspect} with Puppet::ResourceError" do
|
286
|
+
expect { type[attribute] = val }.to raise_error Puppet::ResourceError
|
287
|
+
end
|
288
|
+
end
|
289
|
+
end
|
290
|
+
|
291
|
+
RSpec.shared_examples 'flowcontrol property' do
|
292
|
+
it 'is a property' do
|
293
|
+
expect(described_class.attrtype(attribute)).to eq(:property)
|
294
|
+
end
|
295
|
+
|
296
|
+
%w(desired on off).each do |val|
|
297
|
+
it "accepts #{val.inspect}" do
|
298
|
+
type[attribute] = val
|
299
|
+
end
|
300
|
+
|
301
|
+
it "munges #{val.inspect} to #{val.intern.inspect}" do
|
302
|
+
type[attribute] = val
|
303
|
+
expect(type[attribute]).to eq(val.intern)
|
304
|
+
end
|
305
|
+
end
|
306
|
+
|
307
|
+
[0, 15, '0', '15', { two: :three }, 'abc'].each do |val|
|
308
|
+
it "rejects #{val.inspect} with Puppet::ResourceError" do
|
309
|
+
expect { type[attribute] = val }.to raise_error Puppet::ResourceError
|
310
|
+
end
|
311
|
+
end
|
312
|
+
end
|
313
|
+
|
314
|
+
RSpec.shared_examples 'enabled type' do
|
315
|
+
describe 'enable' do
|
316
|
+
let(:catalog) { Puppet::Resource::Catalog.new }
|
317
|
+
let(:type) do
|
318
|
+
described_class.new(name: 'emanon', catalog: catalog)
|
319
|
+
end
|
320
|
+
|
321
|
+
let(:attribute) { :enable }
|
322
|
+
subject { described_class.attrclass(attribute) }
|
323
|
+
|
324
|
+
it 'is a property' do
|
325
|
+
expect(described_class.attrtype(attribute)).to eq(:property)
|
326
|
+
end
|
327
|
+
|
328
|
+
include_examples '#doc Documentation'
|
329
|
+
include_examples 'boolean value'
|
330
|
+
end
|
331
|
+
end
|
332
|
+
|
333
|
+
RSpec.shared_examples 'string' do |opts|
|
334
|
+
attribute = opts[:attribute]
|
335
|
+
fail unless attribute
|
336
|
+
name = opts[:name] || 'emanon'
|
337
|
+
|
338
|
+
describe "#{attribute}" do
|
339
|
+
let(:catalog) { Puppet::Resource::Catalog.new }
|
340
|
+
let(:attribute) { attribute }
|
341
|
+
let(:type) { described_class.new(name: name, catalog: catalog) }
|
342
|
+
subject { described_class.attrclass(attribute) }
|
343
|
+
|
344
|
+
include_examples 'string value'
|
345
|
+
include_examples '#doc Documentation'
|
346
|
+
include_examples 'rejects values', [0, [1], { two: :three }]
|
347
|
+
end
|
348
|
+
end
|
349
|
+
|
350
|
+
RSpec.shared_examples 'string value' do
|
351
|
+
['Engineering'].each do |val|
|
352
|
+
it "accepts #{val.inspect}" do
|
353
|
+
type[attribute] = val
|
354
|
+
end
|
355
|
+
end
|
356
|
+
|
357
|
+
[0, [1], { two: :three }].each do |val|
|
358
|
+
it "rejects #{val.inspect}" do
|
359
|
+
expect { type[attribute] = val }
|
360
|
+
.to raise_error Puppet::ResourceError, /is invalid, must be a String/
|
361
|
+
end
|
362
|
+
end
|
363
|
+
|
364
|
+
[%w(Marketing Sales)].each do |val|
|
365
|
+
it "munges #{val.inspect} to #{val.first.inspect}" do
|
366
|
+
type[attribute] = val
|
367
|
+
expect(type[attribute]).to eq(val.first)
|
368
|
+
end
|
369
|
+
end
|
370
|
+
end
|
371
|
+
|
372
|
+
RSpec.shared_examples 'rejects values' do |values|
|
373
|
+
[*values].each do |val|
|
374
|
+
it "rejects #{val.inspect} with a Puppet::Error" do
|
375
|
+
expect { type[attribute] = val }.to raise_error Puppet::Error
|
376
|
+
end
|
377
|
+
end
|
378
|
+
end
|
379
|
+
|
380
|
+
RSpec.shared_examples 'accepts values' do |values|
|
381
|
+
[*values].each do |val|
|
382
|
+
it "accepts #{val.inspect}" do
|
383
|
+
type[attribute] = val
|
384
|
+
end
|
385
|
+
|
386
|
+
it "munges #{val.inspect} to #{val.intern.inspect}" do
|
387
|
+
type[attribute] = val
|
388
|
+
expect(type[attribute]).to eq(val.intern)
|
389
|
+
end
|
390
|
+
end
|
391
|
+
end
|
392
|
+
|
393
|
+
RSpec.shared_examples 'accepts values without munging' do |values|
|
394
|
+
[*values].each do |val|
|
395
|
+
it "accepts #{val.inspect}" do
|
396
|
+
type[attribute] = val
|
397
|
+
end
|
398
|
+
|
399
|
+
it "munges #{val.inspect} to #{val.inspect} (no munging)" do
|
400
|
+
type[attribute] = val
|
401
|
+
expect(type[attribute]).to eq(val)
|
402
|
+
end
|
403
|
+
end
|
404
|
+
end
|
405
|
+
|
406
|
+
RSpec.shared_examples 'it has a string property' do |attribute|
|
407
|
+
describe "#{attribute}" do
|
408
|
+
let(:attribute) { attribute }
|
409
|
+
include_examples '#doc Documentation'
|
410
|
+
include_examples 'string value'
|
411
|
+
end
|
412
|
+
end
|