Sha256: 3c440c3d76ab160ddf0ad3b096011796ffc91c3c47092beec7142a5b344d2e21

Contents?: true

Size: 1.39 KB

Versions: 9

Compression:

Stored size: 1.39 KB

Contents

# encoding: UTF-8
require 'rubygems'
require 'bundler/setup'
require 'winrm-fs'
require 'json'
require_relative 'matchers'

# Creates a WinRM connection for integration tests
module ConnectionHelper
  def winrm_connection
    config = symbolize_keys(YAML.load(File.read(winrm_config_path)))
    config[:options].merge!(basic_auth_only: true) unless config[:auth_type].eql? :kerberos
    winrm = WinRM::WinRMWebService.new(
      config[:endpoint], config[:auth_type].to_sym, config[:options])
    winrm
  end

  def winrm_config_path
    # Copy config-example.yml to config.yml and edit for your local configuration
    path = File.expand_path("#{File.dirname(__FILE__)}/config.yml")
    unless File.exist?(path)
      # user hasn't done this, so use sane defaults for unit tests
      path = File.expand_path("#{File.dirname(__FILE__)}/config-example.yml")
    end
    path
  end

  # rubocop:disable Metrics/MethodLength
  def symbolize_keys(hash)
    hash.each_with_object({}) do |(key, value), result|
      new_key = case key
                when String then key.to_sym
                else key
                end
      new_value = case value
                  when Hash then symbolize_keys(value)
                  else value
                  end
      result[new_key] = new_value
      result
    end
  end
  # rubocop:enable Metrics/MethodLength
end

RSpec.configure do |config|
  config.include(ConnectionHelper)
end

Version data entries

9 entries across 8 versions & 3 rubygems

Version Path
vagrant-unbundled-1.8.1.1 vendor/bundle/ruby/2.3.0/gems/winrm-fs-0.2.3/spec/spec_helper.rb
winrm-fs-0.2.3 spec/spec_helper.rb
vagrant-cloudstack-1.2.0 vendor/bundle/gems/winrm-fs-0.2.2/spec/spec_helper.rb
winrm-fs-0.2.2 spec/spec_helper.rb
winrm-fs-0.2.1 spec/spec_helper.rb
vagrant-cloudstack-1.1.0 vendor/bundle/gems/winrm-fs-0.1.0/spec/spec_helper.rb
vagrant-cloudstack-1.1.0 vendor/bundle/gems/winrm-fs-0.2.0/spec/spec_helper.rb
winrm-fs-0.2.0 spec/spec_helper.rb
winrm-fs-0.1.0 spec/spec_helper.rb