kubo39 / bossan

high performance asynchronous rack web server
Other
28 stars 5 forks source link

Refactoring tests, add Bossan::Test::TestCase. #13

Closed rnakano closed 11 years ago

rnakano commented 11 years ago

There are some tests in test/ directory, however all tests include same part below:

begin
  $stderr.puts RUBY_DESCRIPTION
  pid = fork do
    trap(:INT) { Bossan.stop }
    Bossan.listen(DEFAULT_HOST, DEFAULT_PORT)
    Bossan.run(App.new)
  end

  Process.detach pid

  unless server_is_wake_up?
    $stderr.puts "bossan won't wake up until you love it ..."
    exit 1
  end

  err = MiniTest::Unit.new.run(ARGV)
  exit false if err && err != 0

ensure
  Process.kill(:INT, pid)
end

This patch refactors tests, it moves that codes to test/bossan_test.rb We can use Bossan::Test::TestCase instead of Test::Unit::TestCase. It automatically starts/stops server each tests.

And, add test endpoint test/driver.rb, so rake test simply kick it.

rnakano commented 11 years ago

Thank you for merge! :beers: