Sha256: eed6c6a958ed1fa24f6728aafa45e1f372f0bdf481cbbc073c44c7b3a797554c

Contents?: true

Size: 1.16 KB

Versions: 2

Compression:

Stored size: 1.16 KB

Contents

require 'spec_helper'

module NNCore
  describe "nn_shutdown" do

    context "given an initialized library and" do

      context "given a valid socket and" 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 0" do
            rc = LibNanomsg.nn_shutdown(@socket, @endpoint)
            expect(rc).to eq(0)
          end
        end

        context "given an invalid endpoint" do
          it "returns -1 and set nn_errno to EINVAL" do
            rc = LibNanomsg.nn_shutdown(@socket, 0)
            expect(rc).to eq(-1)
            expect(LibNanomsg.nn_errno).to eq(EINVAL)
          end
        end
      end

      context "given an invalid socket" do

        it "returns -1 and sets nn_errno to EBADF" do
          rc = LibNanomsg.nn_shutdown(0, 0)
          expect(rc).to eq(-1)
          expect(LibNanomsg.nn_errno).to eq(EBADF)
        end

      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
nn-core-0.4.0 spec/nn_shutdown_spec.rb
nn-core-0.3.0 spec/nn_shutdown_spec.rb