Skip to content

Commit 37cdf54

Browse files
committed
Reduce duplication in mod_dir spec test
1 parent 44f87d0 commit 37cdf54

File tree

1 file changed

+24
-99
lines changed

1 file changed

+24
-99
lines changed

spec/classes/mod/dir_spec.rb

Lines changed: 24 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -3,106 +3,31 @@
33
require 'spec_helper'
44

55
describe 'apache::mod::dir', type: :class do
6-
it_behaves_like 'a mod class, without including apache'
7-
8-
context 'default configuration with parameters on a Debian OS' do
9-
include_examples 'Debian 8'
10-
11-
context 'passing no parameters' do
12-
it { is_expected.to contain_class('apache::params') }
13-
it { is_expected.to contain_apache__mod('dir') }
14-
it do
15-
is_expected.to contain_file('dir.conf')
16-
.with_content(%r{^DirectoryIndex })
17-
.with_content(%r{ index\.html })
18-
.with_content(%r{ index\.html\.var })
19-
.with_content(%r{ index\.cgi })
20-
.with_content(%r{ index\.pl })
21-
.with_content(%r{ index\.php })
22-
.with_content(%r{ index\.xhtml$})
23-
end
24-
end
25-
context "passing indexes => ['example.txt','fearsome.aspx']" do
26-
let :params do
27-
{ indexes: ['example.txt', 'fearsome.aspx'] }
28-
end
29-
30-
it { is_expected.to contain_file('dir.conf').with_content(%r{ example\.txt }).with_content(%r{ fearsome\.aspx$}) }
31-
end
32-
end
33-
context 'default configuration with parameters on a RedHat OS' do
34-
include_examples 'RedHat 6'
35-
36-
context 'passing no parameters' do
37-
it { is_expected.to contain_class('apache::params') }
38-
it { is_expected.to contain_apache__mod('dir') }
39-
it do
40-
is_expected.to contain_file('dir.conf')
41-
.with_content(%r{^DirectoryIndex })
42-
.with_content(%r{ index\.html })
43-
.with_content(%r{ index\.html\.var })
44-
.with_content(%r{ index\.cgi })
45-
.with_content(%r{ index\.pl })
46-
.with_content(%r{ index\.php })
47-
.with_content(%r{ index\.xhtml$})
48-
end
49-
end
50-
context "passing indexes => ['example.txt','fearsome.aspx']" do
51-
let :params do
52-
{ indexes: ['example.txt', 'fearsome.aspx'] }
53-
end
54-
55-
it { is_expected.to contain_file('dir.conf').with_content(%r{ example\.txt }).with_content(%r{ fearsome\.aspx$}) }
56-
end
57-
end
58-
context 'default configuration with parameters on a FreeBSD OS' do
59-
include_examples 'FreeBSD 9'
60-
61-
context 'passing no parameters' do
62-
it { is_expected.to contain_class('apache::params') }
63-
it { is_expected.to contain_apache__mod('dir') }
64-
it do
65-
is_expected.to contain_file('dir.conf')
66-
.with_content(%r{^DirectoryIndex })
67-
.with_content(%r{ index\.html })
68-
.with_content(%r{ index\.html\.var })
69-
.with_content(%r{ index\.cgi })
70-
.with_content(%r{ index\.pl })
71-
.with_content(%r{ index\.php })
72-
.with_content(%r{ index\.xhtml$})
6+
['Debian 8', 'RedHat 6', 'FreeBSD 9', 'Gentoo'].each do |os|
7+
context "default configuration with parameters on #{os}" do
8+
include_examples os
9+
10+
context 'passing no parameters' do
11+
it { is_expected.to contain_class('apache::params') }
12+
it { is_expected.to contain_apache__mod('dir') }
13+
it do
14+
is_expected.to contain_file('dir.conf')
15+
.with_content(%r{^DirectoryIndex })
16+
.with_content(%r{ index\.html })
17+
.with_content(%r{ index\.html\.var })
18+
.with_content(%r{ index\.cgi })
19+
.with_content(%r{ index\.pl })
20+
.with_content(%r{ index\.php })
21+
.with_content(%r{ index\.xhtml$})
22+
end
23+
end
24+
context "passing indexes => ['example.txt','fearsome.aspx']" do
25+
let :params do
26+
{ indexes: ['example.txt', 'fearsome.aspx'] }
27+
end
28+
29+
it { is_expected.to contain_file('dir.conf').with_content(%r{ example\.txt }).with_content(%r{ fearsome\.aspx$}) }
7330
end
7431
end
75-
context "passing indexes => ['example.txt','fearsome.aspx']" do
76-
let :params do
77-
{ indexes: ['example.txt', 'fearsome.aspx'] }
78-
end
79-
80-
it { is_expected.to contain_file('dir.conf').with_content(%r{ example\.txt }).with_content(%r{ fearsome\.aspx$}) }
81-
end
82-
end
83-
context 'default configuration with parameters on a Gentoo OS' do
84-
include_examples 'Gentoo'
85-
86-
context 'passing no parameters' do
87-
it { is_expected.to contain_class('apache::params') }
88-
it { is_expected.to contain_apache__mod('dir') }
89-
it do
90-
is_expected.to contain_file('dir.conf')
91-
.with_content(%r{^DirectoryIndex })
92-
.with_content(%r{ index\.html })
93-
.with_content(%r{ index\.html\.var })
94-
.with_content(%r{ index\.cgi })
95-
.with_content(%r{ index\.pl })
96-
.with_content(%r{ index\.php })
97-
.with_content(%r{ index\.xhtml$})
98-
end
99-
end
100-
context "passing indexes => ['example.txt','fearsome.aspx']" do
101-
let :params do
102-
{ indexes: ['example.txt', 'fearsome.aspx'] }
103-
end
104-
105-
it { is_expected.to contain_file('dir.conf').with_content(%r{ example\.txt }).with_content(%r{ fearsome\.aspx$}) }
106-
end
10732
end
10833
end

0 commit comments

Comments
 (0)