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:
- Ruby language has better readability than Python (there, I said it). Its idioms are much comprehensible than Python language.
- Rspec gem is better than Python unittest module.
- Java jvm is better than Ruby virtual machine implementation
After creating plsql-spec project by initiating command
I tried following example:
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:
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 spec_helper.py (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: jruby, pl-sql, ruby