Sha256: 58efcd76c8b2bda7575e87863b28db63bd9f8da183f2529d4af18ee68001dd2c

Contents?: true

Size: 1.08 KB

Versions: 48

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

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 = pair

    # 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
    cntr = 0
    begin
      pipe.write_nonblock str
      cntr += 1
      t = select [], [pipe], [], 0
    rescue Errno::EPIPE
      break
    rescue IO::EWOULDBLOCKWaitWritable
      skip "windows - can't test due to 'select' not showing correct status"
      break
    end while t && t[1].include?(pipe) && cntr < 20

    pipe
  end

  it_behaves_like "an NIO selectable"
  it_behaves_like "an NIO selectable stream"
end

Version data entries

48 entries across 45 versions & 9 rubygems

Version Path
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/nio4r-2.5.8/spec/nio/selectables/pipe_spec.rb
nio4r-2.6.0-java spec/nio/selectables/pipe_spec.rb
nio4r-2.6.0 spec/nio/selectables/pipe_spec.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/nio4r-2.5.8/spec/nio/selectables/pipe_spec.rb
nio4r-2.5.9-java spec/nio/selectables/pipe_spec.rb
nio4r-2.5.9 spec/nio/selectables/pipe_spec.rb
date_n_time_picker_activeadmin-0.1.2 vendor/bundle/ruby/2.6.0/gems/nio4r-2.5.8/spec/nio/selectables/pipe_spec.rb
date_n_time_picker_activeadmin-0.1.1 vendor/bundle/ruby/2.6.0/gems/nio4r-2.5.8/spec/nio/selectables/pipe_spec.rb
rails_mini_profiler-0.2.0 vendor/bundle/ruby/3.0.0/gems/nio4r-2.5.7/spec/nio/selectables/pipe_spec.rb
nio4r-2.5.8-java spec/nio/selectables/pipe_spec.rb
nio4r-2.5.8 spec/nio/selectables/pipe_spec.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/nio4r-2.5.7/spec/nio/selectables/pipe_spec.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/3.0.0/gems/nio4r-2.5.5/spec/nio/selectables/pipe_spec.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/3.0.0/gems/nio4r-2.5.4/spec/nio/selectables/pipe_spec.rb
nio4r-2.5.7-java spec/nio/selectables/pipe_spec.rb
nio4r-2.5.7 spec/nio/selectables/pipe_spec.rb
nio4r-2.5.6-java spec/nio/selectables/pipe_spec.rb
nio4r-2.5.6 spec/nio/selectables/pipe_spec.rb
tdiary-5.1.5 vendor/bundle/ruby/3.0.0/gems/nio4r-2.5.4/spec/nio/selectables/pipe_spec.rb
tdiary-5.1.5 vendor/bundle/ruby/3.0.0/gems/nio4r-2.5.5/spec/nio/selectables/pipe_spec.rb