Sha256: 2721306ebe703b889809be99d26fa5a7711550e58fa8f774d1561de7c8ff2b10

Contents?: true

Size: 948 Bytes

Versions: 7

Compression:

Stored size: 948 Bytes

Contents

require 'deltacloud/method_serializer'

# Create 'mock' version of original driver client/gem:

module Mock
  class EC2 < AWS::EC2::Base

    include MethodSerializer::Cache

    def self.cached_methods
      [
        :describe_images,
        :describe_availability_zones,
        :describe_keypairs,
        :create_keypair,
        :run_instances,
        :describe_instances,
        :reboot_instances,
        :terminate_instances,
        :delete_keypair
      ]
    end

    MethodSerializer::Cache::wrap_methods(self, :cache_dir => File.join(File.dirname(__FILE__), '..', '..', '..', '..', 'tests', 'ec2', 'support'))
  end
end


# Replace original client with mock client
Deltacloud::Drivers::EC2::EC2Driver.class_eval do
  alias_method :original_new_client, :new_client

  def new_client(credentials, opts={})
    Mock::EC2.new(
      :access_key_id => credentials.user,
      :secret_access_key => credentials.password
    )
  end

end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
bbrowning-deltacloud-core-0.0.6.1-java lib/deltacloud/base_driver/mock_driver.rb
bbrowning-deltacloud-core-0.0.6-java lib/deltacloud/base_driver/mock_driver.rb
bbrowning-deltacloud-core-0.0.6 lib/deltacloud/base_driver/mock_driver.rb
deltacloud-core-0.0.6 lib/deltacloud/base_driver/mock_driver.rb
bbrowning-deltacloud-core-0.0.4 lib/deltacloud/base_driver/mock_driver.rb
bbrowning-deltacloud-core-0.0.4-java lib/deltacloud/base_driver/mock_driver.rb
deltacloud-core-0.0.5 lib/deltacloud/base_driver/mock_driver.rb