Sha256: 1ad1fa19b65efc5c39ae51c55f10d63e38ddc93f6a1c3b2640730be35d04a3ab

Contents?: true

Size: 689 Bytes

Versions: 7

Compression:

Stored size: 689 Bytes

Contents

require 'spec_helper'

RSpec.describe Reel::Response::Writer do
  let(:fixture_path) { File.expand_path("../../../fixtures/example.txt", __FILE__) }
  let(:expected_response) { "HTTP/1.1 200 OK\r\nContent-Length: 56\r\n\r\n#{File.read(fixture_path)}" }

  it "streams static files" do
    with_socket_pair do |socket, peer|
      writer = described_class.new(socket)

      File.open(fixture_path, 'r') do |file|
        response = Reel::Response.new(:ok, {}, file)
        writer.handle_response(response)
      end

      buf = ""
      begin
        buf << peer.read(95)
      rescue IOError
        # End of body!
      end

      expect(buf).to eq expected_response
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
reel-0.6.1 spec/reel/response/writer_spec.rb
reel-0.6.0 spec/reel/response/writer_spec.rb
reel-0.6.0.pre5 spec/reel/response/writer_spec.rb
reel-0.6.0.pre4 spec/reel/response/writer_spec.rb
reel-0.6.0.pre3 spec/reel/response/writer_spec.rb
reel-0.6.0.pre2 spec/reel/response/writer_spec.rb
reel-0.6.0.pre1 spec/reel/response/writer_spec.rb