File: libzmq_spec.rb

package info (click to toggle)
ruby-ffi-rzmq-core 1.0.7-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 192 kB
  • sloc: ruby: 524; makefile: 2
file content (71 lines) | stat: -rw-r--r-- 1,900 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
require 'spec_helper'

describe LibZMQ do

  it "exposes basic query methods" do
    [:zmq_version, :zmq_errno, :zmq_strerror].each do |method|
      expect(LibZMQ).to respond_to(method)
    end
  end

  it "exposes initialization and context methods" do
    [:zmq_init, :zmq_term, :zmq_ctx_new,
     :zmq_ctx_destroy, :zmq_ctx_set, :zmq_ctx_get].each do |method|
      expect(LibZMQ).to respond_to(method)
    end
  end

  it "exposes the message API" do
    [:zmq_msg_init, :zmq_msg_init_size, :zmq_msg_init_data,
     :zmq_msg_close, :zmq_msg_data, :zmq_msg_size,
     :zmq_msg_copy, :zmq_msg_move, :zmq_msg_send,
     :zmq_msg_recv, :zmq_msg_more, :zmq_msg_get, :zmq_msg_set].each do |method|
      expect(LibZMQ).to respond_to(method)
    end
  end

  it "exposes the socket API" do
    [:zmq_socket, :zmq_setsockopt, :zmq_getsockopt,
     :zmq_bind, :zmq_connect, :zmq_close,
     :zmq_unbind, :zmq_disconnect, :zmq_recvmsg,
     :zmq_recv, :zmq_sendmsg, :zmq_send].each do |method|
      expect(LibZMQ).to respond_to(method)
    end
  end

  it "exposes the Device API" do
    expect(LibZMQ).to respond_to(:zmq_proxy)
  end

  it "exposes the Poll API" do
    expect(LibZMQ).to respond_to(:zmq_poll)
  end

  it "exposes the Monitoring API" do
    expect(LibZMQ).to respond_to(:zmq_socket_monitor)
  end

  if LibZMQ.version3?

    describe '.terminate_context' do
      it 'calls the 3.x zmq_ctx_destroy function' do
        context_dbl = double('context')

        expect(LibZMQ).to receive(:zmq_ctx_destroy).with(context_dbl)
        LibZMQ.terminate_context(context_dbl)
      end
    end

  elsif LibZMQ.version4?

    describe '.terminate_context' do
      it 'calls the 4.x zmq_ctx_destroy function' do
        context_dbl = double('context')

        expect(LibZMQ).to receive(:zmq_ctx_term).with(context_dbl)
        LibZMQ.terminate_context(context_dbl)
      end
    end

  end
end