|
19 | 19 | "/dev/vg00/lv01\t/spare \t \t ext3 defaults\t1 2" |
20 | 20 | end |
21 | 21 |
|
22 | | - # LAK:FIXME I can't mock Facter because this test happens at parse-time. |
| 22 | + # LAK:FIXME I can't double Facter because this test happens at parse-time. |
23 | 23 | it 'defaults to /etc/vfstab on Solaris' do |
24 | 24 | if Facter.value(:osfamily) != 'Solaris' |
25 | 25 | skip('This test only works on Solaris') |
|
112 | 112 |
|
113 | 113 | describe 'mountinstances' do |
114 | 114 | it 'gets name from mountoutput found on Solaris' do |
115 | | - Facter.stubs(:value).with(:osfamily).returns 'Solaris' |
116 | | - described_class.stubs(:mountcmd).returns(File.read(my_fixture('solaris.mount'))) |
| 115 | + allow(Facter).to receive(:value).with(:osfamily).and_return 'Solaris' |
| 116 | + allow(described_class).to receive(:mountcmd).and_return(File.read(my_fixture('solaris.mount'))) |
117 | 117 | mounts = described_class.mountinstances |
118 | 118 | expect(mounts.size).to eq(6) |
119 | 119 | expect(mounts[0]).to eq(name: '/', mounted: :yes) |
|
125 | 125 | end |
126 | 126 |
|
127 | 127 | it 'gets name from mountoutput found on HP-UX' do |
128 | | - Facter.stubs(:value).with(:osfamily).returns 'HP-UX' |
129 | | - described_class.stubs(:mountcmd).returns(File.read(my_fixture('hpux.mount'))) |
| 128 | + allow(Facter).to receive(:value).with(:osfamily).and_return 'HP-UX' |
| 129 | + allow(described_class).to receive(:mountcmd).and_return(File.read(my_fixture('hpux.mount'))) |
130 | 130 | mounts = described_class.mountinstances |
131 | 131 | expect(mounts.size).to eq(17) |
132 | 132 | expect(mounts[0]).to eq(name: '/', mounted: :yes) |
|
149 | 149 | end |
150 | 150 |
|
151 | 151 | it 'gets name from mountoutput found on Darwin' do |
152 | | - Facter.stubs(:value).with(:osfamily).returns 'Darwin' |
153 | | - described_class.stubs(:mountcmd).returns(File.read(my_fixture('darwin.mount'))) |
| 152 | + allow(Facter).to receive(:value).with(:osfamily).and_return 'Darwin' |
| 153 | + allow(described_class).to receive(:mountcmd).and_return(File.read(my_fixture('darwin.mount'))) |
154 | 154 | mounts = described_class.mountinstances |
155 | 155 | expect(mounts.size).to eq(6) |
156 | 156 | expect(mounts[0]).to eq(name: '/', mounted: :yes) |
|
162 | 162 | end |
163 | 163 |
|
164 | 164 | it 'gets name from mountoutput found on Linux' do |
165 | | - Facter.stubs(:value).with(:osfamily).returns 'Gentoo' |
166 | | - described_class.stubs(:mountcmd).returns(File.read(my_fixture('linux.mount'))) |
| 165 | + allow(Facter).to receive(:value).with(:osfamily).and_return 'Gentoo' |
| 166 | + allow(described_class).to receive(:mountcmd).and_return(File.read(my_fixture('linux.mount'))) |
167 | 167 | mounts = described_class.mountinstances |
168 | 168 | expect(mounts[0]).to eq(name: '/', mounted: :yes) |
169 | 169 | expect(mounts[1]).to eq(name: '/lib64/rc/init.d', mounted: :yes) |
|
175 | 175 | end |
176 | 176 |
|
177 | 177 | it 'gets name from mountoutput found on AIX' do |
178 | | - Facter.stubs(:value).with(:osfamily).returns 'AIX' |
179 | | - described_class.stubs(:mountcmd).returns(File.read(my_fixture('aix.mount'))) |
| 178 | + allow(Facter).to receive(:value).with(:osfamily).and_return 'AIX' |
| 179 | + allow(described_class).to receive(:mountcmd).and_return(File.read(my_fixture('aix.mount'))) |
180 | 180 | mounts = described_class.mountinstances |
181 | 181 | expect(mounts[0]).to eq(name: '/', mounted: :yes) |
182 | 182 | expect(mounts[1]).to eq(name: '/usr', mounted: :yes) |
|
190 | 190 | end |
191 | 191 |
|
192 | 192 | it 'raises an error if a line is not understandable' do |
193 | | - described_class.stubs(:mountcmd).returns('bazinga!') |
| 193 | + allow(described_class).to receive(:mountcmd).and_return('bazinga!') |
194 | 194 | expect { described_class.mountinstances }.to raise_error Puppet::Error, 'Could not understand line bazinga! from mount output' |
195 | 195 | end |
196 | 196 | end |
197 | 197 |
|
198 | 198 | it "supports AIX's paragraph based /etc/filesystems" do |
199 | 199 | pending 'This test only works on AIX' unless Facter.value(:osfamily) == 'AIX' |
200 | | - Facter.stubs(:value).with(:osfamily).returns 'AIX' |
201 | | - described_class.stubs(:default_target).returns my_fixture('aix.filesystems') |
202 | | - described_class.stubs(:mountcmd).returns File.read(my_fixture('aix.mount')) |
| 200 | + allow(Facter).to receive(:value).with(:osfamily).and_return 'AIX' |
| 201 | + allow(described_class).to receive(:default_target).and_return my_fixture('aix.filesystems') |
| 202 | + allow(described_class).to receive(:mountcmd).and_return File.read(my_fixture('aix.mount')) |
203 | 203 | instances = described_class.instances |
204 | 204 | expect(instances[0].name).to eq('/') |
205 | 205 | expect(instances[0].device).to eq('/dev/hd4') |
|
220 | 220 | end |
221 | 221 |
|
222 | 222 | before :each do |
223 | | - Facter.stubs(:value).with(:osfamily).returns platform |
| 223 | + allow(Facter).to receive(:value).with(:osfamily).and_return platform |
224 | 224 | if Facter[:osfamily] == 'Solaris' |
225 | 225 | platform == 'solaris' || |
226 | | - skip("We need to stub the operatingsystem fact at load time, but can't") |
| 226 | + skip("We need to double the operatingsystem fact at load time, but can't") |
227 | 227 | else |
228 | 228 | platform != 'solaris' || |
229 | | - skip("We need to stub the operatingsystem fact at load time, but can't") |
| 229 | + skip("We need to double the operatingsystem fact at load time, but can't") |
230 | 230 | end |
231 | 231 |
|
232 | 232 | # Stub the mount output to our fixture. |
233 | 233 | begin |
234 | 234 | mount = my_fixture(platform + '.mount') |
235 | | - described_class.stubs(:mountcmd).returns File.read(mount) |
| 235 | + allow(described_class).to receive(:mountcmd).and_return File.read(mount) |
236 | 236 | rescue |
237 | 237 | skip "is #{platform}.mount missing at this point?" |
238 | 238 | end |
239 | 239 |
|
240 | 240 | # Note: we have to stub default_target before creating resources |
241 | 241 | # because it is used by Puppet::Type::Mount.new to populate the |
242 | 242 | # :target property. |
243 | | - described_class.stubs(:default_target).returns fstab |
| 243 | + allow(described_class).to receive(:default_target).and_return fstab |
244 | 244 | end |
245 | 245 |
|
246 | 246 | # Following mountpoint are present in all fstabs/mountoutputs |
|
274 | 274 | end |
275 | 275 |
|
276 | 276 | before :each do |
277 | | - Facter.stubs(:value).with(:kernel).returns 'Linux' |
278 | | - Facter.stubs(:value).with(:operatingsystem).returns 'RedHat' |
279 | | - Facter.stubs(:value).with(:osfamily).returns 'RedHat' |
| 277 | + allow(Facter).to receive(:value).with(:kernel).and_return 'Linux' |
| 278 | + allow(Facter).to receive(:value).with(:operatingsystem).and_return 'RedHat' |
| 279 | + allow(Facter).to receive(:value).with(:osfamily).and_return 'RedHat' |
280 | 280 | begin |
281 | 281 | mount = my_fixture('linux.mount') |
282 | | - described_class.stubs(:mountcmd).returns File.read(mount) |
| 282 | + allow(described_class).to receive(:mountcmd).and_return File.read(mount) |
283 | 283 | rescue |
284 | 284 | skip 'is linux.mount missing at this point?' |
285 | 285 | end |
286 | 286 |
|
287 | | - described_class.stubs(:default_target).returns my_fixture('linux.fstab') |
| 287 | + allow(described_class).to receive(:default_target).and_return my_fixture('linux.fstab') |
288 | 288 | end |
289 | 289 |
|
290 | 290 | describe 'when handling whitespaces in mountpoints' do |
|
332 | 332 |
|
333 | 333 | before :each do |
334 | 334 | [:osfamily, :operatingsystem, :kernel].each do |fact| |
335 | | - Facter.stubs(:value).with(fact).returns platform |
| 335 | + allow(Facter).to receive(:value).with(fact).and_return platform |
336 | 336 | end |
337 | 337 |
|
338 | 338 | if Facter[:osfamily] == 'Solaris' |
339 | 339 | platform == 'solaris' || |
340 | | - skip("We need to stub the operatingsystem fact at load time, but can't") |
| 340 | + skip("We need to double the operatingsystem fact at load time, but can't") |
341 | 341 | else |
342 | 342 | platform != 'solaris' || |
343 | | - skip("We need to stub the operatingsystem fact at load time, but can't") |
| 343 | + skip("We need to double the operatingsystem fact at load time, but can't") |
344 | 344 | end |
345 | 345 |
|
346 | 346 | # Stub the mount output to our fixture. |
347 | 347 | begin |
348 | 348 | mount = my_fixture(platform + '.mount') |
349 | | - described_class.stubs(:mountcmd).returns File.read(mount) |
| 349 | + allow(described_class).to receive(:mountcmd).and_return File.read(mount) |
350 | 350 | rescue |
351 | 351 | skip "is #{platform}.mount missing at this point?" |
352 | 352 | end |
353 | 353 |
|
354 | 354 | # Note: we have to stub default_target before creating resources |
355 | 355 | # because it is used by Puppet::Type::Mount.new to populate the |
356 | 356 | # :target property. |
357 | | - described_class.stubs(:default_target).returns fstab |
| 357 | + allow(described_class).to receive(:default_target).and_return fstab |
358 | 358 | end |
359 | 359 |
|
360 | 360 | describe 'on other platforms than Solaris', if: Facter.value(:osfamily) != 'Solaris' do |
|
0 commit comments