File: base.rb

package info (click to toggle)
ruby-dbd-sqlite3 1.2.5%2Bgem2deb-1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 268 kB
  • sloc: ruby: 1,179; sql: 33; makefile: 2
file content (32 lines) | stat: -rw-r--r-- 983 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
require 'fileutils'

DBDConfig.set_testbase(:sqlite3, Class.new(Test::Unit::TestCase) do
        def dbtype 
            "sqlite3"
        end

        def test_base
            if @dbh # FIXME for some reason, @dbh isn't initialized in some cases. investigate.
                assert_equal(@dbh.driver_name, "SQLite3")
                assert_kind_of(DBI::DBD::SQLite3::Database, @dbh.instance_variable_get(:@handle))
            end
        end

        def set_base_dbh
            config = DBDConfig.get_config['sqlite3']
            @dbh = DBI.connect('dbi:SQLite3:'+config['dbname'], nil, nil, { }) 
        end

        def setup
            set_base_dbh
            DBDConfig.inject_sql(@dbh, dbtype, "dbd/sqlite3/up.sql")
        end

        def teardown
            @sth.finish if(@sth && !@sth.finished?)
            @dbh.disconnect if @dbh.connected?
            config = DBDConfig.get_config['sqlite3']
            FileUtils.rm_f(config['dbname'])
        end
    end
)