Skip to content

Commit 9d8906a

Browse files
committed
[bench] allow testing with any Rails version
1 parent a60ddcc commit 9d8906a

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

bench/setup.rb

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,22 @@
22

33
require 'rubygems' unless defined? Gem
44

5-
gem 'activerecord', ENV['AR_VERSION'] if ENV['AR_VERSION']
5+
if ENV['RAILS'] # Use local clone of Rails
6+
rails_dir = ENV['RAILS']
7+
8+
activerecord_dir = ::File.join(rails_dir, 'activerecord', 'lib')
9+
if !::File.exist?(rails_dir) && !::File.exist?(activerecord_dir)
10+
raise "ENV['RAILS'] set but does not point at a valid rails clone"
11+
end
12+
puts "--- Using AR from #{activerecord_dir}"
13+
14+
$LOAD_PATH << ::File.join(rails_dir, 'activesupport', 'lib')
15+
$LOAD_PATH << ::File.join(rails_dir, 'activemodel', 'lib')
16+
$LOAD_PATH << activerecord_dir
17+
elsif ENV['AR_VERSION']
18+
gem 'activerecord', ENV['AR_VERSION']
19+
end
20+
621
require 'active_record'
722
require 'active_record/version'
823

@@ -12,7 +27,7 @@
1227
require 'arjdbc'
1328
ArJdbc::VERSION
1429
else
15-
$LOAD_PATH << File.expand_path('../lib', File.dirname(__FILE__))
30+
$LOAD_PATH.unshift File.expand_path('../lib', File.dirname(__FILE__))
1631
require 'arjdbc'
1732
"#{ArJdbc::VERSION} #{`git rev-parse HEAD`[0, 8]}"
1833
end

0 commit comments

Comments
 (0)