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



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

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

.old_windows?Object



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

alias :old_windows? :windows?

.pretend_platformObject



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

def pretend_platform
  @pretend_platform ||= nil
end

.pretend_to_be(platform) ⇒ Object



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

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)


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

def pretend_windows?
  pretend_platform == :windows
end

.windows?Boolean

Returns:

  • (Boolean)


133
134
135
136
137
138
139
# File 'lib/rspec-puppet/monkey_patches.rb', line 133

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