PL/SQL unit testing with Jruby

In order to find out how to do unit testing of PL/SQL code, I found this great blog post by Raimonds Simanovskis. He created two Ruby gems, ruby-plsql and ruby-plsql-spec. Following instructions on github for plsql-spec gem, I installed gems, but for jruby platform.
There are other alternatives for doing unit testing of pl/sql code (Python is one of those and I have been using Python for years), but I decided to try Jruby implementation for three reasons:

After creating plsql-spec project by initiating command

>plsql-spec init

I tried following example:

require "spec_helper"
describe "test installation" do
  it "should get SYSDATE" do
    plsql.sysdate.should_not == NULL

In database.yml I used connection to Oracle database in my company.
I got following error:

Failing tests! 

and nothing more!
In order to investigate what is the problem, I directly run spec_helper.rb using jruby. After that invocation I received java exception:

java.sql.SQLDataException:  ORA-01882: timezone region not found

The solution was to enter following lines in (that ruby script is generated by plsql-spec init)

ENV['TZ'] = 'Europe/Zagreb'

after all require statements.

You should put your own time zone.

Labels: , ,