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



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

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

.actually_windows?Boolean

Returns:

  • (Boolean)


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

def actually_windows?
  actual_platform == :windows
end

.old_windows?Object



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

alias :old_windows? :windows?

.pretend_platformObject



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

def pretend_platform
  @pretend_platform ||= nil
end

.pretend_to_be(platform) ⇒ Object



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

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)


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

def pretend_windows?
  pretend_platform == :windows
end

.pretending?Boolean

Returns:

  • (Boolean)


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

def pretending?
  !pretend_platform.nil?
end

.windows?Boolean

Returns:

  • (Boolean)


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

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