class Dbexpect

Public Class Methods

new(output = STDOUT) click to toggle source
# File lib/dbexpect/dbexpect.rb, line 27
def initialize(output = STDOUT)
  @output = ConsoleFormatter.new(output)
end

Public Instance Methods

great_expectations(script, databases) click to toggle source
# File lib/dbexpect/dbexpect.rb, line 37
def great_expectations(script, databases)
  eval_script(script)

  check_table_expectations(databases)

  if validates_expectations?
    @output.notify_passed
    return 0
  else
    @output.notify_failed(failed_expectations)
    return 1
  end
end
run_test(script,databases,command_runner) click to toggle source
# File lib/dbexpect/dbexpect.rb, line 31
def run_test(script,databases,command_runner)
  setup_test(script,databases)
  run_etl(script,command_runner)
  great_expectations(script,databases)
end
setup_test(script,databases) click to toggle source
# File lib/dbexpect/dbexpect.rb, line 51
def setup_test(script,databases)
  eval_script(script)
  @tables.each do |table|
    table.set_up_for_test(databases)
  end
  return 0
end

Protected Instance Methods

check_table_expectations(databases) click to toggle source
# File lib/dbexpect/dbexpect.rb, line 73
def check_table_expectations(databases)
  @expectation_checker = ExpectationChecker.new(databases)
  @expectation_checker.check_expectations(@expectation_tree)
end
eval_script(script) click to toggle source
# File lib/dbexpect/dbexpect.rb, line 65
def eval_script(script)
  parser = DSLParser.new
  parser.parse(File.read(script))
  @tables = parser.tables
  @expectation_tree = parser.expectation_tree
  @commands_to_run = parser.commands
end
failed_expectations() click to toggle source
# File lib/dbexpect/dbexpect.rb, line 78
def failed_expectations
  @expectation_checker.failed_expectations
end
run_etl(script,command_runner) click to toggle source
# File lib/dbexpect/dbexpect.rb, line 61
def run_etl(script,command_runner)
  @commands_to_run.each {|c| command_runner.run(c) }
end
validates_expectations?() click to toggle source
# File lib/dbexpect/dbexpect.rb, line 82
def validates_expectations?
  @expectation_checker.validates_expectations?
end