Sha256: 5004dc29541002dff3c8918aaf9afe583514ec177047d5f46a204aa91b6f25a7

Contents?: true

Size: 1.7 KB

Versions: 53

Compression:

Stored size: 1.7 KB

Contents

Shindo.tests do
  before do
    @old_home = ENV['HOME']
    @old_rc   = ENV['FOG_RC']
    @old_credential = ENV['FOG_CREDENTIAL']
    @old_credentials = Fog.credentials
    Fog.instance_variable_set('@credential_path', nil) # kill memoization
    Fog.instance_variable_set('@credential', nil) # kill memoization
  end

  after do
    ENV['HOME'] = @old_home
    ENV['FOG_RC'] = @old_rc
    ENV['FOG_CREDENTIAL'] = @old_credential
    Fog.credentials = @old_credentials
  end

  tests('credential') do
    returns(:default, "is :default") { Fog.credential }

    returns(:foo, "can be set directly") do
      Fog.credential = "foo"
      Fog.credential
    end

    returns(:bar, "can be set with environment variable") do
      ENV["FOG_CREDENTIAL"] = "bar"
      Fog.credential
    end
  end

  tests('credentials_path') do
    returns('/rc/path', 'FOG_RC takes precedence over HOME') {
      ENV['HOME'] = '/home/path'
      ENV['FOG_RC'] = '/rc/path'
    }

    returns('/expanded/path', 'properly expands paths') {
      ENV['FOG_RC'] = '/expanded/subdirectory/../path'
      Fog.credentials_path
    }

    returns(File.join(ENV['HOME'], '.fog'), 'falls back to home path if FOG_RC not set') {
      ENV.delete('FOG_RC')
      Fog.credentials_path
    }

    returns(nil, 'ignores home path if it does not exist') {
      ENV.delete('FOG_RC')
      ENV['HOME'] = '/no/such/path'
      Fog.credentials_path
    }

    returns(nil, 'File.expand_path raises because of non-absolute path') {
      ENV.delete('FOG_RC')
      ENV['HOME'] = '.'
      Fog.credentials_path
    }

    returns(nil, 'returns nil when neither FOG_RC or HOME are set') {
      ENV.delete('HOME')
      ENV.delete('FOG_RC')
      Fog.credentials_path
    }
  end
end

Version data entries

53 entries across 53 versions & 16 rubygems

Version Path
gapinc-fog-1.12.1.2.1 tests/core/credential_tests.rb
gapinc-fog-1.14.0 tests/core/credential_tests.rb
fog-maestrodev-1.14.0.20130806165225 tests/core/credential_tests.rb
fog-1.14.0 tests/core/credential_tests.rb
fog-1.13.0 tests/core/credential_tests.rb
gapinc-fog-1.12.1.2 tests/core/credential_tests.rb
gapinc-fog-1.12.1.1 tests/core/credential_tests.rb
gapinc-fog-1.12.1a tests/core/credential_tests.rb
gapinc-fog-1.12.1 tests/core/credential_tests.rb
fog-1.12.1 tests/core/credential_tests.rb
fog-1.12.0 tests/core/credential_tests.rb
hpfog-0.0.20 tests/core/credential_tests.rb
vagrant-shell-0.2.6 vendor/bundle/gems/fog-1.10.1/tests/core/credential_tests.rb
vagrant-shell-0.2.5 vendor/bundle/gems/fog-1.10.1/tests/core/credential_tests.rb
fog-nirvanix-1.8.2 tests/core/credential_tests.rb
fog-1.11.1 tests/core/credential_tests.rb
fog-1.11.0 tests/core/credential_tests.rb
fog-nirvanix-1.8.1 tests/core/credential_tests.rb
fog-1.10.1 tests/core/credential_tests.rb
fog-parser-fix-1.6.1 tests/core/credential_tests.rb