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



190
191
192
# File 'lib/rspec-puppet/monkey_patches.rb', line 190

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

.actually_windows?Boolean

Returns:

  • (Boolean)


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

def actually_windows?
  actual_platform == :windows
end

.old_windows?Object



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

alias :old_windows? :windows?

.pretend_platformObject



214
215
216
# File 'lib/rspec-puppet/monkey_patches.rb', line 214

def pretend_platform
  @pretend_platform ||= nil
end

.pretend_to_be(platform) ⇒ Object



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

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)


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

def pretend_windows?
  pretend_platform == :windows
end

.pretending?Boolean

Returns:

  • (Boolean)


219
220
221
# File 'lib/rspec-puppet/monkey_patches.rb', line 219

def pretending?
  !pretend_platform.nil?
end

.windows?Boolean

Returns:

  • (Boolean)


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

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