Sha256: 48c7bcbcfdb02d07902fc2539afce1edb8c8a46dfeea23a304f66bf683a23ea5

Contents?: true

Size: 926 Bytes

Versions: 16

Compression:

Stored size: 926 Bytes

Contents

require "spec_helper"

RSpec.describe "IO.pipe" do
  let(:pair) { IO.pipe }

  let :unreadable_subject do
    pair.first
  end
  let :readable_subject do
    pipe, peer = pair
    peer << "data"
    pipe
  end

  let :writable_subject do
    pair.last
  end
  let :unwritable_subject do
    reader, pipe = IO.pipe

    # HACK: On OS X 10.8, this str must be larger than PIPE_BUF. Otherwise,
    #      the write is atomic and select() will return writable but write()
    #      will throw EAGAIN if there is too little space to write the string
    # TODO: Use FFI to lookup the platform-specific size of PIPE_BUF
    str = "JUNK IN THE TUBES" * 10_000
    begin
      pipe.write_nonblock str
      _, writers = select [], [pipe], [], 0
    rescue Errno::EPIPE
      break
    end while writers && writers.include?(pipe)

    pipe
  end

  it_behaves_like "an NIO selectable"
  it_behaves_like "an NIO selectable stream"
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/selectables/pipe_spec.rb
autocompl-0.2.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/nio4r-1.2.1/spec/nio/selectables/pipe_spec.rb
autocompl-0.2.0 test/dummy/vendor/bundle/ruby/2.3.0/gems/nio4r-1.2.1/spec/nio/selectables/pipe_spec.rb
autocompl-0.1.2 test/dummy/vendor/bundle/ruby/2.3.0/gems/nio4r-1.2.1/spec/nio/selectables/pipe_spec.rb
autocompl-0.1.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/nio4r-1.2.1/spec/nio/selectables/pipe_spec.rb
autocompl-0.1.0 test/dummy/vendor/bundle/ruby/2.3.0/gems/nio4r-1.2.1/spec/nio/selectables/pipe_spec.rb
autocompl-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/nio4r-1.2.1/spec/nio/selectables/pipe_spec.rb
abaci-0.3.0 vendor/bundle/gems/nio4r-1.2.1/spec/nio/selectables/pipe_spec.rb
nio4r-2.0.0.pre-java spec/nio/selectables/pipe_spec.rb
nio4r-2.0.0.pre spec/nio/selectables/pipe_spec.rb
nio4r-1.2.1-java spec/nio/selectables/pipe_spec.rb
nio4r-1.2.1 spec/nio/selectables/pipe_spec.rb
nio4r-1.2.0-java spec/nio/selectables/pipe_spec.rb
nio4r-1.2.0 spec/nio/selectables/pipe_spec.rb
nio4r-1.1.1-java spec/nio/selectables/pipe_spec.rb
nio4r-1.1.1 spec/nio/selectables/pipe_spec.rb