-
Notifications
You must be signed in to change notification settings - Fork 385
How to execute ActiveRecord JDBC Adapter unit test and Rails ActiveRecord unit test using rails dev box
Yasuo Honda edited this page Nov 10, 2017
·
15 revisions
This document explains how to execute ActiveRecord JDBC Adapter unit test and Rails ActiveRecord unit test using rails-dev-box for those who are interested in ActiveRecord JDBC Adapter Rails 5 support.
Since this document and this rails-dev-box is created for testing purpose only, then please do not apply changes such as changing mysql root password to empty, allowing all IPv4 connection for PostgreSQL to your production systems.
- Install Virtual Box
- Install Vagrant
- Install git
- Clone rails-dev-box
> git clone -b runs_ar_jdbc https://github.com/yahonda/rails-dev-box.git
- Bring up rails-dev-box
> cd rails-dev-box
> vagrant up
- Log in to rails-dev-box via ssh
> vagrant ssh
- Validate which JRuby version is installed
ubuntu@rails-dev-box:~$ ruby -v
jruby 9.1.13.0 (2.3.3) 2017-09-06 8e1c115 OpenJDK 64-Bit Server VM 25.151-b12 on 1.8.0_151-8u151-b12-0ubuntu0.17.04.2-b12 +jit [linux-x86_64]
- Update git config (if necessary)
ubuntu@rails-dev-box:~$ git config --global url."https://".insteadOf git://
- clone ActiveRecord JDBC Adapter
ubuntu@rails-dev-box:~$ git clone https://github.com/jruby/activerecord-jdbc-adapter
ubuntu@rails-dev-box:~$ cd activerecord-jdbc-adapter/
- Execute bundle install to install necessary gems
ubuntu@rails-dev-box:~/activerecord-jdbc-adapter$ bundle install
- Execute test_sqlite3 of ActiveRecord JDBC Adapter
ubuntu@rails-dev-box:~/activerecord-jdbc-adapter$ bundle exec rake test_sqlite3
- Execute test_mysql of ActiveRecord JDBC Adapter
ubuntu@rails-dev-box:~/activerecord-jdbc-adapter$ bundle exec rake test_mysql
- Execute test_postgresql of ActiveRecord JDBC Adapter
ubuntu@rails-dev-box:~/activerecord-jdbc-adapter$ bundle exec rake test_postgresql
- Clone Rails and checkout
5-0-stable
branch to execute Rails ActiveRecord unit test
ubuntu@rails-dev-box:~/activerecord-jdbc-adapter$ cd ~
ubuntu@rails-dev-box:~$ git clone https://github.com/rails/rails
ubuntu@rails-dev-box:~$ cd rails/activerecord
ubuntu@rails-dev-box:~/rails/activerecord$ git checkout 5-0-stable
- Add AR_JDBC environment variable to use ActiveRecord JDBC Adapter
master
branch
ubuntu@rails-dev-box:~/rails/activerecord$ echo 'export AR_JDBC=true' >> ~/.bashrc
ubuntu@rails-dev-box:~/rails/activerecord$ . ~/.bashrc
ubuntu@rails-dev-box:~/rails/activerecord$ echo $AR_JDBC
true
- Bundle
ubuntu@rails-dev-box:~/rails/activerecord$ bundle install
ubuntu@rails-dev-box:~/rails/activerecord$ bundle show |grep jdbc
* activerecord-jdbc-adapter (50.0 dbc8a55)
* activerecord-jdbcmysql-adapter (50.0 dbc8a55)
* activerecord-jdbcpostgresql-adapter (50.0 dbc8a55)
* activerecord-jdbcsqlite3-adapter (50.0 dbc8a55)
* jdbc-mysql (5.1.44 dbc8a55)
* jdbc-postgres (9.4.1212)
* jdbc-sqlite3 (3.8.11.2)
ubuntu@rails-dev-box:~/rails/activerecord$
- Configure RAILS location to point the local file system which has cloned
rails
ubuntu@rails-dev-box:~/rails/activerecord$ cd ~/activerecord-jdbc-adapter
ubuntu@rails-dev-box:~/activerecord-jdbc-adapter$ echo 'export RAILS=$HOME/rails/' >> ~/.bashrc
ubuntu@rails-dev-box:~/activerecord-jdbc-adapter$ . ~/.bashrc
ubuntu@rails-dev-box:~/activerecord-jdbc-adapter$ echo $RAILS
/home/ubuntu/rails/
- Execute Rails ActiveRecord unit test for sqlite3
ubuntu@rails-dev-box:~/activerecord-jdbc-adapter$ cd
ubuntu@rails-dev-box:~$ cd activerecord-jdbc-adapter
ubuntu@rails-dev-box:~/activerecord-jdbc-adapter$ bundle exec rake rails:test:sqlite3
- Execute Rails ActiveRecord unit test for mysql
ubuntu@rails-dev-box:~/activerecord-jdbc-adapter$ bundle exec rake rails:test:mysql
- Execute Rails ActiveRecord unit test postgres
ubuntu@rails-dev-box:~/activerecord-jdbc-adapter$ bundle exec rake rails:test:postgres
Enjoy ActiveRecord JDBC Driver development and testing.