aboutsummaryrefslogtreecommitdiffstats
path: root/spec/spec_helper.rb
blob: 01a703a7d4d8460eeef9c795d656b57cc0f1c45e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
require 'rubygems'
require 'spec'
require 'pp'
dir = File.dirname(__FILE__)
$LOAD_PATH.unshift "#{dir}/../lib"
Dir["#{dir}/matchers/*"].each { |m| require "#{dir}/matchers/#{File.basename(m)}" }
require 'active_relation'

ActiveRecord::Base.configurations = {
  'test' => {
    :adapter  => 'mysql',
    :username => 'root',
    :password => 'password',
    :encoding => 'utf8',
    :database => 'sql_algebra_test',
  },
}
ActiveRecord::Base.establish_connection 'test'

class Hash
  def shift
    returning to_a.sort { |(key1, value1), (key2, value2)| key1.hash <=> key2.hash }.shift do |key, value|
      delete(key)
    end
  end
end

Spec::Runner.configure do |config|  
  config.include(BeLikeMatcher, HashTheSameAsMatcher)
  config.mock_with :rr
  config.before do
    ActiveRelation::Table.engine = ActiveRelation::Engine.new(ActiveRecord::Base)
  end
end