Sha256: 9c802c7c12ed97566878e344e66f7c439367091836d29342d9130646443b2b89

Contents?: true

Size: 1.71 KB

Versions: 10

Compression:

Stored size: 1.71 KB

Contents

require 'spec'
require 'open-uri'

current_directory = File.dirname(__FILE__)
require "#{current_directory}/../lib/fog"
# Fog.mock!

def credentials
  @credentials ||= begin
    credentials_path = File.expand_path('~/.fog')
    credentials_data = File.open(credentials_path).read
    YAML.load(credentials_data)
  end
end

def ec2
  Fog::AWS::EC2.new(
    :aws_access_key_id => credentials[:aws_access_key_id],
    :aws_secret_access_key => credentials[:aws_secret_access_key]
  )
end

def eu_s3
  Fog::AWS::S3.new(
    :aws_access_key_id => credentials[:aws_access_key_id],
    :aws_secret_access_key => credentials[:aws_secret_access_key],
    :host => 's3-external-3.amazonaws.com'
  )
end

def files
  Fog::Rackspace::Files.new(
    :rackspace_api_key => credentials[:rackspace_api_key],
    :rackspace_username => credentials[:rackspace_username]
  )
end

def sdb
  Fog::AWS::SimpleDB.new(
    :aws_access_key_id => credentials[:aws_access_key_id],
    :aws_secret_access_key => credentials[:aws_secret_access_key]
  )
end

def servers
  Fog::Rackspace::Servers.new(
    :rackspace_api_key => credentials[:rackspace_api_key],
    :rackspace_username => credentials[:rackspace_username]
  )
end

def s3
  Fog::AWS::S3.new(
    :aws_access_key_id => credentials[:aws_access_key_id],
    :aws_secret_access_key => credentials[:aws_secret_access_key]
  )
end

def eventually(max_delay = 16, &block)
  delays = [0]
  delay_step = 1
  total = 0
  while true
    delay = 1
    delay_step.times do
      delay *= 2
    end
    delays << delay
    delay_step += 1
    break if delay >= max_delay
  end
  delays.each do |delay|
    begin
      sleep(delay)
      yield
      break
    rescue => error
      raise error if delay >= max_delay
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
fog-0.0.24 spec/spec_helper.rb
fog-0.0.23 spec/spec_helper.rb
fog-0.0.22 spec/spec_helper.rb
fog-0.0.21 spec/spec_helper.rb
fog-0.0.20 spec/spec_helper.rb
fog-0.0.19 spec/spec_helper.rb
fog-0.0.18 spec/spec_helper.rb
fog-0.0.17 spec/spec_helper.rb
fog-0.0.16 spec/spec_helper.rb
fog-0.0.15 spec/spec_helper.rb