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



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

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

.actually_windows?Boolean

Returns:

  • (Boolean)


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

def actually_windows?
  actual_platform == :windows
end

.old_windows?Object



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

alias :old_windows? :windows?

.pretend_platformObject



200
201
202
# File 'lib/rspec-puppet/monkey_patches.rb', line 200

def pretend_platform
  @pretend_platform ||= nil
end

.pretend_to_be(platform) ⇒ Object



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

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)


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

def pretend_windows?
  pretend_platform == :windows
end

.windows?Boolean

Returns:

  • (Boolean)


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

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