Skip to content

Commit 44f87d0

Browse files
committed
Reuse resources in tests to save time
Prior to this patch the runtime was ~21 seconds, after ~18 seconds. A huge part of that is actually initializing facts from rspec-puppet-facts.
1 parent 145aa54 commit 44f87d0

File tree

1 file changed

+44
-36
lines changed

1 file changed

+44
-36
lines changed

spec/classes/mod/dir_spec.rb

Lines changed: 44 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,23 @@
1111
context 'passing no parameters' do
1212
it { is_expected.to contain_class('apache::params') }
1313
it { is_expected.to contain_apache__mod('dir') }
14-
it { is_expected.to contain_file('dir.conf').with_content(%r{^DirectoryIndex }) }
15-
it { is_expected.to contain_file('dir.conf').with_content(%r{ index\.html }) }
16-
it { is_expected.to contain_file('dir.conf').with_content(%r{ index\.html\.var }) }
17-
it { is_expected.to contain_file('dir.conf').with_content(%r{ index\.cgi }) }
18-
it { is_expected.to contain_file('dir.conf').with_content(%r{ index\.pl }) }
19-
it { is_expected.to contain_file('dir.conf').with_content(%r{ index\.php }) }
20-
it { is_expected.to contain_file('dir.conf').with_content(%r{ index\.xhtml$}) }
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
2124
end
2225
context "passing indexes => ['example.txt','fearsome.aspx']" do
2326
let :params do
2427
{ indexes: ['example.txt', 'fearsome.aspx'] }
2528
end
2629

27-
it { is_expected.to contain_file('dir.conf').with_content(%r{ example\.txt }) }
28-
it { is_expected.to contain_file('dir.conf').with_content(%r{ fearsome\.aspx$}) }
30+
it { is_expected.to contain_file('dir.conf').with_content(%r{ example\.txt }).with_content(%r{ fearsome\.aspx$}) }
2931
end
3032
end
3133
context 'default configuration with parameters on a RedHat OS' do
@@ -34,21 +36,23 @@
3436
context 'passing no parameters' do
3537
it { is_expected.to contain_class('apache::params') }
3638
it { is_expected.to contain_apache__mod('dir') }
37-
it { is_expected.to contain_file('dir.conf').with_content(%r{^DirectoryIndex }) }
38-
it { is_expected.to contain_file('dir.conf').with_content(%r{ index\.html }) }
39-
it { is_expected.to contain_file('dir.conf').with_content(%r{ index\.html\.var }) }
40-
it { is_expected.to contain_file('dir.conf').with_content(%r{ index\.cgi }) }
41-
it { is_expected.to contain_file('dir.conf').with_content(%r{ index\.pl }) }
42-
it { is_expected.to contain_file('dir.conf').with_content(%r{ index\.php }) }
43-
it { is_expected.to contain_file('dir.conf').with_content(%r{ index\.xhtml$}) }
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
4449
end
4550
context "passing indexes => ['example.txt','fearsome.aspx']" do
4651
let :params do
4752
{ indexes: ['example.txt', 'fearsome.aspx'] }
4853
end
4954

50-
it { is_expected.to contain_file('dir.conf').with_content(%r{ example\.txt }) }
51-
it { is_expected.to contain_file('dir.conf').with_content(%r{ fearsome\.aspx$}) }
55+
it { is_expected.to contain_file('dir.conf').with_content(%r{ example\.txt }).with_content(%r{ fearsome\.aspx$}) }
5256
end
5357
end
5458
context 'default configuration with parameters on a FreeBSD OS' do
@@ -57,21 +61,23 @@
5761
context 'passing no parameters' do
5862
it { is_expected.to contain_class('apache::params') }
5963
it { is_expected.to contain_apache__mod('dir') }
60-
it { is_expected.to contain_file('dir.conf').with_content(%r{^DirectoryIndex }) }
61-
it { is_expected.to contain_file('dir.conf').with_content(%r{ index\.html }) }
62-
it { is_expected.to contain_file('dir.conf').with_content(%r{ index\.html\.var }) }
63-
it { is_expected.to contain_file('dir.conf').with_content(%r{ index\.cgi }) }
64-
it { is_expected.to contain_file('dir.conf').with_content(%r{ index\.pl }) }
65-
it { is_expected.to contain_file('dir.conf').with_content(%r{ index\.php }) }
66-
it { is_expected.to contain_file('dir.conf').with_content(%r{ index\.xhtml$}) }
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$})
73+
end
6774
end
6875
context "passing indexes => ['example.txt','fearsome.aspx']" do
6976
let :params do
7077
{ indexes: ['example.txt', 'fearsome.aspx'] }
7178
end
7279

73-
it { is_expected.to contain_file('dir.conf').with_content(%r{ example\.txt }) }
74-
it { is_expected.to contain_file('dir.conf').with_content(%r{ fearsome\.aspx$}) }
80+
it { is_expected.to contain_file('dir.conf').with_content(%r{ example\.txt }).with_content(%r{ fearsome\.aspx$}) }
7581
end
7682
end
7783
context 'default configuration with parameters on a Gentoo OS' do
@@ -80,21 +86,23 @@
8086
context 'passing no parameters' do
8187
it { is_expected.to contain_class('apache::params') }
8288
it { is_expected.to contain_apache__mod('dir') }
83-
it { is_expected.to contain_file('dir.conf').with_content(%r{^DirectoryIndex }) }
84-
it { is_expected.to contain_file('dir.conf').with_content(%r{ index\.html }) }
85-
it { is_expected.to contain_file('dir.conf').with_content(%r{ index\.html\.var }) }
86-
it { is_expected.to contain_file('dir.conf').with_content(%r{ index\.cgi }) }
87-
it { is_expected.to contain_file('dir.conf').with_content(%r{ index\.pl }) }
88-
it { is_expected.to contain_file('dir.conf').with_content(%r{ index\.php }) }
89-
it { is_expected.to contain_file('dir.conf').with_content(%r{ index\.xhtml$}) }
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
9099
end
91100
context "passing indexes => ['example.txt','fearsome.aspx']" do
92101
let :params do
93102
{ indexes: ['example.txt', 'fearsome.aspx'] }
94103
end
95104

96-
it { is_expected.to contain_file('dir.conf').with_content(%r{ example\.txt }) }
97-
it { is_expected.to contain_file('dir.conf').with_content(%r{ fearsome\.aspx$}) }
105+
it { is_expected.to contain_file('dir.conf').with_content(%r{ example\.txt }).with_content(%r{ fearsome\.aspx$}) }
98106
end
99107
end
100108
end

0 commit comments

Comments
 (0)