aboutsummaryrefslogblamecommitdiffstats
path: root/actionpack/test/controller/streaming_test.rb
blob: 5a42e2ae6d320a22d957ae502d8ae8ddfe5f5ed7 (plain) (tree)
1
2
3
4
5
6
7
8
9

                             
                       




                                                          
              
















                                                   

     
# frozen_string_literal: true

require "abstract_unit"

module ActionController
  class StreamingResponseTest < ActionController::TestCase
    class TestController < ActionController::Base
      def self.controller_path
        "test"
      end

      def basic_stream
        %w{ hello world }.each do |word|
          response.stream.write word
          response.stream.write "\n"
        end
        response.stream.close
      end
    end

    tests TestController

    def test_write_to_stream
      get :basic_stream
      assert_equal "hello\nworld\n", @response.body
    end
  end
end