Sha256: a5d56302a835960c75d3494f43297be7be45c7ef8193b1f39009b9508e3cc166

Contents?: true

Size: 858 Bytes

Versions: 5

Compression:

Stored size: 858 Bytes

Contents

# frozen_string_literal: true

require "spec_helper"

RSpec.describe "NIO acceptables" do
  shared_context "an NIO acceptable" do
    let(:selector) { NIO::Selector.new }

    it "selects for read readiness" do
      waiting_monitor = selector.register(unacceptable_subject, :r)
      ready_monitor   = selector.register(acceptable_subject, :r)

      ready_monitors = selector.select
      expect(ready_monitors).to include ready_monitor
      expect(ready_monitors).not_to include waiting_monitor
    end
  end

  describe TCPServer do
    let(:port) { next_available_tcp_port }

    let :acceptable_subject do
      server = TCPServer.new("localhost", port)
      TCPSocket.open("localhost", port)
      server
    end

    let :unacceptable_subject do
      TCPServer.new("localhost", port + 1)
    end

    it_behaves_like "an NIO acceptable"
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
nio4r-2.1.0-java spec/nio/acceptables_spec.rb
nio4r-2.1.0 spec/nio/acceptables_spec.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/nio4r-2.0.0/spec/nio/acceptables_spec.rb
nio4r-2.0.0-java spec/nio/acceptables_spec.rb
nio4r-2.0.0 spec/nio/acceptables_spec.rb