Skip to content

Commit 7bc211c

Browse files
author
Travis Fields
committed
MODULES-1764 Fix missing method for check_is_owned_by for windows
Fix tests to use its(:content) instead of deprecated should contain
1 parent fa5c1cf commit 7bc211c

13 files changed

Lines changed: 188 additions & 156 deletions

spec/acceptance/concat_spec.rb

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,37 @@
11
require 'spec_helper_acceptance'
22

33
case fact('osfamily')
4-
when 'AIX'
5-
username = 'root'
6-
groupname = 'system'
7-
scriptname = 'concatfragments.sh'
8-
vardir = default['puppetvardir']
9-
when 'Darwin'
10-
username = 'root'
11-
groupname = 'wheel'
12-
scriptname = 'concatfragments.sh'
13-
vardir = default['puppetvardir']
14-
when 'windows'
15-
username = 'Administrator'
16-
groupname = 'Administrators'
17-
scriptname = 'concatfragments.rb'
18-
result = on default, "echo #{default['puppetvardir']}"
19-
vardir = result.raw_output.chomp
20-
when 'Solaris'
21-
username = 'root'
22-
groupname = 'root'
23-
scriptname = 'concatfragments.rb'
24-
vardir = default['puppetvardir']
25-
else
26-
username = 'root'
27-
groupname = 'root'
28-
scriptname = 'concatfragments.sh'
29-
vardir = default['puppetvardir']
4+
when 'AIX'
5+
username = 'root'
6+
groupname = 'system'
7+
scriptname = 'concatfragments.sh'
8+
vardir = default['puppetvardir']
9+
when 'Darwin'
10+
username = 'root'
11+
groupname = 'wheel'
12+
scriptname = 'concatfragments.sh'
13+
vardir = default['puppetvardir']
14+
when 'windows'
15+
username = 'Administrator'
16+
groupname = 'Administrators'
17+
scriptname = 'concatfragments.rb'
18+
result = on default, "echo #{default['puppetvardir']}"
19+
vardir = result.raw_output.chomp
20+
when 'Solaris'
21+
username = 'root'
22+
groupname = 'root'
23+
scriptname = 'concatfragments.rb'
24+
vardir = default['puppetvardir']
25+
else
26+
username = 'root'
27+
groupname = 'root'
28+
scriptname = 'concatfragments.sh'
29+
vardir = default['puppetvardir']
3030
end
3131

3232
describe 'basic concat test' do
3333
basedir = default.tmpdir('concat')
34-
safe_basedir = basedir.gsub(/[\/:]/,'_')
34+
safe_basedir = basedir.gsub(/[\/:]/, '_')
3535

3636
shared_examples 'successfully_applied' do |pp|
3737
it 'applies the manifest twice with no stderr' do
@@ -46,7 +46,7 @@
4646
should be_mode 755
4747
}
4848
end
49-
describe file("#{vardir}/concat/bin") do
49+
describe file("#{vardir}/concat/bin") do
5050
it { should be_directory }
5151
it { should be_owned_by username }
5252
it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) {
@@ -128,8 +128,10 @@
128128
it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) {
129129
should be_mode 644
130130
}
131-
it { should contain '1' }
132-
it { should contain '2' }
131+
its(:content) {
132+
should match '1'
133+
should match '2'
134+
}
133135
end
134136
describe file("#{vardir}/concat/#{safe_basedir}_file/fragments/01_1") do
135137
it { should be_file }
@@ -177,7 +179,7 @@
177179
it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) {
178180
should be_mode 644
179181
}
180-
it { should contain '1' }
182+
its(:content) { should match '1' }
181183
end
182184
end
183185
context 'works when set to absent with path set' do

spec/acceptance/deprecation_warnings_spec.rb

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
describe 'deprecation warnings' do
44
basedir = default.tmpdir('concat')
55

6-
shared_examples 'has_warning'do |pp, w|
6+
shared_examples 'has_warning' do |pp, w|
77
it 'applies the manifest twice with a stderr regex' do
88
expect(apply_manifest(pp, :catch_failures => true).stderr).to match(/#{Regexp.escape(w)}/m)
99
expect(apply_manifest(pp, :catch_changes => true).stderr).to match(/#{Regexp.escape(w)}/m)
@@ -43,8 +43,10 @@
4343

4444
describe file("#{basedir}/file") do
4545
it { should be_file }
46-
it { should contain '# This file is managed by Puppet. DO NOT EDIT.' }
47-
it { should contain 'bar' }
46+
its(:content) {
47+
should match '# This file is managed by Puppet. DO NOT EDIT.'
48+
should match 'bar'
49+
}
4850
end
4951
end
5052
end
@@ -66,8 +68,10 @@
6668

6769
describe file("#{basedir}/file") do
6870
it { should be_file }
69-
it { should_not contain '# This file is managed by Puppet. DO NOT EDIT.' }
70-
it { should contain 'bar' }
71+
its(:content) {
72+
should_not match '# This file is managed by Puppet. DO NOT EDIT.'
73+
should match 'bar'
74+
}
7175
end
7276
end
7377
end
@@ -100,7 +104,7 @@
100104

101105
describe file("#{basedir}/file") do
102106
it { should be_file }
103-
it { should contain 'file1 contents' }
107+
its(:content) { should match 'file1 contents' }
104108
end
105109

106110
describe 'the fragment can be changed from a symlink to a plain file', :unless => (fact("osfamily") == "windows") do
@@ -119,8 +123,10 @@
119123

120124
describe file("#{basedir}/file") do
121125
it { should be_file }
122-
it { should contain 'new content' }
123-
it { should_not contain 'file1 contents' }
126+
its(:content) {
127+
should match 'new content'
128+
should_not match 'file1 contents'
129+
}
124130
end
125131
end
126132
end # target file exists
@@ -157,7 +163,7 @@
157163

158164
describe file("#{basedir}/file") do
159165
it { should be_file }
160-
it { should contain 'new content' }
166+
its(:content) { should match 'new content' }
161167
end
162168
end
163169
end # target file exists

spec/acceptance/empty_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
describe file("#{basedir}/file") do
1919
it { should be_file }
20-
it { should_not contain '1\n2' }
20+
its(:content) { should_not match /1\n2/ }
2121
end
2222
end
2323
end

spec/acceptance/fragment_source_spec.rb

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
require 'spec_helper_acceptance'
22

33
case fact('osfamily')
4-
when 'AIX'
5-
username = 'root'
6-
groupname = 'system'
7-
when 'Darwin'
8-
username = 'root'
9-
groupname = 'wheel'
10-
when 'windows'
11-
username = 'Administrator'
12-
groupname = 'Administrators'
13-
else
14-
username = 'root'
15-
groupname = 'root'
4+
when 'AIX'
5+
username = 'root'
6+
groupname = 'system'
7+
when 'Darwin'
8+
username = 'root'
9+
groupname = 'wheel'
10+
when 'windows'
11+
username = 'Administrator'
12+
groupname = 'Administrators'
13+
else
14+
username = 'root'
15+
groupname = 'root'
1616
end
1717

1818
describe 'concat::fragment source' do
@@ -50,9 +50,11 @@
5050

5151
describe file("#{basedir}/foo") do
5252
it { should be_file }
53-
it { should contain 'file1 contents' }
54-
it { should contain 'string1 contents' }
55-
it { should contain 'file2 contents' }
53+
its(:content) {
54+
should match 'file1 contents'
55+
should match 'string1 contents'
56+
should match 'file2 contents'
57+
}
5658
end
5759
end # should read file fragments from local system
5860

@@ -106,18 +108,24 @@
106108
end
107109
describe file("#{basedir}/result_file1") do
108110
it { should be_file }
109-
it { should contain 'file1 contents' }
110-
it { should_not contain 'file2 contents' }
111+
its(:content) {
112+
should match 'file1 contents'
113+
should_not match 'file2 contents'
114+
}
111115
end
112116
describe file("#{basedir}/result_file2") do
113117
it { should be_file }
114-
it { should contain 'file2 contents' }
115-
it { should_not contain 'file1 contents' }
118+
its(:content) {
119+
should match 'file2 contents'
120+
should_not match 'file1 contents'
121+
}
116122
end
117123
describe file("#{basedir}/result_file3") do
118124
it { should be_file }
119-
it { should contain 'file1 contents' }
120-
it { should_not contain 'file2 contents' }
125+
its(:content) {
126+
should match 'file1 contents'
127+
should_not match 'file2 contents'
128+
}
121129
end
122130
end
123131

spec/acceptance/fragments_are_always_replaced_spec.rb

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,10 @@
3939

4040
describe file("#{basedir}/foo") do
4141
it { should be_file }
42-
it { should_not contain 'caller has replace unset run 1' }
43-
it { should contain 'caller has replace unset run 2' }
42+
its(:content) {
43+
should_not match 'caller has replace unset run 1'
44+
should match 'caller has replace unset run 2'
45+
}
4446
end
4547
end # should create fragment files
4648

@@ -82,8 +84,10 @@
8284

8385
describe file("#{basedir}/foo") do
8486
it { should be_file }
85-
it { should_not contain 'caller has replace true set run 1' }
86-
it { should contain 'caller has replace true set run 2' }
87+
its(:content) {
88+
should_not match 'caller has replace true set run 1'
89+
should match 'caller has replace true set run 2'
90+
}
8791
end
8892
end # should replace its own fragment files when caller has File(replace=>true) set
8993

@@ -125,8 +129,10 @@
125129

126130
describe file("#{basedir}/foo") do
127131
it { should be_file }
128-
it { should_not contain 'caller has replace false set run 1' }
129-
it { should contain 'caller has replace false set run 2' }
132+
its(:content) {
133+
should_not match 'caller has replace false set run 1'
134+
should match 'caller has replace false set run 2'
135+
}
130136
end
131137
end # should replace its own fragment files even when caller has File(replace=>false) set
132138

spec/acceptance/newline_spec.rb

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

3434
describe file("#{basedir}/file") do
3535
it { should be_file }
36-
it { should contain '12' }
36+
its(:content) { should match '12' }
3737
end
3838
end
3939

@@ -54,13 +54,13 @@
5454

5555
it 'applies the manifest twice with no stderr' do
5656
apply_manifest(pp, :catch_failures => true)
57-
apply_manifest(pp, :catch_changes => true)
57+
apply_manifest(pp, :catch_changes => true)
5858
end
5959

6060
describe file("#{basedir}/file") do
6161
it { should be_file }
62-
it("should contain 1\n2\n", :unless => (fact('osfamily') == 'Solaris')) {
63-
should contain "1\n2\n"
62+
its(:content) {
63+
should match /1\n2\n/
6464
}
6565
end
6666
end

0 commit comments

Comments
 (0)