From 9abb447a573751b87e26ce35f4f05d58290f4c41 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 8 Jul 2010 23:21:18 +0000 Subject: restore Rainbows::HttpResponse.write for Cramp Cramp monkey patches Rainbows internals for WebSockets support and we forgot about it. Add a new integration test to ensure this continues to work in the future (and force us to update the test for newer Cramp). --- t/cramp/rainsocket.ru | 26 ++++++++++++++++++++++++++ t/t0501-cramp-rainsocket.sh | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 t/cramp/rainsocket.ru create mode 100755 t/t0501-cramp-rainsocket.sh (limited to 't') diff --git a/t/cramp/rainsocket.ru b/t/cramp/rainsocket.ru new file mode 100644 index 0000000..0d26f70 --- /dev/null +++ b/t/cramp/rainsocket.ru @@ -0,0 +1,26 @@ +# based on examples/rainsocket.ru git://github.com/lifo/cramp +# Rack::Lint does not like async + EM stuff, so disable it: +#\ -E deployment +require 'cramp/controller' + +Cramp::Controller::Websocket.backend = :rainbows + +class WelcomeController < Cramp::Controller::Websocket + periodic_timer :send_hello_world, :every => 2 + on_data :received_data + + def received_data(data) + if data =~ /fuck/ + render "You cant say fuck in here" + finish + else + render "Got your #{data}" + end + end + + def send_hello_world + render "Hello from the Server!\n" + end +end + +run WelcomeController diff --git a/t/t0501-cramp-rainsocket.sh b/t/t0501-cramp-rainsocket.sh new file mode 100755 index 0000000..6e3aea4 --- /dev/null +++ b/t/t0501-cramp-rainsocket.sh @@ -0,0 +1,38 @@ +#!/bin/sh +. ./test-lib.sh +case $model in +EventMachine) ;; +*) + t_info "skipping $T since it's not compatible with $model" + exit 0 + ;; +esac +require_check cramp Cramp::VERSION + +t_plan 4 "WebSocket monkey patch validity test for Cramp" + +CONFIG_RU=cramp/rainsocket.ru + +t_begin "setup and start" && { + rainbows_setup + rtmpfiles curl_err + + # Like the rest of the EM/async stuff, it's not Rack::Lint compatible + rainbows -E deployment -D $CONFIG_RU -c $unicorn_config + rainbows_wait_start +} + +t_begin "wait for server to say hello to us" && { + ok=$((curl --no-buffer -sS http://$listen/ || :) | \ + awk '/Hello from the Server/ { print "ok"; exit 0 }') + + test x"$ok" = xok +} + +t_begin "termination signal sent" && { + kill $rainbows_pid +} + +t_begin "no errors in stderr" && check_stderr + +t_done -- cgit v1.2.3-24-ge0c7