def find_server_pid
pid = nil
- @pidfile = if @websocket
- WEBSOCKET_PID_PATH
- else
- SERVER_PID_PATH
- end
begin
pid = IO.read(@pidfile).to_i
$stderr.puts "API server is running, pid #{pid.inspect}"
@websocket = args.include?("--websockets")
+ @pidfile = if @websocket
+ WEBSOCKET_PID_PATH
+ else
+ SERVER_PID_PATH
+ end
+
# Kill server left over from previous test run
self.kill_server
ENV["NO_COVERAGE_TEST"] = "1"
if @websocket
_system('bundle', 'exec', 'passenger', 'start', '-d', '-p3333',
- '--pid-file', WEBSOCKET_PID_PATH)
+ '--pid-file', @pidfile)
else
make_ssl_cert
_system('bundle', 'exec', 'rake', 'db:test:load')
_system('bundle', 'exec', 'rake', 'db:fixtures:load')
_system('bundle', 'exec', 'passenger', 'start', '-d', '-p3000',
- '--pid-file', SERVER_PID_PATH,
+ '--pid-file', @pidfile,
'--ssl',
'--ssl-certificate', 'self-signed.pem',
'--ssl-certificate-key', 'self-signed.key')
end
end
end
+
+ def run_rake_task(task_name, arg_string)
+ Dir.chdir(ARV_API_SERVER_DIR) do
+ _system('bundle', 'exec', 'rake', "#{task_name}[#{arg_string}]")
+ end
+ end
end
class ActionController::TestCase
end
end
+# If it quacks like a duck, it must be a HTTP request object.
+class RequestDuck
+ def self.host
+ "localhost"
+ end
+
+ def self.port
+ 8080
+ end
+
+ def self.protocol
+ "http"
+ end
+end
+
if ENV["RAILS_ENV"].eql? 'test'
ApiServerForTests.new.run
ApiServerForTests.new.run ["--websockets"]