Sha256: faf2a6efa4908ed90b1339e0b24e7ced3413cae290e31f3766d05da6a600fa42

Contents?: true

Size: 826 Bytes

Versions: 16

Compression:

Stored size: 826 Bytes

Contents

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(:tcp_port) { 23_456 }

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

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

    it_behaves_like "an NIO acceptable"
  end
end

Version data entries

16 entries across 16 versions & 3 rubygems

Version Path
autocompl-0.2.2 test/dummy/vendor/bundle/ruby/2.3.0/gems/nio4r-1.2.1/spec/nio/acceptables_spec.rb
autocompl-0.2.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/nio4r-1.2.1/spec/nio/acceptables_spec.rb
autocompl-0.2.0 test/dummy/vendor/bundle/ruby/2.3.0/gems/nio4r-1.2.1/spec/nio/acceptables_spec.rb
autocompl-0.1.2 test/dummy/vendor/bundle/ruby/2.3.0/gems/nio4r-1.2.1/spec/nio/acceptables_spec.rb
autocompl-0.1.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/nio4r-1.2.1/spec/nio/acceptables_spec.rb
autocompl-0.1.0 test/dummy/vendor/bundle/ruby/2.3.0/gems/nio4r-1.2.1/spec/nio/acceptables_spec.rb
autocompl-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/nio4r-1.2.1/spec/nio/acceptables_spec.rb
abaci-0.3.0 vendor/bundle/gems/nio4r-1.2.1/spec/nio/acceptables_spec.rb
nio4r-2.0.0.pre-java spec/nio/acceptables_spec.rb
nio4r-2.0.0.pre spec/nio/acceptables_spec.rb
nio4r-1.2.1-java spec/nio/acceptables_spec.rb
nio4r-1.2.1 spec/nio/acceptables_spec.rb
nio4r-1.2.0-java spec/nio/acceptables_spec.rb
nio4r-1.2.0 spec/nio/acceptables_spec.rb
nio4r-1.1.1-java spec/nio/acceptables_spec.rb
nio4r-1.1.1 spec/nio/acceptables_spec.rb