Sha256: 7a0cced0d74dcfebc4c4782c2e299381b50465cc5108447d55fadda9ff09759e
Contents?: true
Size: 1.56 KB
Versions: 5
Compression:
Stored size: 1.56 KB
Contents
# frozen_string_literal: true require_relative 'helper' require 'fileutils' class SocketTest < MiniTest::Test def setup super end def test_tcp port = rand(1234..5678) server = TCPServer.new('127.0.0.1', port) server_fiber = spin do while (socket = server.accept) spin do while (data = socket.gets(8192)) socket << data end end end end snooze client = TCPSocket.new('127.0.0.1', port) client.write("1234\n") assert_equal "1234\n", client.recv(8192) client.close ensure server_fiber&.stop server_fiber&.await server&.close end def test_unix_socket path = '/tmp/test_unix_socket' FileUtils.rm(path) rescue nil server = UNIXServer.new(path) server_fiber = spin do server.accept_loop do |socket| spin do while (data = socket.gets(8192)) socket << data end end end end snooze client = UNIXSocket.new(path) client.write("1234\n") assert_equal "1234\n", client.recv(8192) client.close ensure server_fiber&.stop server_fiber&.await server&.close end end class HTTPClientTest < MiniTest::Test require 'json' def test_http res = HTTParty.get('http://ipinfo.io/') response = JSON.load(res.body) assert_equal 'https://ipinfo.io/missingauth', response['readme'] end def test_https res = HTTParty.get('https://ipinfo.io/') response = JSON.load(res.body) assert_equal 'https://ipinfo.io/missingauth', response['readme'] end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
polyphony-0.50.1 | test/test_socket.rb |
polyphony-0.50.0 | test/test_socket.rb |
polyphony-0.49.2 | test/test_socket.rb |
polyphony-0.49.1 | test/test_socket.rb |
polyphony-0.49.0 | test/test_socket.rb |