hooks.rb 1.4 KB
Newer Older
Joe Libipl's avatar
Joe Libipl committed
1
require 'tiny_tds'
2
require 'timeout'
3 4 5

Before do |scenario|
  # useful:
6
  # debug_msg "Scenario supports: #{(scenario.methods - Object.methods).inspect}"
7
end
8

9 10 11 12 13 14 15 16 17 18
Before ('@restore_config_file') do
  FileUtils.cp('test_env/test001/DragSpinExp.exe.config',
    'test_env/test001/DragSpinExp.exe.config.bak')
end

After ('@restore_config_file') do
  FileUtils.cp('test_env/test001/DragSpinExp.exe.config.bak',
    'test_env/test001/DragSpinExp.exe.config')
end

19
Before('@reset_server') do |scenario|
20
  # Kill the server if it's already running
21
  result = %x[taskkill /F /T /IM DragSpinExp.exe"]
22
  debug_msg "Result of taskkill: #{result}"
23
  @server_database = "minimal"
24
  # Reset the database
25 26 27
  result = %x[sqlcmd -S "#{ENV['DB_DATASERVER']}" -U "#{ENV['DB_USERNAME']}" \
    -P "#{ENV['DB_PASSWORD']}" -i EntireDB-#{@server_database}.sql \
    -o EntireDB-#{@server_database}.out -v MYDATABASE = "#{@server_database}"]
28
  debug_msg "Result of sqlcmd: #{result}"
29
  set_db_in_config(@server_database)
30
  # Start up the server
Joe Libipl's avatar
Joe Libipl committed
31
  result = start_server()
32
  # Wait for server to come up
33
  client = connect_to_db(@server_database)
34
  log_contains('Starting main game loop.')
35
end
Joe Libipl's avatar
Joe Libipl committed
36

Joe Libipl's avatar
Joe Libipl committed
37
After('@kill_server_after') do |scenario|
38 39
  # Kill the server
  result = %x[taskkill /F /T /IM DragSpinExp.exe"]
40
  debug_msg "Result of taskkill: #{result}"
41 42
end

Joe Libipl's avatar
Joe Libipl committed
43
After('@db_cleanup') do |scenario|
44 45 46
  delete_all_test_accounts()
  delete_all_test_players()
  clear_log()
Joe Libipl's avatar
Joe Libipl committed
47
end