Sha256: bc5e278c00e5bd6de33ebba60c3b747c3e2f80f612ab3e7e9862c26f6642b3de

Contents?: true

Size: 1.05 KB

Versions: 3

Compression:

Stored size: 1.05 KB

Contents

require 'spec_helper'
require 'net/http'

unless RUBY_PLATFORM == 'java'

  RSpec.describe Reel::Server::UNIX do
    let(:endpoint) { URI(example_url) }
    let(:response_body) { "ohai thar" }

    it 'allows connections over UNIX sockets' do
      ex = nil

      handler = proc do |connection|
        begin
          request = connection.request
          expect( request.method ).to eq 'GET'
          connection.respond :ok, self.response_body
        end
      end

      Dir::Tmpname.create('reel-sock') do |path|
        begin
          server  = Reel::Server::UNIX.new(path, &handler)
          sock    = Net::BufferedIO.new Celluloid::IO::UNIXSocket.new(path)
          request = Net::HTTP::Get.new('/')

          request.exec(sock, '1.1', path)
          response = Net::HTTPResponse.read_new(sock)
          response.reading_body(sock, request.response_body_permitted?) { }

          expect(response.body).to eq(self.response_body)
        ensure
          server.terminate if server && server.alive?
        end
      end

      raise ex if ex
    end
  end
  
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
reel-0.6.0.pre5 spec/reel/unix_server_spec.rb
reel-0.6.0.pre4 spec/reel/unix_server_spec.rb
reel-0.6.0.pre3 spec/reel/unix_server_spec.rb