Sha256: 89acd7d40dae2fbf5dd12212b811eda2bd88257750e72a8a2859338aa9b5033d

Contents?: true

Size: 1.29 KB

Versions: 13

Compression:

Stored size: 1.29 KB

Contents

require 'spec_helper'

class UtilTest
  include ::Protobuf::Rpc::Zmq::Util
end

describe ::Protobuf::Rpc::Zmq::Util do
  before(:each) do
    load 'protobuf/zmq.rb'
  end

  subject { UtilTest.new }
  describe '#zmq_error_check' do
    it 'raises when the error code is less than 0' do
      expect {
        subject.zmq_error_check(-1, :test)
      }.to raise_error(/test/)
    end

    it 'retrieves the error string from ZeroMQ' do
      ZMQ::Util.stub(:error_string).and_return('an error from zmq')
      expect {
        subject.zmq_error_check(-1, :test)
      }.to raise_error(RuntimeError, /an error from zmq/i)
    end

    it 'does nothing if the error code is > 0' do
      expect {
        subject.zmq_error_check(1, :test)
      }.to_not raise_error
    end

    it 'does nothing if the error code is == 0' do
      expect {
        subject.zmq_error_check(0, :test)
      }.to_not raise_error
    end
  end

  describe '#log_signature' do
    it 'returns the signature for the log' do
      subject.log_signature.should include('server', 'UtilTest')
    end
  end

  describe '.resolve_ip' do
    it 'resolves ips' do
      expect(subject.resolve_ip('127.0.0.1')).to eq('127.0.0.1')
    end

    it 'resolves non ips' do
      expect(subject.resolve_ip('localhost')).to eq('127.0.0.1')
    end
  end
end

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
protobuffy-3.6.0 spec/lib/protobuf/rpc/servers/zmq/util_spec.rb
protobuffy-3.5.1 spec/lib/protobuf/rpc/servers/zmq/util_spec.rb
protobuffy-3.4.0 spec/lib/protobuf/rpc/servers/zmq/util_spec.rb
protobuffy-3.3.0 spec/lib/protobuf/rpc/servers/zmq/util_spec.rb
protobuffy-3.2.0 spec/lib/protobuf/rpc/servers/zmq/util_spec.rb
protobuffy-3.1.0 spec/lib/protobuf/rpc/servers/zmq/util_spec.rb
protobuf-3.0.4 spec/lib/protobuf/rpc/servers/zmq/util_spec.rb
protobuf-3.0.3 spec/lib/protobuf/rpc/servers/zmq/util_spec.rb
protobuf-3.0.2 spec/lib/protobuf/rpc/servers/zmq/util_spec.rb
protobuf-3.0.1 spec/lib/protobuf/rpc/servers/zmq/util_spec.rb
protobuf-3.0.0 spec/lib/protobuf/rpc/servers/zmq/util_spec.rb
protobuf-3.0.0.rc2 spec/lib/protobuf/rpc/servers/zmq/util_spec.rb
protobuf-3.0.0.rc1 spec/lib/protobuf/rpc/servers/zmq/util_spec.rb