forked from thoughtbot/paperclip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspec_helper.rb
46 lines (39 loc) · 1.42 KB
/
spec_helper.rb
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
35
36
37
38
39
40
41
42
43
44
45
46
require 'rubygems'
require 'rspec'
require 'active_record'
require 'active_record/version'
require 'active_support'
require 'active_support/core_ext'
require 'mocha/api'
require 'bourne'
require 'ostruct'
require 'pathname'
require 'activerecord-import'
ROOT = Pathname(File.expand_path(File.join(File.dirname(__FILE__), '..')))
puts "Testing against version #{ActiveRecord::VERSION::STRING}"
$LOAD_PATH << File.join(ROOT, 'lib')
$LOAD_PATH << File.join(ROOT, 'lib', 'paperclip')
require File.join(ROOT, 'lib', 'paperclip.rb')
FIXTURES_DIR = File.join(File.dirname(__FILE__), "fixtures")
config = YAML::load(IO.read(File.dirname(__FILE__) + '/database.yml'))
ActiveRecord::Base.logger = Logger.new(File.dirname(__FILE__) + "/debug.log")
ActiveRecord::Base.establish_connection(config['test'])
if ActiveRecord::VERSION::STRING >= "4.2" &&
ActiveRecord::VERSION::STRING < "5.0"
ActiveRecord::Base.raise_in_transactional_callbacks = true
end
Paperclip.options[:logger] = ActiveRecord::Base.logger
Dir[File.join(ROOT, 'spec', 'support', '**', '*.rb')].each{|f| require f }
Rails = FakeRails.new('test', Pathname.new(ROOT).join('tmp'))
ActiveSupport::Deprecation.silenced = true
RSpec.configure do |config|
config.include Assertions
config.include ModelReconstruction
config.include TestData
config.include Reporting
config.extend VersionHelper
config.mock_framework = :mocha
config.before(:all) do
rebuild_model
end
end