File: peer.rb

package info (click to toggle)
ruby-protocol-http 0.59.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 864 kB
  • sloc: ruby: 7,612; makefile: 4
file content (20 lines) | stat: -rw-r--r-- 489 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# frozen_string_literal: true

# Released under the MIT License.
# Copyright, 2024-2025, by Samuel Williams.

require "protocol/http/peer"
require "socket"

describe Protocol::HTTP::Peer do
	it "can be created from IO" do
		address = Addrinfo.tcp("192.168.1.1", 80)
		io = Socket.new(:AF_INET, :SOCK_STREAM)
		expect(io).to receive(:remote_address).and_return(address)
		
		peer = Protocol::HTTP::Peer.for(io)
		expect(peer).to have_attributes(
			address: be_equal(address),
		)
	end
end