Sha256: ee716e3d7fe8c4351966240cc7bf4951b3bcaf241b438eec41e8e7cf16d4f672

Contents?: true

Size: 1.73 KB

Versions: 2

Compression:

Stored size: 1.73 KB

Contents

require_relative 'methods/required_files'
#====================================
# INTERACTION STEPS
#====================================
# Step used to execute a SQL script on a specific schema
And /^I run sql script "([^\"]*)" on "([^\"]*)" schema$/ do |script, schema|
  begin
    sql = "#{script}"
    DatabaseMethods.execute_select(schema, sql)
    DatabaseMethods.close_connection(schema)
  ensure
  end
end
# Step used to execute SQL script from SQL file on specific schema
Given /^I run sql script from file "([^\"]*)" on "([^\"]*)" schema$/ do |sql_script, schema|
  if sql_script != nil and sql_script != ""
    begin
      File.readlines($sql_dir + sql_script).each do |line|
        if line.nil? || line =~ /^\s*\n*--/
          # puts "\nSQL: " + line;
          next;
        end
        line = line.strip();
        line = line[0..-2];
        #puts "\nSQL: " + line;
        DatabaseMethods.execute_select(schema, line)
        sleep(1);
      end
      DatabaseMethods.close_connection(schema)
    end
  end
end

# Step used to check if data exists in database or not with condition in file
Then /^I should ( not)? see data in schema "(.*)" database with SQL query in file "(.*)"$/ do |negative, schema, file|
  sql = File.read($sql_dir + file)
  filepath = ($sql_dir + file)
  if File.exist?(filepath)
    begin
      rs = DatabaseMethods.execute_select(schema, sql)
      obj_array = Array.new
      rs.each { |row|
        row.each_pair { |col, value|
          assert(false) if negative.nil? && value == 0 || !negative.nil? && value == 1
        }
      }
    ensure
      DatabaseMethods.close_connection(schema)
    end
  else
    raise "*** ERROR: Please check #{filepath} exists."
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
Ifd_Mobile-1.0.0 lib/Ifd_Mobile/methods/lib_schema_data_steps.rb
Ifd_Mobile-0.1.8 lib/Ifd_Mobile/methods/lib_schema_data_steps.rb