Module: Puppet::Util::Platform

Defined in:
lib/rspec-puppet/monkey_patches.rb

Overview

Allow rspec-puppet to pretend to be different platforms.

Class Method Summary collapse

Class Method Details

.actual_platformObject



188
189
190
# File 'lib/rspec-puppet/monkey_patches.rb', line 188

def actual_platform
  @actual_platform ||= !!File::ALT_SEPARATOR ? :windows : :posix
end

.actually_windows?Boolean

Returns:



193
194
195
# File 'lib/rspec-puppet/monkey_patches.rb', line 193

def actually_windows?
  actual_platform == :windows
end

.old_windows?Object



176
# File 'lib/rspec-puppet/monkey_patches.rb', line 176

alias old_windows? windows?

.pretend_platformObject



212
213
214
# File 'lib/rspec-puppet/monkey_patches.rb', line 212

def pretend_platform
  @pretend_platform ||= nil
end

.pretend_to_be(platform) ⇒ Object



203
204
205
206
207
208
209
# File 'lib/rspec-puppet/monkey_patches.rb', line 203

def pretend_to_be(platform)
  # Ensure that we cache the real platform before pretending to be
  # a different one
  actual_platform

  @pretend_platform = platform
end

.pretend_windows?Boolean

Returns:



198
199
200
# File 'lib/rspec-puppet/monkey_patches.rb', line 198

def pretend_windows?
  pretend_platform == :windows
end

.pretending?Boolean

Returns:



217
218
219
# File 'lib/rspec-puppet/monkey_patches.rb', line 217

def pretending?
  !pretend_platform.nil?
end

.windows?Boolean

Returns:



179
180
181
182
183
184
185
# File 'lib/rspec-puppet/monkey_patches.rb', line 179

def windows?
  if RSpec::Puppet.rspec_puppet_example?
    pretending? ? pretend_windows? : (actual_platform == :windows)
  else
    old_windows?
  end
end