Sha256: 7d8bf0d8e7c8f0c5d95a56108480c9569029257b00fa03f3c1430f67f68db905

Contents?: true

Size: 1.31 KB

Versions: 5

Compression:

Stored size: 1.31 KB

Contents

$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
$LOAD_PATH.unshift(File.dirname(__FILE__))
require 'rubygems'
require 'active_record'
require 'rspec'
require 'datts_right'
require 'datts_right/page'

# Allow to connect to SQLite
root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
Dir.mkdir("db") unless File.directory?("db")
ActiveRecord::Base.establish_connection(
  :adapter => "sqlite3",
  :database => "#{root}/db/test.db"
)

# Requires supporting files with custom matchers and macros, etc,
# in ./support/ and its subdirectories.
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}

RSpec.configure do |config|
  
end

def reset_database
  %W(pages dynamic_attributes).each do |table_name|
    ActiveRecord::Base.connection.execute("DROP TABLE IF EXISTS '#{table_name}'")
  end
  ActiveRecord::Base.connection.create_table(:pages) do |t|
    t.string :name, :default => "My name"
  end
  ActiveRecord::Base.connection.create_table(:dynamic_attributes) do |t|
    t.string :name, :null => false
    t.string :attr_key, :null => false
    t.string :object_type, :null => false
    t.string :attributable_type, :null => false
    t.integer :attributable_id, :null => false
    %w(integer string boolean text float).each do |type|
      t.send(type, "#{type}_value".to_sym)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
datts_right-0.0.12 spec/spec_helper.rb
datts_right-0.0.11 spec/spec_helper.rb
datts_right-0.0.10 spec/spec_helper.rb
datts_right-0.0.9 spec/spec_helper.rb
datts_right-0.0.8 spec/spec_helper.rb