Sha256: 7b2f60295921b27e167c344154aaf6d9caf5f0054ccf021d40fcda2f9049f6e0

Contents?: true

Size: 1.01 KB

Versions: 7

Compression:

Stored size: 1.01 KB

Contents

require 'spec_helper'

RSpec.describe Reel::Response do
  it "streams enumerables" do
    with_socket_pair do |client, peer|
      connection = Reel::Connection.new(peer)
      client << ExampleRequest.new.to_s
      request = connection.request

      connection.respond Reel::Response.new(:ok, ["Hello", "World"])
      connection.close

      response = client.read(4096)
      crlf = Reel::Response::Writer::CRLF
      fixture = "5#{crlf}Hello#{crlf}5#{crlf}World#{crlf}0#{crlf*2}"
      expect(response[(response.length - fixture.length)..-1]).to eq fixture
    end
  end

  it "canonicalizes response headers" do
    with_socket_pair do |client, peer|
      connection = Reel::Connection.new(peer)
      client << ExampleRequest.new.to_s
      request = connection.request

      connection.respond Reel::Response.new(:ok, {"content-type" => "application/json"}, "['mmmkay']")
      connection.close

      response = client.read(4096)
      expect(response["Content-Type: application/json"]).to_not be_nil
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

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