rspec-puppet 2.12.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +140 -480
- data/README.md +18 -5
- data/bin/rspec-puppet-init +4 -3
- data/lib/rspec-puppet/adapters.rb +67 -61
- data/lib/rspec-puppet/cache.rb +3 -2
- data/lib/rspec-puppet/consts.rb +16 -14
- data/lib/rspec-puppet/coverage.rb +37 -42
- data/lib/rspec-puppet/errors.rb +6 -6
- data/lib/rspec-puppet/example/application_example_group.rb +3 -1
- data/lib/rspec-puppet/example/class_example_group.rb +3 -1
- data/lib/rspec-puppet/example/define_example_group.rb +3 -1
- data/lib/rspec-puppet/example/function_example_group.rb +28 -23
- data/lib/rspec-puppet/example/host_example_group.rb +3 -1
- data/lib/rspec-puppet/example/provider_example_group.rb +2 -0
- data/lib/rspec-puppet/example/type_alias_example_group.rb +4 -2
- data/lib/rspec-puppet/example/type_example_group.rb +3 -1
- data/lib/rspec-puppet/example.rb +6 -7
- data/lib/rspec-puppet/facter_impl.rb +11 -10
- data/lib/rspec-puppet/matchers/allow_value.rb +10 -10
- data/lib/rspec-puppet/matchers/compile.rb +54 -61
- data/lib/rspec-puppet/matchers/count_generic.rb +18 -18
- data/lib/rspec-puppet/matchers/create_generic.rb +66 -78
- data/lib/rspec-puppet/matchers/dynamic_matchers.rb +13 -2
- data/lib/rspec-puppet/matchers/include_class.rb +5 -4
- data/lib/rspec-puppet/matchers/parameter_matcher.rb +11 -12
- data/lib/rspec-puppet/matchers/raise_error.rb +5 -1
- data/lib/rspec-puppet/matchers/run.rb +41 -44
- data/lib/rspec-puppet/matchers/type_matchers.rb +37 -48
- data/lib/rspec-puppet/matchers.rb +2 -0
- data/lib/rspec-puppet/monkey_patches/win32/registry.rb +7 -5
- data/lib/rspec-puppet/monkey_patches/win32/taskscheduler.rb +3 -1
- data/lib/rspec-puppet/monkey_patches/windows/taskschedulerconstants.rb +208 -205
- data/lib/rspec-puppet/monkey_patches.rb +56 -56
- data/lib/rspec-puppet/rake_task.rb +6 -4
- data/lib/rspec-puppet/raw_string.rb +2 -0
- data/lib/rspec-puppet/sensitive.rb +9 -7
- data/lib/rspec-puppet/setup.rb +43 -48
- data/lib/rspec-puppet/spec_helper.rb +2 -0
- data/lib/rspec-puppet/support.rb +133 -134
- data/lib/rspec-puppet/tasks/release_test.rb +8 -5
- data/lib/rspec-puppet/version.rb +5 -0
- data/lib/rspec-puppet.rb +43 -51
- metadata +9 -7
@@ -1,10 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module RSpec::Puppet
|
2
4
|
module TypeMatchers
|
3
|
-
|
4
5
|
class CreateGeneric
|
5
|
-
|
6
|
-
def initialize(*args, &block)
|
7
|
-
|
6
|
+
def initialize(*_args)
|
8
7
|
@exp_provider = nil
|
9
8
|
@exp_parameters = []
|
10
9
|
@exp_properties = []
|
@@ -22,19 +21,19 @@ module RSpec::Puppet
|
|
22
21
|
|
23
22
|
# ensures the listed properties are valid
|
24
23
|
def with_properties(props)
|
25
|
-
@exp_properties
|
24
|
+
@exp_properties |= Array(props)
|
26
25
|
self
|
27
26
|
end
|
28
27
|
|
29
28
|
# ensures the listed parameters are valid
|
30
29
|
def with_parameters(params)
|
31
|
-
@exp_parameters
|
30
|
+
@exp_parameters |= Array(params)
|
32
31
|
self
|
33
32
|
end
|
34
33
|
|
35
34
|
# ensure the type has the list of features
|
36
35
|
def with_features(features)
|
37
|
-
@exp_features
|
36
|
+
@exp_features |= Array(features)
|
38
37
|
self
|
39
38
|
end
|
40
39
|
|
@@ -59,9 +58,8 @@ module RSpec::Puppet
|
|
59
58
|
type = type_title_and_params[0]
|
60
59
|
title = type_title_and_params[1]
|
61
60
|
params = type_title_and_params[2]
|
62
|
-
unless match_params(type) && match_props(type) && match_features(type)
|
63
|
-
|
64
|
-
end
|
61
|
+
return false unless match_params(type) && match_props(type) && match_features(type)
|
62
|
+
|
65
63
|
if @params_with_values != {} || @exp_provider
|
66
64
|
# only build a resource if we are validating provider or setting
|
67
65
|
# additional parameters
|
@@ -97,25 +95,20 @@ module RSpec::Puppet
|
|
97
95
|
# checks that the expected provider is set
|
98
96
|
#
|
99
97
|
def match_default_provider(resource)
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
return false
|
106
|
-
end
|
107
|
-
else
|
108
|
-
return true
|
109
|
-
end
|
98
|
+
return true unless @exp_provider
|
99
|
+
return true if resource[:provider] == @exp_provider
|
100
|
+
|
101
|
+
@errors.push("Expected provider: #{@exp_provider} does not match: #{resource[:provider]}")
|
102
|
+
false
|
110
103
|
end
|
111
104
|
|
112
|
-
def match_default_values(
|
113
|
-
# TODO FINISH
|
105
|
+
def match_default_values(_resource)
|
106
|
+
# TODO: FINISH
|
114
107
|
true
|
115
108
|
end
|
116
109
|
|
117
110
|
def description
|
118
|
-
|
111
|
+
'be a valid type'
|
119
112
|
end
|
120
113
|
|
121
114
|
def failure_message
|
@@ -124,35 +117,31 @@ module RSpec::Puppet
|
|
124
117
|
|
125
118
|
private
|
126
119
|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
elsif ! type.send("valid#{attr_type}?".to_sym, param)
|
136
|
-
baddies.push(param)
|
137
|
-
end
|
138
|
-
end
|
139
|
-
if baddies.size > 0
|
140
|
-
@errors.push("Invalid #{pluralize(attr_type)}: #{baddies.join(',')}")
|
141
|
-
false
|
142
|
-
else
|
143
|
-
true
|
120
|
+
def match_attrs(type, attrs, attr_type)
|
121
|
+
baddies = []
|
122
|
+
attrs.each do |param|
|
123
|
+
param = param.to_sym
|
124
|
+
if attr_type == :feature
|
125
|
+
baddies.push(param) unless type.provider_feature(param)
|
126
|
+
elsif !type.send("valid#{attr_type}?".to_sym, param)
|
127
|
+
baddies.push(param)
|
144
128
|
end
|
145
129
|
end
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
"#{name}s"
|
152
|
-
end
|
130
|
+
if baddies.size.positive?
|
131
|
+
@errors.push("Invalid #{pluralize(attr_type)}: #{baddies.join(',')}")
|
132
|
+
false
|
133
|
+
else
|
134
|
+
true
|
153
135
|
end
|
136
|
+
end
|
154
137
|
|
138
|
+
def pluralize(name)
|
139
|
+
if name == :property
|
140
|
+
'properties'
|
141
|
+
else
|
142
|
+
"#{name}s"
|
143
|
+
end
|
144
|
+
end
|
155
145
|
end
|
156
|
-
|
157
146
|
end
|
158
147
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module RSpec
|
2
4
|
module Puppet
|
3
5
|
module Win32
|
@@ -37,9 +39,9 @@ module RSpec
|
|
37
39
|
KEY_NOTIFY = 0x0010
|
38
40
|
KEY_CREATE_LINK = 0x0020
|
39
41
|
KEY_READ = STANDARD_RIGHTS_READ |
|
40
|
-
|
42
|
+
KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS | KEY_NOTIFY
|
41
43
|
KEY_WRITE = STANDARD_RIGHTS_WRITE |
|
42
|
-
|
44
|
+
KEY_SET_VALUE | KEY_CREATE_SUB_KEY
|
43
45
|
KEY_EXECUTE = KEY_READ
|
44
46
|
KEY_ALL_ACCESS = KEY_READ | KEY_WRITE | KEY_CREATE_LINK
|
45
47
|
|
@@ -50,8 +52,8 @@ module RSpec
|
|
50
52
|
REG_OPTION_BACKUP_RESTORE = 0x0004
|
51
53
|
REG_OPTION_OPEN_LINK = 0x0008
|
52
54
|
REG_LEGAL_OPTION = REG_OPTION_RESERVED |
|
53
|
-
|
54
|
-
|
55
|
+
REG_OPTION_NON_VOLATILE | REG_OPTION_CREATE_LINK |
|
56
|
+
REG_OPTION_BACKUP_RESTORE | REG_OPTION_OPEN_LINK
|
55
57
|
|
56
58
|
REG_CREATED_NEW_KEY = 1
|
57
59
|
REG_OPENED_EXISTING_KEY = 2
|
@@ -62,7 +64,7 @@ module RSpec
|
|
62
64
|
REG_FORCE_RESTORE = 0x0008
|
63
65
|
|
64
66
|
MAX_KEY_LENGTH = 514
|
65
|
-
MAX_VALUE_LENGTH =
|
67
|
+
MAX_VALUE_LENGTH = 32_768
|
66
68
|
end
|
67
69
|
include Constants
|
68
70
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Create our dummy Win32::TaskScheduler with the consts defined from
|
2
4
|
# https://github.com/djberg96/win32-taskscheduler/blob/ole/lib/win32/taskscheduler.rb
|
3
5
|
|
@@ -9,7 +11,7 @@ module RSpec
|
|
9
11
|
class TaskScheduler
|
10
12
|
include Windows::TaskSchedulerConstants
|
11
13
|
|
12
|
-
DAYS_IN_A_MONTH = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
|
14
|
+
DAYS_IN_A_MONTH = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31].freeze
|
13
15
|
|
14
16
|
IDLE = IDLE_PRIORITY_CLASS
|
15
17
|
NORMAL = NORMAL_PRIORITY_CLASS
|