Sha256: 3ea038bc657488b6a6cc8c0a166ce5c86e2a3aa1e2582f028b18ffdadad319eb

Contents?: true

Size: 1.24 KB

Versions: 3

Compression:

Stored size: 1.24 KB

Contents

dir = File.dirname(__FILE__)
$LOAD_PATH.unshift "#{dir}/../lib"

require 'rubygems'
require 'spec'
require 'pp'
require 'fileutils'
require 'arel'

[:matchers, :doubles].each do |helper|
  Dir["#{dir}/#{helper}/*"].each { |m| require "#{dir}/#{helper}/#{File.basename(m)}" }
end

module AdapterGuards
  def adapter_is(name)
    verify_adapter_name(name)
    yield if name.to_s == adapter_name
  end

  def adapter_is_not(name)
    verify_adapter_name(name)
    yield if name.to_s != adapter_name
  end

  def adapter_name
    name = ActiveRecord::Base.configurations["unit"][:adapter]
    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]
  end
end

module Check
  # This is used to eliminate Ruby warnings on some RSpec assertion lines
  # See: https://rspec.lighthouseapp.com/projects/5645/tickets/504
  def check(*args)
  end
end

Spec::Runner.configure do |config|
  config.include BeLikeMatcher, HashTheSameAsMatcher, DisambiguateAttributesMatcher
  config.include AdapterGuards
  config.include Check

  config.before do
    Arel::Table.engine = Arel::Sql::Engine.new(ActiveRecord::Base)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
arel-0.2.1 spec/spec_helper.rb
arel-0.2.0 spec/spec_helper.rb
arel-0.2.pre spec/spec_helper.rb