Sha256: f223354fd2c14803446093e47bc87b6aeb8610cf8b717a7f19c3601188d1a7df

Contents?: true

Size: 1.6 KB

Versions: 148

Compression:

Stored size: 1.6 KB

Contents

#! /usr/bin/env ruby
require 'spec_helper'

describe "Windows UTF8 environment variables", :if => Puppet.features.microsoft_windows? do
  # The Puppet::Util::Windows::Process class is used to manipulate environment variables as it is known to handle UTF8 characters. Where as the implementation of ENV in ruby does not.
  # before and end all are used to inject environment variables before the test helper 'before_each_test' function is called
  # Do not use before and after hooks in these tests as it may have unintended consequences

  before(:all) {
    @varname = 'test_helper_spec-test_variable'
    @rune_utf8 = "\u16A0\u16C7\u16BB\u16EB\u16D2\u16E6\u16A6\u16EB\u16A0\u16B1\u16A9\u16A0\u16A2\u16B1\u16EB\u16A0\u16C1\u16B1\u16AA\u16EB\u16B7\u16D6\u16BB\u16B9\u16E6\u16DA\u16B3\u16A2\u16D7"

    Puppet::Util::Windows::Process.set_environment_variable(@varname, @rune_utf8)
  }
  after(:all) {
    # Need to cleanup this environment variable otherwise it contaminates any subsequent tests
    Puppet::Util::Windows::Process.set_environment_variable(@varname, nil)
  }
  
  it "#after_each_test should preserve UTF8 environment variables" do
    envhash = Puppet::Util::Windows::Process.get_environment_strings
    expect(envhash[@varname]).to eq(@rune_utf8)
    # Change the value in the test to force test_helper to restore the environment
    ENV[@varname] = 'bad foo'

    # Prematurely trigger the after_each_test method
    Puppet::Test::TestHelper.after_each_test

    envhash = Puppet::Util::Windows::Process.get_environment_strings
    expect(envhash[@varname]).to eq(@rune_utf8)
  end
end

Version data entries

148 entries across 148 versions & 1 rubygems

Version Path
puppet-4.10.1 spec/integration/test/test_helper_spec.rb
puppet-4.10.1-x86-mingw32 spec/integration/test/test_helper_spec.rb
puppet-4.10.1-x64-mingw32 spec/integration/test/test_helper_spec.rb
puppet-4.10.1-universal-darwin spec/integration/test/test_helper_spec.rb
puppet-4.10.0 spec/integration/test/test_helper_spec.rb
puppet-4.10.0-x86-mingw32 spec/integration/test/test_helper_spec.rb
puppet-4.10.0-x64-mingw32 spec/integration/test/test_helper_spec.rb
puppet-4.10.0-universal-darwin spec/integration/test/test_helper_spec.rb
puppet-4.9.4 spec/integration/test/test_helper_spec.rb
puppet-4.9.4-x86-mingw32 spec/integration/test/test_helper_spec.rb
puppet-4.9.4-x64-mingw32 spec/integration/test/test_helper_spec.rb
puppet-4.9.4-universal-darwin spec/integration/test/test_helper_spec.rb
puppet-4.9.3 spec/integration/test/test_helper_spec.rb
puppet-4.9.3-x86-mingw32 spec/integration/test/test_helper_spec.rb
puppet-4.9.3-x64-mingw32 spec/integration/test/test_helper_spec.rb
puppet-4.9.3-universal-darwin spec/integration/test/test_helper_spec.rb
puppet-4.9.2 spec/integration/test/test_helper_spec.rb
puppet-4.9.2-x86-mingw32 spec/integration/test/test_helper_spec.rb
puppet-4.9.2-x64-mingw32 spec/integration/test/test_helper_spec.rb
puppet-4.9.2-universal-darwin spec/integration/test/test_helper_spec.rb