我有这个应用程序:
require 'sinatra/base'
require 'thin'
class WebService < Sinatra::Base
get '/' do
'hello'
end
end
EM.run do
EventMachine.add_periodic_timer(1) do
puts 'hello'
end
Thin::Server.start(WebService)
end
我需要为此编写一个测试脚本。通常的方法不起作用,因为测试永远不会被执行:
class WebServiceTest < Test::Unit::TestCase
include Rack::Test::Methods
def app
WebService
end
def test
get '/'
assert last_response.ok?
end
end