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



154
155
156
# File 'lib/rspec-puppet/monkey_patches.rb', line 154

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

.old_windows?Object



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

alias :old_windows? :windows?

.pretend_platformObject



173
174
175
# File 'lib/rspec-puppet/monkey_patches.rb', line 173

def pretend_platform
  @pretend_platform ||= nil
end

.pretend_to_be(platform) ⇒ Object



164
165
166
167
168
169
170
# File 'lib/rspec-puppet/monkey_patches.rb', line 164

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:

  • (Boolean)


159
160
161
# File 'lib/rspec-puppet/monkey_patches.rb', line 159

def pretend_windows?
  pretend_platform == :windows
end

.windows?Boolean

Returns:

  • (Boolean)


145
146
147
148
149
150
151
# File 'lib/rspec-puppet/monkey_patches.rb', line 145

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