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



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

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

.actually_windows?Boolean

Returns:

  • (Boolean)


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

def actually_windows?
  actual_platform == :windows
end

.old_windows?Object



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

alias old_windows? windows?

.pretend_platformObject



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

def pretend_platform
  @pretend_platform ||= nil
end

.pretend_to_be(platform) ⇒ Object



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

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)


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

def pretend_windows?
  pretend_platform == :windows
end

.pretending?Boolean

Returns:

  • (Boolean)


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

def pretending?
  !pretend_platform.nil?
end

.windows?Boolean

Returns:

  • (Boolean)


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

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