Test AR 4.2 locally, without dropping support for 4.0
See notes in boot.rb about `enum`
This commit is contained in:
parent
b05964a466
commit
34ab41d39b
|
@ -28,43 +28,73 @@ Testing is a little awkward because the test suite:
|
||||||
1. Contains a "dummy" rails app with three databases (test, foo, and bar)
|
1. Contains a "dummy" rails app with three databases (test, foo, and bar)
|
||||||
1. Supports three different RDBMS': sqlite, mysql, and postgres
|
1. Supports three different RDBMS': sqlite, mysql, and postgres
|
||||||
|
|
||||||
### Run tests with sqlite
|
### Test sqlite, AR 4.2
|
||||||
|
|
||||||
```
|
```
|
||||||
# Create the appropriate database config. file
|
# Create the appropriate database config. file
|
||||||
rm test/dummy/config/database.yml
|
rm test/dummy/config/database.yml
|
||||||
DB=sqlite bundle exec rake prepare
|
DB=sqlite bundle exec rake prepare
|
||||||
|
|
||||||
# If this is the first test run ever, create databases
|
# If this is the first test run ever, create databases.
|
||||||
|
# We can't use `appraisal` inside the test dummy, so we must set `BUNDLE_GEMFILE`.
|
||||||
|
# See test/dummy/config/boot.rb for a complete explanation.
|
||||||
cd test/dummy
|
cd test/dummy
|
||||||
|
export BUNDLE_GEMFILE=../../gemfiles/ar_4.2.gemfile
|
||||||
RAILS_ENV=test bundle exec rake db:setup
|
RAILS_ENV=test bundle exec rake db:setup
|
||||||
RAILS_ENV=foo bundle exec rake db:setup
|
RAILS_ENV=foo bundle exec rake db:setup
|
||||||
RAILS_ENV=bar bundle exec rake db:setup
|
RAILS_ENV=bar bundle exec rake db:setup
|
||||||
|
unset BUNDLE_GEMFILE
|
||||||
|
cd ../..
|
||||||
|
|
||||||
|
# Run tests
|
||||||
|
DB=sqlite bundle exec appraisal ar-4.2 rake
|
||||||
|
```
|
||||||
|
|
||||||
|
### Test sqlite, AR 5
|
||||||
|
|
||||||
|
```
|
||||||
|
# Create the appropriate database config. file
|
||||||
|
rm test/dummy/config/database.yml
|
||||||
|
DB=sqlite bundle exec rake prepare
|
||||||
|
|
||||||
|
# If this is the first test run ever, create databases.
|
||||||
|
# We can't use `appraisal` inside the test dummy, so we must set `BUNDLE_GEMFILE`.
|
||||||
|
# See test/dummy/config/boot.rb for a complete explanation.
|
||||||
|
cd test/dummy
|
||||||
|
export BUNDLE_GEMFILE=../../gemfiles/ar_5.0.gemfile
|
||||||
|
RAILS_ENV=test bundle exec rake db:environment:set db:setup
|
||||||
|
RAILS_ENV=foo bundle exec rake db:environment:set db:setup
|
||||||
|
RAILS_ENV=bar bundle exec rake db:environment:set db:setup
|
||||||
|
unset BUNDLE_GEMFILE
|
||||||
cd ../..
|
cd ../..
|
||||||
|
|
||||||
# Run tests
|
# Run tests
|
||||||
DB=sqlite bundle exec appraisal ar-5.0 rake
|
DB=sqlite bundle exec appraisal ar-5.0 rake
|
||||||
```
|
```
|
||||||
|
|
||||||
### Run tests with mysql
|
### Test mysql, AR 5
|
||||||
|
|
||||||
```
|
```
|
||||||
# Create the appropriate database config. file
|
# Create the appropriate database config. file
|
||||||
rm test/dummy/config/database.yml
|
rm test/dummy/config/database.yml
|
||||||
DB=mysql bundle exec rake prepare
|
DB=mysql bundle exec rake prepare
|
||||||
|
|
||||||
# If this is the first test run ever, create databases
|
# If this is the first test run ever, create databases.
|
||||||
|
# We can't use `appraisal` inside the test dummy, so we must set `BUNDLE_GEMFILE`.
|
||||||
|
# See test/dummy/config/boot.rb for a complete explanation.
|
||||||
cd test/dummy
|
cd test/dummy
|
||||||
RAILS_ENV=test bundle exec rake db:setup
|
export BUNDLE_GEMFILE=../../gemfiles/ar_5.0.gemfile
|
||||||
RAILS_ENV=foo bundle exec rake db:setup
|
RAILS_ENV=test bundle exec rake db:environment:set db:setup
|
||||||
RAILS_ENV=bar bundle exec rake db:setup
|
RAILS_ENV=foo bundle exec rake db:environment:set db:setup
|
||||||
|
RAILS_ENV=bar bundle exec rake db:environment:set db:setup
|
||||||
|
unset BUNDLE_GEMFILE
|
||||||
cd ../..
|
cd ../..
|
||||||
|
|
||||||
# Run tests
|
# Run tests
|
||||||
DB=mysql bundle exec appraisal ar-5.0 rake
|
DB=mysql bundle exec appraisal ar-5.0 rake
|
||||||
```
|
```
|
||||||
|
|
||||||
### Run tests with postgres
|
### Test postgres, AR 5
|
||||||
|
|
||||||
```
|
```
|
||||||
# Create the appropriate database config. file
|
# Create the appropriate database config. file
|
||||||
|
@ -73,10 +103,14 @@ DB=postgres bundle exec rake prepare
|
||||||
|
|
||||||
# If this is the first test run ever, create databases.
|
# If this is the first test run ever, create databases.
|
||||||
# Unlike mysql, use create/migrate instead of setup.
|
# Unlike mysql, use create/migrate instead of setup.
|
||||||
|
# We can't use `appraisal` inside the test dummy, so we must set `BUNDLE_GEMFILE`.
|
||||||
|
# See test/dummy/config/boot.rb for a complete explanation.
|
||||||
cd test/dummy
|
cd test/dummy
|
||||||
|
export BUNDLE_GEMFILE=../../gemfiles/ar_5.0.gemfile
|
||||||
DB=postgres RAILS_ENV=test bundle exec rake db:drop db:create db:migrate
|
DB=postgres RAILS_ENV=test bundle exec rake db:drop db:create db:migrate
|
||||||
DB=postgres RAILS_ENV=foo bundle exec rake db:drop db:create db:migrate
|
DB=postgres RAILS_ENV=foo bundle exec rake db:drop db:create db:migrate
|
||||||
DB=postgres RAILS_ENV=bar bundle exec rake db:drop db:create db:migrate
|
DB=postgres RAILS_ENV=bar bundle exec rake db:drop db:create db:migrate
|
||||||
|
unset BUNDLE_GEMFILE
|
||||||
cd ../..
|
cd ../..
|
||||||
|
|
||||||
# Run tests
|
# Run tests
|
||||||
|
|
|
@ -1,10 +1,23 @@
|
||||||
require "rubygems"
|
require "rubygems"
|
||||||
gemfile = File.expand_path("../../../../Gemfile", __FILE__)
|
|
||||||
|
|
||||||
if File.exist?(gemfile)
|
# Set ENV['BUNDLE_GEMFILE'] as follows:
|
||||||
|
#
|
||||||
|
# Our test dummy app uses `enum`, so it must use AR >= 4.1. However, we want our
|
||||||
|
# gemspec to support AR >= 4.0. For local test runs, using our root Gemfile
|
||||||
|
# would be problematic here. For TravisCI it seems to be fine. Maybe Travis
|
||||||
|
# overwrites the root Gemfile?
|
||||||
|
if ENV.key?("BUNDLE_GEMFILE")
|
||||||
|
# This is a local test run, and we are running rake tasks in this dummy app,
|
||||||
|
# and we can't use the project's root Gemfile for the reasons given above.
|
||||||
|
puts "Booting PT test dummy app: Using BUNDLE_GEMFILE: #{ENV.fetch('BUNDLE_GEMFILE')}"
|
||||||
|
else
|
||||||
|
gemfile = File.expand_path("../../../../Gemfile", __FILE__)
|
||||||
|
if File.exist?(gemfile)
|
||||||
|
puts "Booting PT test dummy app: Using gemfile: #{gemfile}"
|
||||||
ENV["BUNDLE_GEMFILE"] = gemfile
|
ENV["BUNDLE_GEMFILE"] = gemfile
|
||||||
require "bundler"
|
end
|
||||||
Bundler.setup
|
|
||||||
end
|
end
|
||||||
|
require "bundler"
|
||||||
|
Bundler.setup
|
||||||
|
|
||||||
$LOAD_PATH.unshift File.expand_path("../../../../lib", __FILE__)
|
$LOAD_PATH.unshift(File.expand_path("../../../../lib", __FILE__))
|
||||||
|
|
Loading…
Reference in New Issue