test/unit/daemon_test.rb in nyoibo-0.0.2 vs test/unit/daemon_test.rb in nyoibo-0.0.3

- old
+ new

@@ -1,10 +1,10 @@ require 'test_helper' class Nyoibo::DaemonTest < Test::Unit::TestCase class TestApp < Test::Unit::TestCase include Nyoibo::Callback - uploaded "/" do |json, binary| + after_upload "/" do |json, binary| File.open("/tmp/test.jpg", "w:binary"){|f| f.write(binary) } raise "finame is not 'test.jpg'" if json["filename"] != "test.jpg" raise "Binary size is not '3137' byte" if binary.length != 3137 @@ -29,9 +29,11 @@ @sendsize = 1024 http.stream{|msg| case msg when "OK Ready" http.send("JSON: " + {:filename => File.basename(@file.path), :size => @file.size}.to_json) + when "OK Bye" + http.close_connection when "NEXT" @end = @start + @sendsize @encoded ||= Base64.encode64(@file.read) @end = @encoded.size - 1 if @end >= @encoded.size