Sha256: 1758e10d3bce808a1e345ab832f6abee072700c4ee65beb54fd4aed540b8f97d

Contents?: true

Size: 1.45 KB

Versions: 5

Compression:

Stored size: 1.45 KB

Contents

require 'spec_helper'

describe UV::Pipe do
  let(:handle_name) { :pipe }
  let(:loop) { double() }
  let(:pointer) { double() }
  subject { UV::Pipe.new(loop, pointer) }

  it_behaves_like 'a handle'
  it_behaves_like 'a stream'

  describe "#open" do
    let(:fileno) { 6555 }

    it "calls UV.pipe_open" do
      UV.should_receive(:pipe_open).with(pointer, fileno)

      subject.open(fileno)
    end
  end

  describe "#bind" do
    let(:name) {
      name = "/tmp/filename.ipc"
      name = subject.send :windows_path, name if FFI::Platform.windows?
      name
    }

    it "calls UV.pipe_bind" do
      UV.should_receive(:pipe_bind).with(pointer, name)

      subject.bind(name)
    end
  end

  describe "#connect" do
    let(:name) {
      name = "/tmp/filename.ipc"
      name = subject.send :windows_path, name if FFI::Platform.windows?
      name
    }
    let(:connect_request) { double() }

    it "requires a block" do
      expect{ subject.connect(name) }.to raise_error(ArgumentError)
    end

    it "calls UV.pipe_connect" do
      UV.should_receive(:create_request).with(:uv_connect).and_return(connect_request)
      UV.should_receive(:pipe_connect).with(connect_request, pointer, name, subject.method(:on_connect))

      subject.connect(name) { |e| }
    end
  end

  describe "#pending_instances=" do
    it "calls UV.pipe_pending_instances" do
      UV.should_receive(:pipe_pending_instances).with(pointer, 5)
      subject.pending_instances = 5
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
uvrb-0.2.0 spec/uv/pipe_spec.rb
uvrb-0.1.4 spec/uv/pipe_spec.rb
uvrb-0.1.3 spec/uv/pipe_spec.rb
uvrb-0.1.2 spec/uv/pipe_spec.rb
uvrb-0.1.1 spec/uv/pipe_spec.rb