When you are creating a fix and/or some new features for Oracle enhanced adapter, It is recommended to execute Oracle enhanced adapter unit tests and ActiveRecord unit tests.
- Oracle enhanced adapter unit test
- ActiveRecord unit test
This document explains how to prepare and execute Oracle enhanced adapter unit test. For ActiveRecord unit test, please refer Contributing to Ruby on Rails .
This document talks about developing Oracle enhanced adapter itself, does NOT talk about developing Rails applications using Oracle enhanced adapter.
You can create Oracle enhanced adapter development and test environment by following one of them. If you are first to create this environment rails-dev-box runs_oracle branch is recommended.
- Please follow the README .
- Please follow the README .
You can create your development and test environment by yourself.
Install Ruby 2.2.2 or higher version of Ruby and JRuby 9.0.5 or higher. To switch multiple version of ruby, you can use use ruby-build or Ruby Version Manager(RVM).
To test Oracle enhanced adapter Oracle database is necesssary. You can build by your own or use the Docker to run pre-build Oracle Database Express Edition 11g Release 2.
Oracle database 11.2 or later with SYS and SYSTEM user access. AL32UTF8 database character set is recommended.
If no Oracle database with SYS and SYSTEM user access is available, try the docker approach.
-
Install Docker
-
Pull docker-oracle-xe-11g-r2 image from docker hub
$ docker pull wnameless/oracle-xe-11g-r2
-
Start a Oracle database docker container with mapped ports. Use port
49161
to access the database.$ docker run -d -p 49160:22 -p 49161:1521 wnameless/oracle-xe-11g-r2
-
Check connection to the database with
sqlplus
. The user issystem
, the password isoracle
.$ sqlplus64 system/oracle@localhost:49161
- Create Oracle database schema for test purposes. Review
spec/spec_helper.rb
to see default schema/user names and database names (use environment variables to override defaults)
SQL> CREATE USER oracle_enhanced IDENTIFIED BY oracle_enhanced;
SQL> GRANT unlimited tablespace, create session, create table, create sequence, create procedure, create trigger, create view, create materialized view, create database link, create synonym, create type, ctxapp TO oracle_enhanced;
SQL> CREATE USER oracle_enhanced_schema IDENTIFIED BY oracle_enhanced_schema;
SQL> GRANT unlimited tablespace, create session, create table, create sequence, create procedure, create trigger, create view, create materialized view, create database link, create synonym, create type, ctxapp TO oracle_enhanced_schema;
-
Configure database credentials in one of two ways:
- copy
spec/spec_config.yaml.template
tospec/spec_config.yaml
and modify as needed - set required environment variables (see DATABASE_NAME in spec_helper.rb)
- copy
-
The oracle enhanced configuration file
spec/spec_config.yaml
should look like:# copy this file to spec/config.yaml and set appropriate values # you can also use environment variables, see spec_helper.rb database: name: 'xe' host: 'localhost' port: 49161 user: 'oracle_enhanced' password: 'oracle_enhanced' sys_password: 'oracle' non_default_tablespace: 'SYSTEM' timezone: 'Europe/Riga'
-
Install bundler
$ gem install bundler
-
Execute bundle install to install required gems
$ bundle install
-
Run Oracle enhanced adapter unit tests
$ bundle exec rake spec