Class: Dbtap::Tapper

Inherits:
Object
  • Object
show all
Includes:
Sequelizer
Defined in:
lib/dbtap/tapper.rb

Overview

The Tapper class provides the DSL for Dbtap#define_tests

It also drives the evaluation of all the tests via #run

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTapper

Returns a new instance of Tapper.



11
12
13
14
# File 'lib/dbtap/tapper.rb', line 11

def initialize
  @tests = []
  db.extension :error_sql
end

Instance Attribute Details

#testsObject (readonly)

Returns the value of attribute tests.



10
11
12
# File 'lib/dbtap/tapper.rb', line 10

def tests
  @tests
end

Instance Method Details

#runObject

Drives the evaluation of each test, emitting TAP-compliant messages for each test



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/dbtap/tapper.rb', line 18

def run
  puts (1..tests.length).to_s
  tests.each_with_index do |test, i|
    begin
      if test.is_ok?
        ok(test, i)
      else
        not_ok(test, i)
      end
    rescue Sequel::DatabaseError
      puts $!.sql
      raise $!
    end
  end
end