Sha256: 9257b59828dd2f04c486e192eac3ea8aae4074f3575867441b54b10b3d77dee2

Contents?: true

Size: 1.27 KB

Versions: 1

Compression:

Stored size: 1.27 KB

Contents

# This file is part of ruby-flores.
# Copyright (C) 2015 Jordan Sissel
# 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
# 
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
# encoding: utf-8
require "randomized"
require "socket"
require "rspec/stress_it"

RSpec.configure do |c|
  c.extend RSpec::StressIt
end

describe TCPServer do
  subject(:socket) { Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0) }
  let(:sockaddr) { Socket.sockaddr_in(port, "127.0.0.1") }
  after { socket.close }

  context "on a random port" do
    let(:port) { Randomized.integer(-100_000..100_000) }
    analyze_it "should bind successfully", [:port] do
      socket.bind(sockaddr)
      expect(socket.local_address.ip_port).to(be == port)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
flores-0.0.2 examples/socket_analyze_spec.rb