Sha256: 507109882424404cf427acee4aa0cae406272c2698663cc217af61a1d1e481f1

Contents?: true

Size: 1.33 KB

Versions: 5

Compression:

Stored size: 1.33 KB

Contents

require 'rubygems'
require 'active_record'
require File.join File.dirname(__FILE__), '..', 'lib', 'permissive'

module PermissiveSpecHelper
  def self.clear_log
    File.open(PermissiveSpecHelper.log_path, 'w') do |file|
      file.puts ''
    end
  end

  def self.db_up
    ActiveRecord::Base.establish_connection({:adapter => 'sqlite3', :database => ':memory:', :pool => 5, :timeout => 5000})
    silence_stream(STDOUT) do
      ActiveRecord::Schema.define do
        create_table :permissive_users, :force => true do |t|
          t.timestamps
        end
        create_table :permissive_users_with_roles, :force => true do |t|
          t.string :role
          t.timestamps
        end
        create_table :permissive_organizations, :force => true do |t|
          t.timestamps
        end
        create_table :permissive_permissions do |t|
          t.integer :permitted_object_id
          t.string :permitted_object_type, :limit => 32
          t.integer :scoped_object_id
          t.string :scoped_object_type, :limit => 32
          t.integer :mask, :default => 0
        end
      end
    end
  end

  def self.log_path
    @log_path ||= File.join(File.dirname(__FILE__), 'spec.log')
  end
end

# Setup the logging
PermissiveSpecHelper.clear_log
ActiveRecord::Base.logger = Logger.new(PermissiveSpecHelper.log_path)
PermissiveSpecHelper.db_up

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
permissive-0.2.9.alpha spec/spec_helper.rb
permissive-0.2.8.alpha spec/spec_helper.rb
permissive-0.2.7.alpha spec/spec_helper.rb
permissive-0.2.6.alpha spec/spec_helper.rb
permissive-0.2.5.alpha spec/spec_helper.rb