Sha256: 27c207f1d2c0d505d7415e837a2840b9e17355e3e940f5f5de0dc7117fba7956

Contents?: true

Size: 865 Bytes

Versions: 1

Compression:

Stored size: 865 Bytes

Contents

Bundler.require :cassandra

Superstore::Base.config = {
  keyspace: 'superstore_test',
  servers: '127.0.0.1:9160',
  consistency: 'QUORUM',
  thrift: {
    timeout: 5
  }
}

begin
  Superstore::CassandraSchema.drop_keyspace 'superstore_test'
rescue Exception => e
end

sleep 1
Superstore::CassandraSchema.create_keyspace 'superstore_test'
Superstore::CassandraSchema.create_column_family 'Issues'

Superstore::Base.class_eval do
  class_attribute :created_records
  self.created_records = []

  after_create do
    created_records << self
  end

  def self.delete_after_test
    # created_records.reject(&:destroyed?).each(&:destroy)
    Issue.delete_all
    created_records.clear
  end
end

module ActiveSupport
  class TestCase
    teardown do
      if Superstore::Base.created_records.any?
        Superstore::Base.delete_after_test
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
superstore-1.0.0 test/support/cassandra.rb