Sha256: 209070f44ad93a2ef7207c661b3860d115a37ad117a5702b31d55e7f805d14ff

Contents?: true

Size: 837 Bytes

Versions: 1

Compression:

Stored size: 837 Bytes

Contents

require_relative '../spec_helper'

require 'hawkular/env_config'

describe Hawkular::EnvConfig do
  subject(:config) { Hawkular::EnvConfig }
  describe '.log_response?' do
    it 'is true if defined' do
      swap_env('HAWKULARCLIENT_LOG_RESPONSE', 'true') do
        expect(config.log_response?).to be_truthy
      end
    end

    it 'is false if null' do
      swap_env('HAWKULARCLIENT_LOG_RESPONSE', nil) do
        expect(config.log_response?).to be_falsey
      end
    end
  end

  describe '.rest_timeout' do
    it 'returns the value for the environment' do
      swap_env('HAWKULARCLIENT_REST_TIMEOUT', '20') do
        expect(config.rest_timeout).to eq '20'
      end
    end
  end

  private

  def swap_env(name, value)
    old_value = ENV[name]
    ENV[name] = value

    yield
  ensure
    ENV[name] = old_value
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hawkular-client-2.9.0 spec/integration/env_config_spec.rb