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



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

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

.old_windows?Object



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

alias :old_windows? :windows?

.pretend_platformObject



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

def pretend_platform
  @pretend_platform ||= nil
end

.pretend_to_be(platform) ⇒ Object



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

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)


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

def pretend_windows?
  pretend_platform == :windows
end

.windows?Boolean

Returns:

  • (Boolean)


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

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