Sha256: 4d2867ed5c6babec76a01517b282a8e74801ecbf3731c694d10645c0976fbdb0

Contents?: true

Size: 1.1 KB

Versions: 4

Compression:

Stored size: 1.1 KB

Contents

require 'spec_helper'

describe Alephant::Harness::Service::DynamoDB do

  describe ".create" do
    it "creates a table based off a schema" do

      table_name = 'test_lookup'
      schema_name = 'lookup'

      expected_schema = YAML::load_file(File.join(File.dirname(__FILE__), *[%w'..' * 2], 'schema', "#{schema_name}.yaml"))
      expected_schema[:table_name] = table_name

      expect_any_instance_of(AWS::DynamoDB::Client::V20120810).to receive(:create_table).with(expected_schema)
      subject.create(table_name, schema_name)

    end
  end

  describe ".delete" do
    let(:tables) { %w(foo bar) }

    context "When tables exist" do
      it "removes specified tables" do
        expect_any_instance_of(AWS::DynamoDB::Client::V20120810).to receive(:delete_table).twice
        subject.remove(tables)
      end
    end

    context "When tables don't exist" do
      it "Fails silently" do
        expect_any_instance_of(AWS::DynamoDB::Client::V20120810).to receive(:delete_table).twice.and_raise(Exception)
        expect { subject.remove(tables) }.to_not raise_error(Exception)
      end
    end

  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
alephant-harness-0.1.3 spec/service/dynamo_db_spec.rb
alephant-harness-0.1.2 spec/service/dynamo_db_spec.rb
alephant-harness-0.1.1 spec/service/dynamo_db_spec.rb
alephant-harness-0.1.0 spec/service/dynamo_db_spec.rb