diff options
Diffstat (limited to 'spec/support')
-rw-r--r-- | spec/support/guards.rb | 28 | ||||
-rw-r--r-- | spec/support/model.rb | 67 | ||||
-rw-r--r-- | spec/support/schemas/mysql_schema.rb | 26 | ||||
-rw-r--r-- | spec/support/schemas/oracle_schema.rb | 20 | ||||
-rw-r--r-- | spec/support/schemas/postgresql_schema.rb | 26 | ||||
-rw-r--r-- | spec/support/schemas/sqlite3_schema.rb | 26 |
6 files changed, 0 insertions, 193 deletions
diff --git a/spec/support/guards.rb b/spec/support/guards.rb deleted file mode 100644 index db6075f73a..0000000000 --- a/spec/support/guards.rb +++ /dev/null @@ -1,28 +0,0 @@ -module AdapterGuards - def adapter_is(*names) - names = names.map(&:to_s) - names.each{|name| verify_adapter_name(name)} - yield if names.include? adapter_name - end - - def adapter_is_not(*names) - names = names.map(&:to_s) - names.each{|name| verify_adapter_name(name)} - yield unless names.include? adapter_name - end - - def adapter_name - name = ActiveRecord::Base.configurations["unit"][:adapter] - name = 'oracle' if name == 'oracle_enhanced' - verify_adapter_name(name) - name - end - - def verify_adapter_name(name) - raise "Invalid adapter name: #{name}" unless valid_adapters.include?(name.to_s) - end - - def valid_adapters - %w[mysql postgresql sqlite3 oracle] - end -end diff --git a/spec/support/model.rb b/spec/support/model.rb deleted file mode 100644 index 45fe254d6f..0000000000 --- a/spec/support/model.rb +++ /dev/null @@ -1,67 +0,0 @@ -module Arel - module Testing - class Engine < Arel::Memory::Engine - attr_reader :rows - - def initialize - @rows = [] - end - - def supports(operation) - false - end - - def read(relation) - case relation - when Arel::Take, Arel::Order, Arel::Skip, Arel::Where - relation.eval - else - @rows.dup.map { |r| Row.new(relation, r) } - end - end - - def create(insert) - @rows << insert.record.tuple - insert - end - end - end - - class Model - include Relation - - attr_reader :engine - - def self.build - relation = new - yield relation - relation - end - - def initialize - @attributes = [] - end - - def engine(engine = nil) - @engine = engine if engine - @engine - end - - def attribute(name, type) - @attributes << type.new(self, name) - end - - def attributes - Header.new(@attributes) - end - - def format(attribute, value) - value - end - - def insert(row) - insert = super Arel::Row.new(self, row) - insert.record - end - end -end diff --git a/spec/support/schemas/mysql_schema.rb b/spec/support/schemas/mysql_schema.rb deleted file mode 100644 index a2e913d756..0000000000 --- a/spec/support/schemas/mysql_schema.rb +++ /dev/null @@ -1,26 +0,0 @@ -sql = <<-SQL - DROP TABLE IF EXISTS users; - CREATE TABLE users ( - id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, - name VARCHAR(255) NOT NULL - ); - - DROP TABLE IF EXISTS photos; - CREATE TABLE photos ( - id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, - user_id INTEGER NOT NULL, - camera_id INTEGER NOT NULL - ); - DROP TABLE IF EXISTS developers; - CREATE TABLE developers ( - id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, - name VARCHAR(255) NOT NULL, - salary INTEGER NOT NULL, - department VARCHAR(255) NOT NULL, - created_at TIMESTAMP NOT NULL - ); -SQL - -sql.split(/;/).select(&:present?).each do |sql_statement| - ActiveRecord::Base.connection.execute sql_statement -end diff --git a/spec/support/schemas/oracle_schema.rb b/spec/support/schemas/oracle_schema.rb deleted file mode 100644 index c8207c8d98..0000000000 --- a/spec/support/schemas/oracle_schema.rb +++ /dev/null @@ -1,20 +0,0 @@ -ActiveRecord::Schema.define do - suppress_messages do - create_table :users, :primary_key_trigger => true, :force => true do |t| - t.string :name, :limit => 255, :null => false - end - - create_table :photos, :primary_key_trigger => true, :force => true do |t| - t.integer :user_id - t.integer :camera_id - end - - create_table :developers, :primary_key_trigger => true, :force => true do |t| - t.string :name, :limit => 255, :null => false - t.integer :salary - t.string :department, :limit => 255, :null => false - t.timestamp :created_at, :null => false - end - - end -end diff --git a/spec/support/schemas/postgresql_schema.rb b/spec/support/schemas/postgresql_schema.rb deleted file mode 100644 index 23a48f5ad8..0000000000 --- a/spec/support/schemas/postgresql_schema.rb +++ /dev/null @@ -1,26 +0,0 @@ -sql = <<-SQL - DROP TABLE IF EXISTS users; - CREATE TABLE users ( - id SERIAL PRIMARY KEY NOT NULL, - name VARCHAR(255) NOT NULL - ); - - DROP TABLE IF EXISTS photos; - CREATE TABLE photos ( - id SERIAL PRIMARY KEY NOT NULL, - user_id INTEGER NOT NULL, - camera_id INTEGER NOT NULL - ); - DROP TABLE IF EXISTS developers; - CREATE TABLE developers ( - id SERIAL PRIMARY KEY NOT NULL, - name VARCHAR(255) NOT NULL, - salary INTEGER NOT NULL, - department VARCHAR(255) NOT NULL, - created_at TIMESTAMP NOT NULL - ); -SQL - -sql.split(/;/).select(&:present?).each do |sql_statement| - ActiveRecord::Base.connection.execute sql_statement -end diff --git a/spec/support/schemas/sqlite3_schema.rb b/spec/support/schemas/sqlite3_schema.rb deleted file mode 100644 index c1fed70859..0000000000 --- a/spec/support/schemas/sqlite3_schema.rb +++ /dev/null @@ -1,26 +0,0 @@ -sql = <<-SQL - DROP TABLE IF EXISTS users; - CREATE TABLE users ( - id INTEGER NOT NULL PRIMARY KEY, - name VARCHAR(255) NOT NULL - ); - - DROP TABLE IF EXISTS photos; - CREATE TABLE photos ( - id INTEGER NOT NULL PRIMARY KEY, - user_id INTEGER NOT NULL, - camera_id INTEGER NOT NULL - ); - DROP TABLE IF EXISTS developers; - CREATE TABLE developers ( - id INTEGER NOT NULL PRIMARY KEY, - name VARCHAR(255) NOT NULL, - salary INTEGER NOT NULL, - department VARCHAR(255) NOT NULL, - created_at TIMESTAMP NOT NULL - ); -SQL - -sql.split(/;/).select(&:present?).each do |sql_statement| - ActiveRecord::Base.connection.execute sql_statement -end |