Sha256: 2d8a1887483443dff5fe571453dfb865c90acf3284a3d6ba171ecf57348c5edf
Contents?: true
Size: 1.99 KB
Versions: 4
Compression:
Stored size: 1.99 KB
Contents
require 'spec_helper' require 'spec/proto/test_service_impl' describe 'Functional ZMQ Client' do before(:all) do Thread.abort_on_exception = true server = OpenStruct.new(:server => "127.0.0.1", :port => 9399, :backlog => 100, :threshold => 100) @server_thread = Thread.new(server) { |s| Protobuf::Rpc::ZmqRunner.run(s) } Thread.pass until Protobuf::Rpc::Zmq::Server.running? end after(:all) do ::Protobuf::Rpc::Zmq::Server.stop @server_thread.join end it 'runs fine when required fields are set' do expect { with_constants "Protobuf::ClientType" => "Zmq" do client = ::Spec::Proto::TestService.client(:async => false) client.find(:name => 'Test Name', :active => true) do |c| c.on_success do |succ| succ.name.should eq("Test Name") succ.status.should eq(::Spec::Proto::StatusType::ENABLED) end c.on_failure do |err| raise err.inspect end end end }.to_not raise_error end it 'calls the on_failure callback when a message is malformed' do error = nil with_constants "Protobuf::ClientType" => "Zmq" do request = ::Spec::Proto::ResourceFindRequest.new(:active => true) client = ::Spec::Proto::TestService.client(:async => false) client.find(request) do |c| c.on_success { raise "shouldn't pass"} c.on_failure {|e| error = e} end end error.message.should =~ /ResourceFindRequest.*fields.*improperly set.*"name"/ end it 'calls the on_failure callback when the request type is wrong' do error = nil with_constants "Protobuf::ClientType" => "Zmq" do request = ::Spec::Proto::Resource.new(:name => 'Test Name') client = ::Spec::Proto::TestService.client(:async => false) client.find(request) do |c| c.on_success { raise "shouldn't pass"} c.on_failure {|e| error = e} end end error.message.should =~ /expected request.*ResourceFindRequest.*Resource instead/i end end
Version data entries
4 entries across 4 versions & 1 rubygems