Sha256: 48fd165c5920345f9cf92289a6b3a109806d6056ce87adfdb3cbe1a2ce3dc75b

Contents?: true

Size: 1.59 KB

Versions: 2

Compression:

Stored size: 1.59 KB

Contents

# lib = File.expand_path("#{File.dirname(__FILE__)}/../lib")
# $:.unshift(lib) unless $:.include?('lib') || $:.include?(lib)
# require File.expand_path('../../lib/cassandra_object', __FILE__)
require 'cassandra/0.8'
require 'cassandra_object'
require 'rails/test_help'
require 'mocha/setup'

class Issue < CassandraObject::Base
  key :uuid
  attribute :created_at, :type => :time
  attribute :updated_at, :type => :time
  attribute :description, :type => :string
  attribute :worth, :type => :decimal, :precision => 100
  attribute :name, :type => :string
  before_validation :set_defaults, :on => :create

  def set_defaults
    self.name ||= 'default name'
  end
end

class IssueWithoutTimestamps < CassandraObject::Base
  self.column_family = 'Issues'

  key :uuid
  attribute :description, :type => :string
  attribute :worth, :type => :decimal, :precision => 100
  attribute :name, :type => :string
  before_validation :set_defaults, :on => :create

  def set_defaults
    self.name ||= 'default name'
  end
end

class Counter < CassandraObject::Base
  attribute :created_at, :type => :time
  attribute :updated_at, :type => :time

  self.write_consistency = :all
end

module CassandraObject
  class TestCase < ActiveSupport::TestCase
    TEST_KEYSPACE = 'place_directory_development'

    setup do
      CassandraObject::Base.establish_connection(
        :keyspace => TEST_KEYSPACE,
        # servers: '192.168.0.100:9160'
        :servers => '127.0.0.1:9160'
      )
    end

    teardown do
      Issue.delete_all
      Counter.delete_all
    end

    def connection
      CassandraObject::Base.connection
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sessionm-cassandra_object-2.4.1 test/test_helper.rb
sessionm-cassandra_object-2.4.0 test/test_helper.rb