Sha256: 71cd4af6060c6ea05f4733671c6487e2573222c756db5987262bff5fe42b7930

Contents?: true

Size: 1.3 KB

Versions: 1

Compression:

Stored size: 1.3 KB

Contents

$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
$LOAD_PATH.unshift(File.dirname(__FILE__))
require 'rspec'
require 'acts-as-messageable'

Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}

ActiveRecord::Migration.verbose = false

RSpec.configure do |config|
  config.before(:all) do
    ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => ":memory:")
    create_database

    @alice = User.create :email => "alice@example.com"
    @bob   = User.create :email => "bob@example.com"
  end

  config.after(:all) do
    drop_database
  end

  config.after(:each) do
    ActsAsMessageable::Message.destroy_all
  end
end

def create_database
  ActiveRecord::Schema.define(:version => 1) do
    create_table :messages do |t|
      t.string :topic
      t.text :body
      t.references :received_messageable, :polymorphic => true
      t.references :sent_messageable, :polymorphic => true
      t.boolean :opened, :default => false
      t.boolean :recipient_delete, :default => false
      t.boolean :sender_delete, :default => false
      t.string :ancestry
    end

    create_table :users do |t|
      t.string :email
    end
  end
end

def drop_database
  ActiveRecord::Base.connection.tables.each do |table|
    ActiveRecord::Base.connection.drop_table(table)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
acts-as-messageable-0.3.1 spec/spec_helper.rb