Sha256: c3f78ea3a707c1fccf52ca879ee57e06ec5fc32814bf8dd9e4fabbedc8e93b79

Contents?: true

Size: 1.51 KB

Versions: 113

Compression:

Stored size: 1.51 KB

Contents

# Contexts for stubbing platforms
# In a describe or context block, adding :as_platform => :windows or
# :as_platform => :posix will stub the relevant facter config, 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.fact(:operatingsystem).stubs(:value).returns('Windows')
    Facter::Util::Config.stubs(:is_windows?).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 = '\\'
      File::PATH_SEPARATOR = ';'
    end
    begin
      example.run
    ensure
      with_verbose_disabled do
        File::ALT_SEPARATOR = file_alt_separator
        File::PATH_SEPARATOR = file_path_separator
      end
    end
  end
end

shared_context "posix", :as_platform => :posix do
  before :each do
    Facter::Util::Config.stubs(:is_windows?).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 = nil
      File::PATH_SEPARATOR = ':'
    end
    begin
      example.run
    ensure
      with_verbose_disabled do
        File::ALT_SEPARATOR = file_alt_separator
        File::PATH_SEPARATOR = file_path_separator
      end
    end
  end
end

Version data entries

113 entries across 113 versions & 2 rubygems

Version Path
facter-2.5.7 spec/shared_contexts/platform.rb
facter-2.5.7-x86-mingw32 spec/shared_contexts/platform.rb
facter-2.5.7-x64-mingw32 spec/shared_contexts/platform.rb
facter-2.5.7-universal-darwin spec/shared_contexts/platform.rb
facter-2.5.6-x86-mingw32 spec/shared_contexts/platform.rb
facter-2.5.6-x64-mingw32 spec/shared_contexts/platform.rb
facter-2.5.6-universal-darwin spec/shared_contexts/platform.rb
facter-2.5.6 spec/shared_contexts/platform.rb
facter-2.5.5-x86-mingw32 spec/shared_contexts/platform.rb
facter-2.5.5-x64-mingw32 spec/shared_contexts/platform.rb
facter-2.5.5-universal-darwin spec/shared_contexts/platform.rb
facter-2.5.5 spec/shared_contexts/platform.rb
facter-2.5.4-x86-mingw32 spec/shared_contexts/platform.rb
facter-2.5.4-x64-mingw32 spec/shared_contexts/platform.rb
facter-2.5.4-universal-darwin spec/shared_contexts/platform.rb
facter-2.5.4 spec/shared_contexts/platform.rb
facter-2.5.1 spec/shared_contexts/platform.rb
facter-2.5.1-x86-mingw32 spec/shared_contexts/platform.rb
facter-2.5.1-x64-mingw32 spec/shared_contexts/platform.rb
facter-2.5.1-universal-darwin spec/shared_contexts/platform.rb