Sha256: 4dd610fb66cc350827c8415b980e17488522260c217f2e06cb61748a2b3de48e

Contents?: true

Size: 1.53 KB

Versions: 39

Compression:

Stored size: 1.53 KB

Contents

# Contexts for stubbing platforms
# In a describe or context block, adding :as_platform => :windows or
# :as_platform => :posix will stub the relevant Puppet features, as well as
# the behavior of Ruby's filesystem methods by changing File::ALT_SEPARATOR.

shared_context "windows", :as_platform => :windows do
  before :each do
    Facter.stubs(:value).with(:operatingsystem).returns 'Windows'
    Puppet.features.stubs(:microsoft_windows?).returns(true)
    Puppet.features.stubs(:posix?).returns(false)
  end

  around do |example|
    file_alt_separator = File::ALT_SEPARATOR
    file_path_separator = File::PATH_SEPARATOR

    # prevent Ruby from warning about changing a constant
    with_verbose_disabled do
      File::ALT_SEPARATOR = '\\'
      File::PATH_SEPARATOR = ';'
    end
    example.run
    with_verbose_disabled do
      File::ALT_SEPARATOR = file_alt_separator
      File::PATH_SEPARATOR = file_path_separator
    end
  end
end

shared_context "posix", :as_platform => :posix do
  before :each do
    Puppet.features.stubs(:microsoft_windows?).returns(false)
    Puppet.features.stubs(:posix?).returns(true)
  end

  around do |example|
    file_alt_separator = File::ALT_SEPARATOR
    file_path_separator = File::PATH_SEPARATOR

    # prevent Ruby from warning about changing a constant
    with_verbose_disabled do
      File::ALT_SEPARATOR = nil
      File::PATH_SEPARATOR = ':'
    end
    example.run
    with_verbose_disabled do
      File::ALT_SEPARATOR = file_alt_separator
      File::PATH_SEPARATOR = file_path_separator
    end
  end
end

Version data entries

39 entries across 39 versions & 2 rubygems

Version Path
puppet-2.7.26 spec/shared_contexts/platform.rb
puppet-2.7.25 spec/shared_contexts/platform.rb
puppet-2.7.24 spec/shared_contexts/platform.rb
puppet-3.3.2 spec/shared_contexts/platform.rb
puppet-3.3.1 spec/shared_contexts/platform.rb
puppet-3.3.1.rc3 spec/shared_contexts/platform.rb
puppet-3.3.1.rc2 spec/shared_contexts/platform.rb
puppet-3.3.1.rc1 spec/shared_contexts/platform.rb
puppet-3.3.0 spec/shared_contexts/platform.rb
puppet-3.3.0.rc3 spec/shared_contexts/platform.rb
puppet-3.3.0.rc2 spec/shared_contexts/platform.rb
puppet-3.2.4 spec/shared_contexts/platform.rb
puppet-2.7.23 spec/shared_contexts/platform.rb
puppet-3.2.3 spec/shared_contexts/platform.rb
puppet-3.2.3.rc1 spec/shared_contexts/platform.rb
puppet-3.2.2 spec/shared_contexts/platform.rb
puppet-2.7.22 spec/shared_contexts/platform.rb
puppet-3.2.1 spec/shared_contexts/platform.rb
puppet-3.2.1.rc1 spec/shared_contexts/platform.rb
puppet-3.2.0.rc2 spec/shared_contexts/platform.rb