class TestSquad::Runner

Public Class Methods

new() click to toggle source
# File lib/test_squad/runner.rb, line 11
def initialize
  Rails.configuration.logger = logger
end
run() click to toggle source
# File lib/test_squad/runner.rb, line 7
def self.run
  new.run
end

Public Instance Methods

app_server() click to toggle source
# File lib/test_squad/runner.rb, line 23
def app_server
  Rack::Handler.pick(["puma", "thin", "webrick"])
end
config() click to toggle source
# File lib/test_squad/runner.rb, line 15
def config
  TestSquad.configuration
end
logger() click to toggle source
# File lib/test_squad/runner.rb, line 19
def logger
  @logger ||= Logger.new(StringIO.new)
end
run() click to toggle source
# File lib/test_squad/runner.rb, line 27
def run
  run_server
  run_tests
end
run_server() click to toggle source
# File lib/test_squad/runner.rb, line 32
def run_server
  Thread.new do
    app_server.run Rails.application,
      Port: config.server_port,
      Host: config.server_host,
      Logger: logger,
      AccessLog: [],
      Silent: true
  end
end
run_tests() click to toggle source
# File lib/test_squad/runner.rb, line 47
def run_tests
  system(
    config.phantomjs_bin,
    runner_script,
    config.server_uri,
    config.timeout.to_s
  )

  exit_code = $? ? $?.exitstatus : 0
  exit(exit_code)
end
runner_script() click to toggle source
# File lib/test_squad/runner.rb, line 43
def runner_script
  File.expand_path("../../../phantomjs/runner.js", __FILE__)
end