Skip to content

Commit df4002b

Browse files
committed
Rewrite some defs as shared examples
Shared examples have the benefit that they are a bit more native in rspec.
1 parent 48d6abd commit df4002b

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

spec/classes/mod/status_spec.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
# Helper function for testing the contents of `status.conf`
66
# Apache < 2.4
7-
def status_conf_spec(allow_from, extended_status, status_path)
7+
shared_examples 'status_conf_spec' do |allow_from, extended_status, status_path|
88
expected =
99
"<Location #{status_path}>\n"\
1010
" SetHandler server-status\n"\
@@ -47,7 +47,7 @@ def require_directives(requires)
4747
end
4848
end
4949

50-
def status_conf_spec_require(requires, extended_status, status_path)
50+
shared_examples 'status_conf_spec_require' do |requires, extended_status, status_path|
5151
expected =
5252
"<Location #{status_path}>\n"\
5353
" SetHandler server-status\n"\
@@ -84,7 +84,7 @@ def status_conf_spec_require(requires, extended_status, status_path)
8484

8585
it { is_expected.to contain_apache__mod('status') }
8686

87-
status_conf_spec(['127.0.0.1', '::1'], 'On', '/server-status')
87+
include_examples 'status_conf_spec', ['127.0.0.1', '::1'], 'On', '/server-status'
8888

8989
it {
9090
is_expected.to contain_file('status.conf').with(ensure: 'file',
@@ -112,7 +112,7 @@ def status_conf_spec_require(requires, extended_status, status_path)
112112

113113
it { is_expected.to contain_apache__mod('status') }
114114

115-
status_conf_spec(['127.0.0.1', '::1'], 'On', '/server-status')
115+
include_examples 'status_conf_spec', ['127.0.0.1', '::1'], 'On', '/server-status'
116116

117117
it { is_expected.to contain_file('status.conf').with_path('/etc/httpd/conf.d/status.conf') }
118118
end
@@ -164,7 +164,7 @@ def status_conf_spec_require(requires, extended_status, status_path)
164164

165165
it { is_expected.to contain_apache__mod('status') }
166166

167-
status_conf_spec_require(req_value, 'On', '/server-status')
167+
include_examples 'status_conf_spec_require', req_value, 'On', '/server-status'
168168

169169
it {
170170
is_expected.to contain_file('status.conf').with(ensure: 'file',
@@ -198,7 +198,7 @@ def status_conf_spec_require(requires, extended_status, status_path)
198198

199199
it { is_expected.to contain_apache__mod('status') }
200200

201-
status_conf_spec_require(req_value, 'On', '/server-status')
201+
include_examples 'status_conf_spec_require', req_value, 'On', '/server-status'
202202

203203
it { is_expected.to contain_file('status.conf').with_path('/etc/httpd/conf.modules.d/status.conf') }
204204
end
@@ -224,7 +224,7 @@ def status_conf_spec_require(requires, extended_status, status_path)
224224

225225
it { is_expected.to contain_apache__mod('status') }
226226

227-
status_conf_spec_require(req_value, 'On', '/server-status')
227+
include_examples 'status_conf_spec_require', req_value, 'On', '/server-status'
228228

229229
it { is_expected.to contain_file('status.conf').with_path('/etc/httpd/conf.modules.d/status.conf') }
230230
end
@@ -253,7 +253,7 @@ def status_conf_spec_require(requires, extended_status, status_path)
253253

254254
it { is_expected.to compile }
255255

256-
status_conf_spec(['10.10.10.10', '11.11.11.11'], 'Off', '/custom-status')
256+
include_examples 'status_conf_spec', ['10.10.10.10', '11.11.11.11'], 'Off', '/custom-status'
257257
end
258258

259259
context "with valid parameter type $allow_from => ['10.10.10.10']" do

0 commit comments

Comments
 (0)