PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, December 6, 2022

[FIXED] How to test Ruby OCI8 database services

 December 06, 2022     integration-testing, oci8, ruby, tdd, unit-testing     No comments   

Issue

Are there any tutorials or examples of testing Ruby OCI8 database services?


Solution

See "C:\RubyXXX\lib\ruby\gems\1.9.1\gems\ruby-oci8-2.1.0-x86-mingw32\test\test_oci8.rb" or wherever it is on your drive.

Lots of weblinks i'm not going to include, you can google them yourselve.

A very simple example

require 'oci8'

oci = OCI8.new('schema','password','db.server')
oci.exec('select * from table') do |record|
  puts record.join(',')
end

Some unit testing for active-record and sqlite, you can adapt this for oci8

require 'active_record'
require "test/unit"

ActiveRecord::Base.establish_connection(
    :adapter => "sqlite3",
    :database  => "sample.db"
)
class Album < ActiveRecord::Base;end

class Tester < Test::Unit::TestCase
  def test_title
    assert_equal('Sticky Fingers', Album.find_by_title('Sticky Fingers').title)
  end
end


Answered By - peter
Answer Checked By - Cary Denson (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing