Sha256: cf96192a8396ebdd6124d1cd525c585e31f956a4dbe353242b1d3f150e7b0cfa

Contents?: true

Size: 1.13 KB

Versions: 3

Compression:

Stored size: 1.13 KB

Contents

require 'spec_helper'

module NNCore
  describe "nn_send" do

    context "given an initialized library and" do

      context "given a valid socket" do
        before(:each) do
          @socket = LibNanomsg.nn_socket(AF_SP, NN_PUB)
        end

        after(:each) do
          LibNanomsg.nn_close(@socket)
        end

        context "given a valid endpoint" do
          before(:each) do
            @endpoint = LibNanomsg.nn_bind(@socket, "inproc://some_endpoint")
          end

          it "returns the number of bytes sent" do
            nbytes = LibNanomsg.nn_send(@socket, "ABC", 3, 0)
            nbytes.should == 3
          end
        end

        context "disconnected from all endpoints" do
          it "returns the number of bytes queued" do
            nbytes = LibNanomsg.nn_send(@socket, "ABC", 3, 0)
            nbytes.should == 3
          end
        end
      end

      context "given an invalid socket" do

        it "returns -1 and sets nn_errno to EBADF" do
          rc = LibNanomsg.nn_send(0, "ABC", 3, 0)
          rc.should == -1
          LibNanomsg.nn_errno.should == EBADF
        end

      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
nn-core-0.2.1 spec/nn_send_spec.rb
nn-core-0.1.6 spec/nn_send_spec.rb
nn-core-0.1.5 spec/nn_send_spec.rb