github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

rsim / ruby-plsql-spec

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 2
    • 1
  • Source
  • Commits
  • Network (1)
  • Issues (0)
  • Downloads (0)
  • Wiki (1)
  • Graphs
  • Branch: master

click here to add a description

click here to add a homepage

  • Branches (1)
    • master ✓
  • Tags (0)
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

Oracle PL/SQL unit testing with Ruby — Read more

  cancel

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

added connection logoff when exiting 
rsim (author)
Fri Feb 05 07:46:33 -0800 2010
commit  93fe7a5b5069ce532a207a0cb09cc41c7549068f
tree    d410567234abb65c5d1609547f9c01c5a2b2ecab
parent  6be3c91b77adc8f1dadab82111be55c1c1983b5b
ruby-plsql-spec /
name age
history
message
file INSTALL-Windows.markdown Fri Dec 11 05:50:32 -0800 2009 added additional descriptions and links about h... [rsim]
file License.txt Fri Nov 27 07:07:34 -0800 2009 added license file [rsim]
file README.markdown Fri Dec 11 05:50:32 -0800 2009 added additional descriptions and links about h... [rsim]
directory source/ Tue Jan 05 04:10:57 -0800 2010 updates to match latest ruby-plsql version 0.4.1 [rsim]
directory spec/ Fri Feb 05 07:46:33 -0800 2010 added connection logoff when exiting [rsim]
README.markdown

ruby-plsql-spec

PL/SQL unit testing with Ruby

Unit testing of PL/SQL procedures with Ruby libraries:

  • ruby-plsql - Ruby API for calling PL/SQL procedures
  • RSpec - Ruby testing (or behavior driven development) framework

Examples

PL/SQL procedure examples are in source subdirectory, test examples are in spec subdirectory.

  • BETWNSTR - example from utPLSQL project
  • AWARD_BONUS - example from SQL Developer 2.1 tutorial
  • REMOVE_ROOMS_BY_NAME - example from Quest Code Tester for Oracle tutorial

Installing

See Installing on Windows in separate file.

  • Install Ruby 1.8.7 or Ruby 1.9.1
  • Install Oracle client, e.g. Oracle Instant Client
  • Install rspec, ruby-oci8 and ruby-plsql (prefix with sudo if necessary)

    gem install rspec
    gem install ruby-oci8
    gem install ruby-plsql
    

Another alternative is to use JRuby if for example it is necessary also to test Java classes / methods using Ruby.

  • Install JRuby
  • Copy Oracle JDBC driver (e.g. ojdbc14.jar) to JRUBY_HOME/lib directory
  • Install rspec and ruby-plsql (prefix with sudo if necessary)

    jruby -S gem install rspec
    jruby -S gem install ruby-plsql
    

Executing tests

All tests can be run from command line using spec utility.

  • Run all tests in spec directory:

    spec spec
    
  • Run all tests in specified file:

    spec spec/betwnstr_spec.rb
    

Or you can use text editor or IDE which supports running RSpec tests.

How to start?

Read blog post about Oracle PL/SQL unit testing with Ruby.

If you are not familiar with Ruby I recommend to start with Ruby in Twenty Minutes tutorial. Then you can take a look on some RSpec examples how to write and structure tests. And then you can take a look at ruby-plsql own tests to see how to pass parameters and verify results for different PL/SQL data types.

How to add ruby-plsql-spec to a new project?

Create spec directory somewhere in your project directory structure where you will keep your ruby-plsql-spec tests. Copy spec_helper.rb to this directory and modify to your needs:

  • modify database connection settings
  • review other initialization settings (requiring helper files, factory files, source files) and adapt as necessary

Create helpers directory. Review and copy needed helper files to helpers directory from this project.

Create factories directory where to store definitions of test data factory methods (review example from this project).

Start creating tests in files with _spec.rb at the end of file name. If there will be not so many files then you can place them directly in spec directory. If there will be many tests files then create separate directories per module / functionality group and place tests files in subdirectories. You can also create factories and helpers subdirectories per each module / functionality group.

Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server