Class: Berl::Application

Inherits:
Object
  • Object
show all
Defined in:
lib/berl/application.rb

Instance Method Summary collapse

Instance Method Details

#runObject



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
33
34
35
36
# File 'lib/berl/application.rb', line 5

def run
  start = Time.now

  number_of_workers = ENV['BERL_NUM_OF_WORKERS'].to_i ||= 1
  db_conn_str_tpl = ENV['BERL_DB_CONN_STR_TPL'] ||= "mysql://root@localhost:3306/db_%s"
  debug = !!ENV['BERL_DEBUG'] ||= false
  suites_path = ENV['BERL_SUITES_PATH']

  # database_wizard = DatabaseWizard.new(debug)
  # database_wizard.initialize_num_of_databases(number_of_workers, db_conn_str_tpl)

  databases = [
    sprintf(db_conn_str_tpl, 1),
    sprintf(db_conn_str_tpl, 2),
  ]

  puts "[Debug] Resolving suites" if debug

  suites_resolver = SuitesResolver.new(suites_path)
  suites = suites_resolver.resolve_suites

  puts "[Debug] Running Behat" if debug

  behat_runner = BehatRunner.new(number_of_workers, suites, databases, debug)
  behat_runner.start

  behat_runner.print_errors

  puts "Finished in #{Time.now - start} seconds"

  exit 1 if behat_runner.num_of_failed > 0
end