blob: 2e6d4d7a616904f27ccf87e0ac476dc4e9523fff (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# Contexts for stubbing platforms
# In a describe or context block, adding :as_platform => :windows or
# :as_platform => :posix will stub the relevant Puppet features, as well as
# the behavior of Ruby's filesystem methods by changing File::ALT_SEPARATOR.
shared_context "windows", :as_platform => :windows do
before :each do
Facter.stubs(:value).with(:operatingsystem).returns 'Windows'
Facter.stubs(:value).with(:osfamily).returns 'windows'
Puppet.features.stubs(:microsoft_windows?).returns(true)
Puppet.features.stubs(:posix?).returns(false)
end
around do |example|
file_alt_separator = File::ALT_SEPARATOR
file_path_separator = File::PATH_SEPARATOR
# prevent Ruby from warning about changing a constant
with_verbose_disabled do
File::ALT_SEPARATOR = '\\'
File::PATH_SEPARATOR = ';'
end
example.run
with_verbose_disabled do
File::ALT_SEPARATOR = file_alt_separator
File::PATH_SEPARATOR = file_path_separator
end
end
end
shared_context "posix", :as_platform => :posix do
before :each do
Puppet.features.stubs(:microsoft_windows?).returns(false)
Puppet.features.stubs(:posix?).returns(true)
end
around do |example|
file_alt_separator = File::ALT_SEPARATOR
file_path_separator = File::PATH_SEPARATOR
# prevent Ruby from warning about changing a constant
with_verbose_disabled do
File::ALT_SEPARATOR = nil
File::PATH_SEPARATOR = ':'
end
example.run
with_verbose_disabled do
File::ALT_SEPARATOR = file_alt_separator
File::PATH_SEPARATOR = file_path_separator
end
end
end
|