aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/ruby/spec/generic
diff options
context:
space:
mode:
Diffstat (limited to 'src/ruby/spec/generic')
-rw-r--r--src/ruby/spec/generic/active_call_spec.rb48
-rw-r--r--src/ruby/spec/generic/client_stub_spec.rb143
-rw-r--r--src/ruby/spec/generic/rpc_desc_spec.rb117
-rw-r--r--src/ruby/spec/generic/rpc_server_pool_spec.rb35
-rw-r--r--src/ruby/spec/generic/rpc_server_spec.rb139
-rw-r--r--src/ruby/spec/generic/service_spec.rb58
6 files changed, 222 insertions, 318 deletions
diff --git a/src/ruby/spec/generic/active_call_spec.rb b/src/ruby/spec/generic/active_call_spec.rb
index bb73eef47c..898022f185 100644
--- a/src/ruby/spec/generic/active_call_spec.rb
+++ b/src/ruby/spec/generic/active_call_spec.rb
@@ -38,9 +38,9 @@ describe GRPC::ActiveCall do
CompletionType = GRPC::Core::CompletionType
before(:each) do
- @pass_through = Proc.new { |x| x }
+ @pass_through = proc { |x| x }
@server_tag = Object.new
- @server_done_tag, meta_tag = Object.new
+ @server_done_tag = Object.new
@tag = Object.new
@client_queue = GRPC::Core::CompletionQueue.new
@@ -70,7 +70,7 @@ describe GRPC::ActiveCall do
describe '#multi_req_view' do
it 'exposes a fixed subset of the ActiveCall methods' do
- want = ['cancelled', 'deadline', 'each_remote_read', 'shutdown']
+ want = %w(cancelled, deadline, each_remote_read, shutdown)
v = @client_call.multi_req_view
want.each do |w|
expect(v.methods.include?(w))
@@ -80,7 +80,7 @@ describe GRPC::ActiveCall do
describe '#single_req_view' do
it 'exposes a fixed subset of the ActiveCall methods' do
- want = ['cancelled', 'deadline', 'shutdown']
+ want = %w(cancelled, deadline, shutdown)
v = @client_call.single_req_view
want.each do |w|
expect(v.methods.include?(w))
@@ -110,7 +110,7 @@ describe GRPC::ActiveCall do
# Accept the call, and verify that the server reads the response ok.
ev.call.server_accept(@client_queue, @server_tag)
- ev.call.server_end_initial_metadata()
+ ev.call.server_end_initial_metadata
server_call = ActiveCall.new(ev.call, @client_queue, @pass_through,
@pass_through, deadline)
expect(server_call.remote_read).to eq(msg)
@@ -120,7 +120,7 @@ describe GRPC::ActiveCall do
call = make_test_call
done_tag, meta_tag = ActiveCall.client_start_invoke(call, @client_queue,
deadline)
- marshal = Proc.new { |x| 'marshalled:' + x }
+ marshal = proc { |x| 'marshalled:' + x }
client_call = ActiveCall.new(call, @client_queue, marshal,
@pass_through, deadline,
finished_tag: done_tag,
@@ -132,33 +132,29 @@ describe GRPC::ActiveCall do
@server.request_call(@server_tag)
ev = @server_queue.next(deadline)
ev.call.server_accept(@client_queue, @server_tag)
- ev.call.server_end_initial_metadata()
+ ev.call.server_end_initial_metadata
server_call = ActiveCall.new(ev.call, @client_queue, @pass_through,
@pass_through, deadline)
expect(server_call.remote_read).to eq('marshalled:' + msg)
end
-
end
describe '#client_start_invoke' do
-
it 'sends keywords as metadata to the server when the are present' do
- call, pass_through = make_test_call, Proc.new { |x| x }
- done_tag, meta_tag = ActiveCall.client_start_invoke(call, @client_queue,
- deadline, k1: 'v1',
- k2: 'v2')
+ call = make_test_call
+ ActiveCall.client_start_invoke(call, @client_queue, deadline,
+ k1: 'v1', k2: 'v2')
@server.request_call(@server_tag)
ev = @server_queue.next(deadline)
expect(ev).to_not be_nil
expect(ev.result.metadata['k1']).to eq('v1')
expect(ev.result.metadata['k2']).to eq('v2')
end
-
end
describe '#remote_read' do
it 'reads the response sent by a server' do
- call, pass_through = make_test_call, Proc.new { |x| x }
+ call = make_test_call
done_tag, meta_tag = ActiveCall.client_start_invoke(call, @client_queue,
deadline)
client_call = ActiveCall.new(call, @client_queue, @pass_through,
@@ -173,7 +169,7 @@ describe GRPC::ActiveCall do
end
it 'saves metadata { status=200 } when the server adds no metadata' do
- call, pass_through = make_test_call, Proc.new { |x| x }
+ call = make_test_call
done_tag, meta_tag = ActiveCall.client_start_invoke(call, @client_queue,
deadline)
client_call = ActiveCall.new(call, @client_queue, @pass_through,
@@ -186,11 +182,11 @@ describe GRPC::ActiveCall do
server_call.remote_send('ignore me')
expect(client_call.metadata).to be_nil
client_call.remote_read
- expect(client_call.metadata).to eq({':status' => '200'})
+ expect(client_call.metadata).to eq(':status' => '200')
end
it 'saves metadata add by the server' do
- call, pass_through = make_test_call, Proc.new { |x| x }
+ call = make_test_call
done_tag, meta_tag = ActiveCall.client_start_invoke(call, @client_queue,
deadline)
client_call = ActiveCall.new(call, @client_queue, @pass_through,
@@ -203,13 +199,12 @@ describe GRPC::ActiveCall do
server_call.remote_send('ignore me')
expect(client_call.metadata).to be_nil
client_call.remote_read
- expect(client_call.metadata).to eq({':status' => '200', 'k1' => 'v1',
- 'k2' => 'v2'})
+ expected = { ':status' => '200', 'k1' => 'v1', 'k2' => 'v2' }
+ expect(client_call.metadata).to eq(expected)
end
-
it 'get a nil msg before a status when an OK status is sent' do
- call, pass_through = make_test_call, Proc.new { |x| x }
+ call = make_test_call
done_tag, meta_tag = ActiveCall.client_start_invoke(call, @client_queue,
deadline)
client_call = ActiveCall.new(call, @client_queue, @pass_through,
@@ -227,12 +222,11 @@ describe GRPC::ActiveCall do
expect(res).to be_nil
end
-
it 'unmarshals the response using the unmarshal func' do
call = make_test_call
done_tag, meta_tag = ActiveCall.client_start_invoke(call, @client_queue,
deadline)
- unmarshal = Proc.new { |x| 'unmarshalled:' + x }
+ unmarshal = proc { |x| 'unmarshalled:' + x }
client_call = ActiveCall.new(call, @client_queue, @pass_through,
unmarshal, deadline,
finished_tag: done_tag,
@@ -245,7 +239,6 @@ describe GRPC::ActiveCall do
server_call.remote_send('server_response')
expect(client_call.remote_read).to eq('unmarshalled:server_response')
end
-
end
describe '#each_remote_read' do
@@ -298,7 +291,6 @@ describe GRPC::ActiveCall do
server_call.send_status(OK, 'OK')
expect { e.next }.to raise_error(StopIteration)
end
-
end
describe '#writes_done' do
@@ -357,7 +349,6 @@ describe GRPC::ActiveCall do
expect { client_call.writes_done(true) }.to_not raise_error
expect { server_call.finished }.to_not raise_error
end
-
end
def expect_server_to_receive(sent_text, **kw)
@@ -371,7 +362,7 @@ describe GRPC::ActiveCall do
ev = @server_queue.next(deadline)
ev.call.add_metadata(kw)
ev.call.server_accept(@client_queue, @server_done_tag)
- ev.call.server_end_initial_metadata()
+ ev.call.server_end_initial_metadata
ActiveCall.new(ev.call, @client_queue, @pass_through,
@pass_through, deadline,
finished_tag: @server_done_tag)
@@ -384,5 +375,4 @@ describe GRPC::ActiveCall do
def deadline
Time.now + 0.25 # in 0.25 seconds; arbitrary
end
-
end
diff --git a/src/ruby/spec/generic/client_stub_spec.rb b/src/ruby/spec/generic/client_stub_spec.rb
index 2db8718d1a..8ebe48bc4c 100644
--- a/src/ruby/spec/generic/client_stub_spec.rb
+++ b/src/ruby/spec/generic/client_stub_spec.rb
@@ -31,7 +31,7 @@ require 'grpc'
require 'xray/thread_dump_signal_handler'
require_relative '../port_picker'
-NOOP = Proc.new { |x| x }
+NOOP = proc { |x| x }
def wakey_thread(&blk)
awake_mutex, awake_cond = Mutex.new, ConditionVariable.new
@@ -52,7 +52,6 @@ include GRPC::Core::StatusCodes
include GRPC::Core::TimeConsts
describe 'ClientStub' do
-
before(:each) do
Thread.abort_on_exception = true
@server = nil
@@ -67,11 +66,10 @@ describe 'ClientStub' do
end
describe '#new' do
-
it 'can be created from a host and args' do
host = new_test_host
- opts = {:a_channel_arg => 'an_arg'}
- blk = Proc.new do
+ opts = { a_channel_arg: 'an_arg' }
+ blk = proc do
GRPC::ClientStub.new(host, @cq, **opts)
end
expect(&blk).not_to raise_error
@@ -79,8 +77,8 @@ describe 'ClientStub' do
it 'can be created with a default deadline' do
host = new_test_host
- opts = {:a_channel_arg => 'an_arg', :deadline => 5}
- blk = Proc.new do
+ opts = { a_channel_arg: 'an_arg', deadline: 5 }
+ blk = proc do
GRPC::ClientStub.new(host, @cq, **opts)
end
expect(&blk).not_to raise_error
@@ -88,8 +86,8 @@ describe 'ClientStub' do
it 'can be created with an channel override' do
host = new_test_host
- opts = {:a_channel_arg => 'an_arg', :channel_override => @ch}
- blk = Proc.new do
+ opts = { a_channel_arg: 'an_arg', channel_override: @ch }
+ blk = proc do
GRPC::ClientStub.new(host, @cq, **opts)
end
expect(&blk).not_to raise_error
@@ -97,8 +95,8 @@ describe 'ClientStub' do
it 'cannot be created with a bad channel override' do
host = new_test_host
- blk = Proc.new do
- opts = {:a_channel_arg => 'an_arg', :channel_override => Object.new}
+ blk = proc do
+ opts = { a_channel_arg: 'an_arg', channel_override: Object.new }
GRPC::ClientStub.new(host, @cq, **opts)
end
expect(&blk).to raise_error
@@ -106,8 +104,8 @@ describe 'ClientStub' do
it 'cannot be created with bad credentials' do
host = new_test_host
- blk = Proc.new do
- opts = {:a_channel_arg => 'an_arg', :creds => Object.new}
+ blk = proc do
+ opts = { a_channel_arg: 'an_arg', creds: Object.new }
GRPC::ClientStub.new(host, @cq, **opts)
end
expect(&blk).to raise_error
@@ -116,17 +114,16 @@ describe 'ClientStub' do
it 'can be created with test test credentials' do
certs = load_test_certs
host = new_test_host
- blk = Proc.new do
+ blk = proc do
opts = {
GRPC::Core::Channel::SSL_TARGET => 'foo.test.google.com',
- :a_channel_arg => 'an_arg',
- :creds => GRPC::Core::Credentials.new(certs[0], nil, nil)
+ a_channel_arg: 'an_arg',
+ creds: GRPC::Core::Credentials.new(certs[0], nil, nil)
}
GRPC::ClientStub.new(host, @cq, **opts)
end
expect(&blk).to_not raise_error
end
-
end
describe '#request_response' do
@@ -135,7 +132,6 @@ describe 'ClientStub' do
end
shared_examples 'request response' do
-
it 'should send a request to/receive a reply from a server' do
host = new_test_host
th = run_request_response(host, @sent_msg, @resp, @pass)
@@ -146,8 +142,8 @@ describe 'ClientStub' do
it 'should send metadata to the server ok' do
host = new_test_host
- th = run_request_response(host, @sent_msg, @resp, @pass, k1: 'v1',
- k2: 'v2')
+ th = run_request_response(host, @sent_msg, @resp, @pass,
+ k1: 'v1', k2: 'v2')
stub = GRPC::ClientStub.new(host, @cq)
expect(get_response(stub)).to eq(@resp)
th.join
@@ -157,7 +153,10 @@ describe 'ClientStub' do
host = new_test_host
th = run_request_response(host, @sent_msg, @resp, @pass,
k1: 'updated-v1', k2: 'v2')
- update_md = Proc.new { |md| md[:k1] = 'updated-v1'; md }
+ update_md = proc do |md|
+ md[:k1] = 'updated-v1'
+ md
+ end
stub = GRPC::ClientStub.new(host, @cq, update_metadata: update_md)
expect(get_response(stub)).to eq(@resp)
th.join
@@ -167,7 +166,7 @@ describe 'ClientStub' do
alt_host = new_test_host
th = run_request_response(alt_host, @sent_msg, @resp, @pass)
ch = GRPC::Core::Channel.new(alt_host, nil)
- stub = GRPC::ClientStub.new('ignored-host', @cq, channel_override:ch)
+ stub = GRPC::ClientStub.new('ignored-host', @cq, channel_override: ch)
expect(get_response(stub)).to eq(@resp)
th.join
end
@@ -176,45 +175,37 @@ describe 'ClientStub' do
host = new_test_host
th = run_request_response(host, @sent_msg, @resp, @fail)
stub = GRPC::ClientStub.new(host, @cq)
- blk = Proc.new { get_response(stub) }
+ blk = proc { get_response(stub) }
expect(&blk).to raise_error(GRPC::BadStatus)
th.join
end
-
end
describe 'without a call operation' do
-
def get_response(stub)
- stub.request_response(@method, @sent_msg, NOOP, NOOP, k1: 'v1',
- k2: 'v2')
+ stub.request_response(@method, @sent_msg, NOOP, NOOP,
+ k1: 'v1', k2: 'v2')
end
it_behaves_like 'request response'
-
end
describe 'via a call operation' do
-
def get_response(stub)
op = stub.request_response(@method, @sent_msg, NOOP, NOOP,
- return_op:true, k1: 'v1', k2: 'v2')
+ return_op: true, k1: 'v1', k2: 'v2')
expect(op).to be_a(GRPC::ActiveCall::Operation)
- op.execute()
+ op.execute
end
it_behaves_like 'request response'
-
end
-
end
describe '#client_streamer' do
-
shared_examples 'client streaming' do
-
before(:each) do
- @sent_msgs = Array.new(3) { |i| 'msg_' + (i+1).to_s }
+ @sent_msgs = Array.new(3) { |i| 'msg_' + (i + 1).to_s }
@resp = 'a_reply'
end
@@ -228,19 +219,21 @@ describe 'ClientStub' do
it 'should send metadata to the server ok' do
host = new_test_host
- th = run_client_streamer(host, @sent_msgs, @resp, @pass, k1: 'v1',
- k2: 'v2')
+ th = run_client_streamer(host, @sent_msgs, @resp, @pass,
+ k1: 'v1', k2: 'v2')
stub = GRPC::ClientStub.new(host, @cq)
expect(get_response(stub)).to eq(@resp)
th.join
end
-
it 'should update the sent metadata with a provided metadata updater' do
host = new_test_host
th = run_client_streamer(host, @sent_msgs, @resp, @pass,
k1: 'updated-v1', k2: 'v2')
- update_md = Proc.new { |md| md[:k1] = 'updated-v1'; md }
+ update_md = proc do |md|
+ md[:k1] = 'updated-v1'
+ md
+ end
stub = GRPC::ClientStub.new(host, @cq, update_metadata: update_md)
expect(get_response(stub)).to eq(@resp)
th.join
@@ -250,46 +243,38 @@ describe 'ClientStub' do
host = new_test_host
th = run_client_streamer(host, @sent_msgs, @resp, @fail)
stub = GRPC::ClientStub.new(host, @cq)
- blk = Proc.new { get_response(stub) }
+ blk = proc { get_response(stub) }
expect(&blk).to raise_error(GRPC::BadStatus)
th.join
end
-
end
describe 'without a call operation' do
-
def get_response(stub)
- stub.client_streamer(@method, @sent_msgs, NOOP, NOOP, k1: 'v1',
- k2: 'v2')
+ stub.client_streamer(@method, @sent_msgs, NOOP, NOOP,
+ k1: 'v1', k2: 'v2')
end
it_behaves_like 'client streaming'
-
end
describe 'via a call operation' do
-
def get_response(stub)
op = stub.client_streamer(@method, @sent_msgs, NOOP, NOOP,
- return_op:true, k1: 'v1', k2: 'v2')
+ return_op: true, k1: 'v1', k2: 'v2')
expect(op).to be_a(GRPC::ActiveCall::Operation)
- resp = op.execute()
+ op.execute
end
it_behaves_like 'client streaming'
-
end
-
end
describe '#server_streamer' do
-
shared_examples 'server streaming' do
-
before(:each) do
@sent_msg = 'a_msg'
- @replys = Array.new(3) { |i| 'reply_' + (i+1).to_s }
+ @replys = Array.new(3) { |i| 'reply_' + (i + 1).to_s }
end
it 'should send a request to/receive replies from a server' do
@@ -311,8 +296,8 @@ describe 'ClientStub' do
it 'should send metadata to the server ok' do
host = new_test_host
- th = run_server_streamer(host, @sent_msg, @replys, @fail, k1: 'v1',
- k2: 'v2')
+ th = run_server_streamer(host, @sent_msg, @replys, @fail,
+ k1: 'v1', k2: 'v2')
stub = GRPC::ClientStub.new(host, @cq)
e = get_responses(stub)
expect { e.collect { |r| r } }.to raise_error(GRPC::BadStatus)
@@ -323,55 +308,50 @@ describe 'ClientStub' do
host = new_test_host
th = run_server_streamer(host, @sent_msg, @replys, @pass,
k1: 'updated-v1', k2: 'v2')
- update_md = Proc.new { |md| md[:k1] = 'updated-v1'; md }
+ update_md = proc do |md|
+ md[:k1] = 'updated-v1'
+ md
+ end
stub = GRPC::ClientStub.new(host, @cq, update_metadata: update_md)
e = get_responses(stub)
expect(e.collect { |r| r }).to eq(@replys)
th.join
end
-
end
describe 'without a call operation' do
-
def get_responses(stub)
- e = stub.server_streamer(@method, @sent_msg, NOOP, NOOP, k1: 'v1',
- k2: 'v2')
+ e = stub.server_streamer(@method, @sent_msg, NOOP, NOOP,
+ k1: 'v1', k2: 'v2')
expect(e).to be_a(Enumerator)
e
end
it_behaves_like 'server streaming'
-
end
describe 'via a call operation' do
-
def get_responses(stub)
op = stub.server_streamer(@method, @sent_msg, NOOP, NOOP,
- return_op:true, k1: 'v1', k2: 'v2')
+ return_op: true, k1: 'v1', k2: 'v2')
expect(op).to be_a(GRPC::ActiveCall::Operation)
- e = op.execute()
+ e = op.execute
expect(e).to be_a(Enumerator)
e
end
it_behaves_like 'server streaming'
-
end
-
end
describe '#bidi_streamer' do
-
shared_examples 'bidi streaming' do
-
before(:each) do
- @sent_msgs = Array.new(3) { |i| 'msg_' + (i+1).to_s }
- @replys = Array.new(3) { |i| 'reply_' + (i+1).to_s }
+ @sent_msgs = Array.new(3) { |i| 'msg_' + (i + 1).to_s }
+ @replys = Array.new(3) { |i| 'reply_' + (i + 1).to_s }
end
- it 'supports sending all the requests first', :bidi => true do
+ it 'supports sending all the requests first', bidi: true do
host = new_test_host
th = run_bidi_streamer_handle_inputs_first(host, @sent_msgs, @replys,
@pass)
@@ -381,7 +361,7 @@ describe 'ClientStub' do
th.join
end
- it 'supports client-initiated ping pong', :bidi => true do
+ it 'supports client-initiated ping pong', bidi: true do
host = new_test_host
th = run_bidi_streamer_echo_ping_pong(host, @sent_msgs, @pass, true)
stub = GRPC::ClientStub.new(host, @cq)
@@ -396,7 +376,7 @@ describe 'ClientStub' do
# servers don't know if all the client metadata has been sent until
# they receive a message from the client. Without receiving all the
# metadata, the server does not accept the call, so this test hangs.
- xit 'supports a server-initiated ping pong', :bidi => true do
+ xit 'supports a server-initiated ping pong', bidi: true do
host = new_test_host
th = run_bidi_streamer_echo_ping_pong(host, @sent_msgs, @pass, false)
stub = GRPC::ClientStub.new(host, @cq)
@@ -404,11 +384,9 @@ describe 'ClientStub' do
expect(e.collect { |r| r }).to eq(@sent_msgs)
th.join
end
-
end
describe 'without a call operation' do
-
def get_responses(stub)
e = stub.bidi_streamer(@method, @sent_msgs, NOOP, NOOP)
expect(e).to be_a(Enumerator)
@@ -416,13 +394,12 @@ describe 'ClientStub' do
end
it_behaves_like 'bidi streaming'
-
end
describe 'via a call operation' do
-
def get_responses(stub)
- op = stub.bidi_streamer(@method, @sent_msgs, NOOP, NOOP, return_op:true)
+ op = stub.bidi_streamer(@method, @sent_msgs, NOOP, NOOP,
+ return_op: true)
expect(op).to be_a(GRPC::ActiveCall::Operation)
e = op.execute
expect(e).to be_a(Enumerator)
@@ -430,9 +407,7 @@ describe 'ClientStub' do
end
it_behaves_like 'bidi streaming'
-
end
-
end
def run_server_streamer(hostname, expected_input, replys, status, **kw)
@@ -514,14 +489,13 @@ describe 'ClientStub' do
def expect_server_to_be_invoked(hostname, awake_mutex, awake_cond)
server_queue = start_test_server(hostname, awake_mutex, awake_cond)
- test_deadline = Time.now + 10 # fail tests after 10 seconds
ev = server_queue.pluck(@server_tag, INFINITE_FUTURE)
- raise OutOfTime if ev.nil?
+ fail OutOfTime if ev.nil?
server_call = ev.call
server_call.metadata = ev.result.metadata
finished_tag = Object.new
server_call.server_accept(server_queue, finished_tag)
- server_call.server_end_initial_metadata()
+ server_call.server_end_initial_metadata
GRPC::ActiveCall.new(server_call, server_queue, NOOP, NOOP, INFINITE_FUTURE,
finished_tag: finished_tag)
end
@@ -530,5 +504,4 @@ describe 'ClientStub' do
port = find_unused_tcp_port
"localhost:#{port}"
end
-
end
diff --git a/src/ruby/spec/generic/rpc_desc_spec.rb b/src/ruby/spec/generic/rpc_desc_spec.rb
index efef7e4686..ac0b5c51f4 100644
--- a/src/ruby/spec/generic/rpc_desc_spec.rb
+++ b/src/ruby/spec/generic/rpc_desc_spec.rb
@@ -30,9 +30,7 @@
require 'grpc'
require 'grpc/generic/rpc_desc'
-
describe GRPC::RpcDesc do
-
RpcDesc = GRPC::RpcDesc
Stream = RpcDesc::Stream
OK = GRPC::Core::StatusCodes::OK
@@ -56,7 +54,6 @@ describe GRPC::RpcDesc do
end
describe '#run_server_method' do
-
describe 'for request responses' do
before(:each) do
@call = double('active_call')
@@ -78,7 +75,7 @@ describe GRPC::RpcDesc do
it 'absorbs EventError with no further action' do
expect(@call).to receive(:remote_read).once.and_raise(EventError)
- blk = Proc.new do
+ blk = proc do
@request_response.run_server_method(@call, method(:fake_reqresp))
end
expect(&blk).to_not raise_error
@@ -86,7 +83,7 @@ describe GRPC::RpcDesc do
it 'absorbs CallError with no further action' do
expect(@call).to receive(:remote_read).once.and_raise(CallError)
- blk = Proc.new do
+ blk = proc do
@request_response.run_server_method(@call, method(:fake_reqresp))
end
expect(&blk).to_not raise_error
@@ -100,7 +97,6 @@ describe GRPC::RpcDesc do
expect(@call).to receive(:finished).once
@request_response.run_server_method(@call, method(:fake_reqresp))
end
-
end
describe 'for client streamers' do
@@ -122,7 +118,7 @@ describe GRPC::RpcDesc do
it 'absorbs EventError with no further action' do
expect(@call).to receive(:remote_send).once.and_raise(EventError)
- blk = Proc.new do
+ blk = proc do
@client_streamer.run_server_method(@call, method(:fake_clstream))
end
expect(&blk).to_not raise_error
@@ -130,20 +126,18 @@ describe GRPC::RpcDesc do
it 'absorbs CallError with no further action' do
expect(@call).to receive(:remote_send).once.and_raise(CallError)
- blk = Proc.new do
+ blk = proc do
@client_streamer.run_server_method(@call, method(:fake_clstream))
end
expect(&blk).to_not raise_error
end
it 'sends a response and closes the stream if there no errors' do
- req = Object.new
expect(@call).to receive(:remote_send).once.with(@ok_response)
expect(@call).to receive(:send_status).once.with(OK, 'OK')
expect(@call).to receive(:finished).once
@client_streamer.run_server_method(@call, method(:fake_clstream))
end
-
end
describe 'for server streaming' do
@@ -167,7 +161,7 @@ describe GRPC::RpcDesc do
it 'absorbs EventError with no further action' do
expect(@call).to receive(:remote_read).once.and_raise(EventError)
- blk = Proc.new do
+ blk = proc do
@server_streamer.run_server_method(@call, method(:fake_svstream))
end
expect(&blk).to_not raise_error
@@ -175,7 +169,7 @@ describe GRPC::RpcDesc do
it 'absorbs CallError with no further action' do
expect(@call).to receive(:remote_read).once.and_raise(CallError)
- blk = Proc.new do
+ blk = proc do
@server_streamer.run_server_method(@call, method(:fake_svstream))
end
expect(&blk).to_not raise_error
@@ -189,7 +183,6 @@ describe GRPC::RpcDesc do
expect(@call).to receive(:finished).once
@server_streamer.run_server_method(@call, method(:fake_svstream))
end
-
end
describe 'for bidi streamers' do
@@ -215,30 +208,27 @@ describe GRPC::RpcDesc do
end
it 'closes the stream if there no errors' do
- req = Object.new
expect(@call).to receive(:run_server_bidi)
expect(@call).to receive(:send_status).once.with(OK, 'OK')
expect(@call).to receive(:finished).once
@bidi_streamer.run_server_method(@call, method(:fake_bidistream))
end
-
end
-
end
describe '#assert_arity_matches' do
def no_arg
end
- def fake_clstream(arg)
+ def fake_clstream(_arg)
end
- def fake_svstream(arg1, arg2)
+ def fake_svstream(_arg1, _arg2)
end
it 'raises when a request_response does not have 2 args' do
[:fake_clstream, :no_arg].each do |mth|
- blk = Proc.new do
+ blk = proc do
@request_response.assert_arity_matches(method(mth))
end
expect(&blk).to raise_error
@@ -246,7 +236,7 @@ describe GRPC::RpcDesc do
end
it 'passes when a request_response has 2 args' do
- blk = Proc.new do
+ blk = proc do
@request_response.assert_arity_matches(method(:fake_svstream))
end
expect(&blk).to_not raise_error
@@ -254,7 +244,7 @@ describe GRPC::RpcDesc do
it 'raises when a server_streamer does not have 2 args' do
[:fake_clstream, :no_arg].each do |mth|
- blk = Proc.new do
+ blk = proc do
@server_streamer.assert_arity_matches(method(mth))
end
expect(&blk).to raise_error
@@ -262,7 +252,7 @@ describe GRPC::RpcDesc do
end
it 'passes when a server_streamer has 2 args' do
- blk = Proc.new do
+ blk = proc do
@server_streamer.assert_arity_matches(method(:fake_svstream))
end
expect(&blk).to_not raise_error
@@ -270,7 +260,7 @@ describe GRPC::RpcDesc do
it 'raises when a client streamer does not have 1 arg' do
[:fake_svstream, :no_arg].each do |mth|
- blk = Proc.new do
+ blk = proc do
@client_streamer.assert_arity_matches(method(mth))
end
expect(&blk).to raise_error
@@ -278,16 +268,15 @@ describe GRPC::RpcDesc do
end
it 'passes when a client_streamer has 1 arg' do
- blk = Proc.new do
+ blk = proc do
@client_streamer.assert_arity_matches(method(:fake_clstream))
end
expect(&blk).to_not raise_error
end
-
it 'raises when a bidi streamer does not have 1 arg' do
[:fake_svstream, :no_arg].each do |mth|
- blk = Proc.new do
+ blk = proc do
@bidi_streamer.assert_arity_matches(method(mth))
end
expect(&blk).to raise_error
@@ -295,88 +284,78 @@ describe GRPC::RpcDesc do
end
it 'passes when a bidi streamer has 1 arg' do
- blk = Proc.new do
+ blk = proc do
@bidi_streamer.assert_arity_matches(method(:fake_clstream))
end
expect(&blk).to_not raise_error
end
-
end
- describe '#is_request_response?' do
-
+ describe '#request_response?' do
it 'is true only input and output are both not Streams' do
- expect(@request_response.is_request_response?).to be(true)
- expect(@client_streamer.is_request_response?).to be(false)
- expect(@bidi_streamer.is_request_response?).to be(false)
- expect(@server_streamer.is_request_response?).to be(false)
+ expect(@request_response.request_response?).to be(true)
+ expect(@client_streamer.request_response?).to be(false)
+ expect(@bidi_streamer.request_response?).to be(false)
+ expect(@server_streamer.request_response?).to be(false)
end
-
end
- describe '#is_client_streamer?' do
-
+ describe '#client_streamer?' do
it 'is true only when input is a Stream and output is not a Stream' do
- expect(@client_streamer.is_client_streamer?).to be(true)
- expect(@request_response.is_client_streamer?).to be(false)
- expect(@server_streamer.is_client_streamer?).to be(false)
- expect(@bidi_streamer.is_client_streamer?).to be(false)
+ expect(@client_streamer.client_streamer?).to be(true)
+ expect(@request_response.client_streamer?).to be(false)
+ expect(@server_streamer.client_streamer?).to be(false)
+ expect(@bidi_streamer.client_streamer?).to be(false)
end
-
end
- describe '#is_server_streamer?' do
-
+ describe '#server_streamer?' do
it 'is true only when output is a Stream and input is not a Stream' do
- expect(@server_streamer.is_server_streamer?).to be(true)
- expect(@client_streamer.is_server_streamer?).to be(false)
- expect(@request_response.is_server_streamer?).to be(false)
- expect(@bidi_streamer.is_server_streamer?).to be(false)
+ expect(@server_streamer.server_streamer?).to be(true)
+ expect(@client_streamer.server_streamer?).to be(false)
+ expect(@request_response.server_streamer?).to be(false)
+ expect(@bidi_streamer.server_streamer?).to be(false)
end
-
end
- describe '#is_bidi_streamer?' do
-
+ describe '#bidi_streamer?' do
it 'is true only when output is a Stream and input is a Stream' do
- expect(@bidi_streamer.is_bidi_streamer?).to be(true)
- expect(@server_streamer.is_bidi_streamer?).to be(false)
- expect(@client_streamer.is_bidi_streamer?).to be(false)
- expect(@request_response.is_bidi_streamer?).to be(false)
+ expect(@bidi_streamer.bidi_streamer?).to be(true)
+ expect(@server_streamer.bidi_streamer?).to be(false)
+ expect(@client_streamer.bidi_streamer?).to be(false)
+ expect(@request_response.bidi_streamer?).to be(false)
end
-
end
- def fake_reqresp(req, call)
+ def fake_reqresp(_req, _call)
@ok_response
end
- def fake_clstream(call)
+ def fake_clstream(_call)
@ok_response
end
- def fake_svstream(req, call)
+ def fake_svstream(_req, _call)
[@ok_response, @ok_response]
end
def fake_bidistream(an_array)
- return an_array
+ an_array
end
- def bad_status(req, call)
- raise GRPC::BadStatus.new(@bs_code, 'NOK')
+ def bad_status(_req, _call)
+ fail GRPC::BadStatus.new(@bs_code, 'NOK')
end
- def other_error(req, call)
- raise ArgumentError.new('other error')
+ def other_error(_req, _call)
+ fail(ArgumentError, 'other error')
end
- def bad_status_alt(call)
- raise GRPC::BadStatus.new(@bs_code, 'NOK')
+ def bad_status_alt(_call)
+ fail GRPC::BadStatus.new(@bs_code, 'NOK')
end
- def other_error_alt(call)
- raise ArgumentError.new('other error')
+ def other_error_alt(_call)
+ fail(ArgumentError, 'other error')
end
-
end
diff --git a/src/ruby/spec/generic/rpc_server_pool_spec.rb b/src/ruby/spec/generic/rpc_server_pool_spec.rb
index 83979ec164..27fabd9c31 100644
--- a/src/ruby/spec/generic/rpc_server_pool_spec.rb
+++ b/src/ruby/spec/generic/rpc_server_pool_spec.rb
@@ -33,9 +33,7 @@ require 'xray/thread_dump_signal_handler'
Pool = GRPC::RpcServer::Pool
describe Pool do
-
describe '#new' do
-
it 'raises if a non-positive size is used' do
expect { Pool.new(0) }.to raise_error
expect { Pool.new(-1) }.to raise_error
@@ -45,11 +43,9 @@ describe Pool do
it 'is constructed OK with a positive size' do
expect { Pool.new(1) }.not_to raise_error
end
-
end
describe '#jobs_waiting' do
-
it 'at start, it is zero' do
p = Pool.new(1)
expect(p.jobs_waiting).to be(0)
@@ -57,74 +53,67 @@ describe Pool do
it 'it increases, with each scheduled job if the pool is not running' do
p = Pool.new(1)
- job = Proc.new { }
+ job = proc {}
expect(p.jobs_waiting).to be(0)
5.times do |i|
p.schedule(&job)
expect(p.jobs_waiting).to be(i + 1)
end
-
end
it 'it decreases as jobs are run' do
p = Pool.new(1)
- job = Proc.new { }
+ job = proc {}
expect(p.jobs_waiting).to be(0)
- 3.times do |i|
+ 3.times do
p.schedule(&job)
end
p.start
sleep 2
expect(p.jobs_waiting).to be(0)
end
-
end
describe '#schedule' do
-
it 'throws if the pool is already stopped' do
p = Pool.new(1)
- p.stop()
- job = Proc.new { }
+ p.stop
+ job = proc {}
expect { p.schedule(&job) }.to raise_error
end
it 'adds jobs that get run by the pool' do
p = Pool.new(1)
- p.start()
+ p.start
o, q = Object.new, Queue.new
- job = Proc.new { q.push(o) }
+ job = proc { q.push(o) }
p.schedule(&job)
expect(q.pop).to be(o)
p.stop
end
-
end
describe '#stop' do
-
it 'works when there are no scheduled tasks' do
p = Pool.new(1)
- expect { p.stop() }.not_to raise_error
+ expect { p.stop }.not_to raise_error
end
it 'stops jobs when there are long running jobs' do
p = Pool.new(1)
- p.start()
+ p.start
o, q = Object.new, Queue.new
- job = Proc.new do
+ job = proc do
sleep(5) # long running
q.push(o)
end
p.schedule(&job)
sleep(1) # should ensure the long job gets scheduled
- expect { p.stop() }.not_to raise_error
+ expect { p.stop }.not_to raise_error
end
-
end
describe '#start' do
-
it 'runs pre-scheduled jobs' do
p = Pool.new(2)
o, q = Object.new, Queue.new
@@ -146,7 +135,5 @@ describe Pool do
end
p.stop
end
-
end
-
end
diff --git a/src/ruby/spec/generic/rpc_server_spec.rb b/src/ruby/spec/generic/rpc_server_spec.rb
index 5997fdb363..cd4888a3b4 100644
--- a/src/ruby/spec/generic/rpc_server_spec.rb
+++ b/src/ruby/spec/generic/rpc_server_spec.rb
@@ -37,33 +37,37 @@ def load_test_certs
files.map { |f| File.open(File.join(test_root, f)).read }
end
+# A test message
class EchoMsg
- def self.marshal(o)
+ def self.marshal(_o)
''
end
- def self.unmarshal(o)
+ def self.unmarshal(_o)
EchoMsg.new
end
end
+# A test service with no methods.
class EmptyService
include GRPC::GenericService
end
+# A test service without an implementation.
class NoRpcImplementation
include GRPC::GenericService
rpc :an_rpc, EchoMsg, EchoMsg
end
+# A test service with an implementation.
class EchoService
include GRPC::GenericService
rpc :an_rpc, EchoMsg, EchoMsg
- def initialize(default_var='ignored')
+ def initialize(_default_var = 'ignored')
end
- def an_rpc(req, call)
+ def an_rpc(req, _call)
logger.info('echo service received a request')
req
end
@@ -71,14 +75,15 @@ end
EchoStub = EchoService.rpc_stub_class
+# A slow test service.
class SlowService
include GRPC::GenericService
rpc :an_rpc, EchoMsg, EchoMsg
- def initialize(default_var='ignored')
+ def initialize(_default_var = 'ignored')
end
- def an_rpc(req, call)
+ def an_rpc(req, _call)
delay = 0.25
logger.info("starting a slow #{delay} rpc")
sleep delay
@@ -89,7 +94,6 @@ end
SlowStub = SlowService.rpc_stub_class
describe GRPC::RpcServer do
-
RpcServer = GRPC::RpcServer
StatusCodes = GRPC::Core::StatusCodes
@@ -97,7 +101,7 @@ describe GRPC::RpcServer do
@method = 'an_rpc_method'
@pass = 0
@fail = 1
- @noop = Proc.new { |x| x }
+ @noop = proc { |x| x }
@server_queue = GRPC::Core::CompletionQueue.new
port = find_unused_tcp_port
@@ -112,18 +116,17 @@ describe GRPC::RpcServer do
end
describe '#new' do
-
it 'can be created with just some args' do
- opts = {:a_channel_arg => 'an_arg'}
- blk = Proc.new do
+ opts = { a_channel_arg: 'an_arg' }
+ blk = proc do
RpcServer.new(**opts)
end
expect(&blk).not_to raise_error
end
it 'can be created with a default deadline' do
- opts = {:a_channel_arg => 'an_arg', :deadline => 5}
- blk = Proc.new do
+ opts = { a_channel_arg: 'an_arg', deadline: 5 }
+ blk = proc do
RpcServer.new(**opts)
end
expect(&blk).not_to raise_error
@@ -131,20 +134,20 @@ describe GRPC::RpcServer do
it 'can be created with a completion queue override' do
opts = {
- :a_channel_arg => 'an_arg',
- :completion_queue_override => @server_queue
+ a_channel_arg: 'an_arg',
+ completion_queue_override: @server_queue
}
- blk = Proc.new do
+ blk = proc do
RpcServer.new(**opts)
end
expect(&blk).not_to raise_error
end
it 'cannot be created with a bad completion queue override' do
- blk = Proc.new do
+ blk = proc do
opts = {
- :a_channel_arg => 'an_arg',
- :completion_queue_override => Object.new
+ a_channel_arg: 'an_arg',
+ completion_queue_override: Object.new
}
RpcServer.new(**opts)
end
@@ -152,10 +155,10 @@ describe GRPC::RpcServer do
end
it 'cannot be created with invalid ServerCredentials' do
- blk = Proc.new do
+ blk = proc do
opts = {
- :a_channel_arg => 'an_arg',
- :creds => Object.new
+ a_channel_arg: 'an_arg',
+ creds: Object.new
}
RpcServer.new(**opts)
end
@@ -165,10 +168,10 @@ describe GRPC::RpcServer do
it 'can be created with the creds as valid ServerCedentials' do
certs = load_test_certs
server_creds = GRPC::Core::ServerCredentials.new(nil, certs[1], certs[2])
- blk = Proc.new do
+ blk = proc do
opts = {
- :a_channel_arg => 'an_arg',
- :creds => server_creds
+ a_channel_arg: 'an_arg',
+ creds: server_creds
}
RpcServer.new(**opts)
end
@@ -176,30 +179,28 @@ describe GRPC::RpcServer do
end
it 'can be created with a server override' do
- opts = {:a_channel_arg => 'an_arg', :server_override => @server}
- blk = Proc.new do
+ opts = { a_channel_arg: 'an_arg', server_override: @server }
+ blk = proc do
RpcServer.new(**opts)
end
expect(&blk).not_to raise_error
end
it 'cannot be created with a bad server override' do
- blk = Proc.new do
+ blk = proc do
opts = {
- :a_channel_arg => 'an_arg',
- :server_override => Object.new
+ a_channel_arg: 'an_arg',
+ server_override: Object.new
}
RpcServer.new(**opts)
end
expect(&blk).to raise_error
end
-
end
describe '#stopped?' do
-
before(:each) do
- opts = {:a_channel_arg => 'an_arg', :poll_period => 1}
+ opts = { a_channel_arg: 'an_arg', poll_period: 1 }
@srv = RpcServer.new(**opts)
end
@@ -229,33 +230,31 @@ describe GRPC::RpcServer do
expect(@srv.stopped?).to be(true)
t.join
end
-
end
describe '#running?' do
-
it 'starts out false' do
- opts = {:a_channel_arg => 'an_arg', :server_override => @server}
+ opts = { a_channel_arg: 'an_arg', server_override: @server }
r = RpcServer.new(**opts)
expect(r.running?).to be(false)
end
it 'is false after run is called with no services registered' do
opts = {
- :a_channel_arg => 'an_arg',
- :poll_period => 1,
- :server_override => @server
+ a_channel_arg: 'an_arg',
+ poll_period: 1,
+ server_override: @server
}
r = RpcServer.new(**opts)
- r.run()
+ r.run
expect(r.running?).to be(false)
end
it 'is true after run is called with a registered service' do
opts = {
- :a_channel_arg => 'an_arg',
- :poll_period => 1,
- :server_override => @server
+ a_channel_arg: 'an_arg',
+ poll_period: 1,
+ server_override: @server
}
r = RpcServer.new(**opts)
r.handle(EchoService)
@@ -265,13 +264,11 @@ describe GRPC::RpcServer do
r.stop
t.join
end
-
end
describe '#handle' do
-
before(:each) do
- @opts = {:a_channel_arg => 'an_arg', :poll_period => 1}
+ @opts = { a_channel_arg: 'an_arg', poll_period: 1 }
@srv = RpcServer.new(**@opts)
end
@@ -309,33 +306,30 @@ describe GRPC::RpcServer do
@srv.handle(EchoService)
expect { r.handle(EchoService) }.to raise_error
end
-
end
describe '#run' do
-
before(:each) do
@client_opts = {
- :channel_override => @ch
+ channel_override: @ch
}
@marshal = EchoService.rpc_descs[:an_rpc].marshal_proc
@unmarshal = EchoService.rpc_descs[:an_rpc].unmarshal_proc(:output)
server_opts = {
- :server_override => @server,
- :completion_queue_override => @server_queue,
- :poll_period => 1
+ server_override: @server,
+ completion_queue_override: @server_queue,
+ poll_period: 1
}
@srv = RpcServer.new(**server_opts)
end
describe 'when running' do
-
it 'should return NOT_FOUND status for requests on unknown methods' do
@srv.handle(EchoService)
t = Thread.new { @srv.run }
@srv.wait_till_running
req = EchoMsg.new
- blk = Proc.new do
+ blk = proc do
cq = GRPC::Core::CompletionQueue.new
stub = GRPC::ClientStub.new(@host, cq, **@client_opts)
stub.request_response('/unknown', req, @marshal, @unmarshal)
@@ -352,20 +346,19 @@ describe GRPC::RpcServer do
req = EchoMsg.new
n = 5 # arbitrary
stub = EchoStub.new(@host, **@client_opts)
- n.times { |x| expect(stub.an_rpc(req)).to be_a(EchoMsg) }
+ n.times { expect(stub.an_rpc(req)).to be_a(EchoMsg) }
@srv.stop
t.join
end
it 'should obtain responses for multiple parallel requests' do
@srv.handle(EchoService)
- t = Thread.new { @srv.run }
+ Thread.new { @srv.run }
@srv.wait_till_running
req, q = EchoMsg.new, Queue.new
n = 5 # arbitrary
threads = []
- n.times do |x|
- cq = GRPC::Core::CompletionQueue.new
+ n.times do
threads << Thread.new do
stub = EchoStub.new(@host, **@client_opts)
q << stub.an_rpc(req)
@@ -373,44 +366,40 @@ describe GRPC::RpcServer do
end
n.times { expect(q.pop).to be_a(EchoMsg) }
@srv.stop
- threads.each { |t| t.join }
+ threads.each(&:join)
end
it 'should return UNAVAILABLE status if there too many jobs' do
opts = {
- :a_channel_arg => 'an_arg',
- :server_override => @server,
- :completion_queue_override => @server_queue,
- :pool_size => 1,
- :poll_period => 1,
- :max_waiting_requests => 0
+ a_channel_arg: 'an_arg',
+ server_override: @server,
+ completion_queue_override: @server_queue,
+ pool_size: 1,
+ poll_period: 1,
+ max_waiting_requests: 0
}
alt_srv = RpcServer.new(**opts)
alt_srv.handle(SlowService)
- t = Thread.new { alt_srv.run }
+ Thread.new { alt_srv.run }
alt_srv.wait_till_running
req = EchoMsg.new
n = 5 # arbitrary, use as many to ensure the server pool is exceeded
threads = []
- _1_failed_as_unavailable = false
- n.times do |x|
+ one_failed_as_unavailable = false
+ n.times do
threads << Thread.new do
- cq = GRPC::Core::CompletionQueue.new
stub = SlowStub.new(@host, **@client_opts)
begin
stub.an_rpc(req)
rescue GRPC::BadStatus => e
- _1_failed_as_unavailable = e.code == StatusCodes::UNAVAILABLE
+ one_failed_as_unavailable = e.code == StatusCodes::UNAVAILABLE
end
end
end
- threads.each { |t| t.join }
+ threads.each(&:join)
alt_srv.stop
- expect(_1_failed_as_unavailable).to be(true)
+ expect(one_failed_as_unavailable).to be(true)
end
-
end
-
end
-
end
diff --git a/src/ruby/spec/generic/service_spec.rb b/src/ruby/spec/generic/service_spec.rb
index a8e0c6f52f..29f2412631 100644
--- a/src/ruby/spec/generic/service_spec.rb
+++ b/src/ruby/spec/generic/service_spec.rb
@@ -31,23 +31,24 @@ require 'grpc'
require 'grpc/generic/rpc_desc'
require 'grpc/generic/service'
-
+# A test message that encodes/decodes using marshal/marshal.
class GoodMsg
- def self.marshal(o)
+ def self.marshal(_o)
''
end
- def self.unmarshal(o)
+ def self.unmarshal(_o)
GoodMsg.new
end
end
+# A test message that encodes/decodes using encode/decode.
class EncodeDecodeMsg
- def self.encode(o)
+ def self.encode(_o)
''
end
- def self.decode(o)
+ def self.decode(_o)
GoodMsg.new
end
end
@@ -55,7 +56,6 @@ end
GenericService = GRPC::GenericService
Dsl = GenericService::Dsl
-
describe 'String#underscore' do
it 'should convert CamelCase to underscore separated' do
expect('AnRPC'.underscore).to eq('an_rpc')
@@ -66,20 +66,14 @@ describe 'String#underscore' do
end
describe Dsl do
-
it 'can be included in new classes' do
- blk = Proc.new do
- c = Class.new { include Dsl }
- end
+ blk = proc { Class.new { include Dsl } }
expect(&blk).to_not raise_error
end
-
end
describe GenericService do
-
describe 'including it' do
-
it 'adds a class method, rpc' do
c = Class.new do
include GenericService
@@ -144,9 +138,8 @@ describe GenericService do
end
describe '#include' do
-
it 'raises if #rpc is missing an arg' do
- blk = Proc.new do
+ blk = proc do
Class.new do
include GenericService
rpc :AnRpc, GoodMsg
@@ -154,7 +147,7 @@ describe GenericService do
end
expect(&blk).to raise_error ArgumentError
- blk = Proc.new do
+ blk = proc do
Class.new do
include GenericService
rpc :AnRpc
@@ -164,9 +157,8 @@ describe GenericService do
end
describe 'when #rpc args are incorrect' do
-
it 'raises if an arg does not have the marshal or unmarshal methods' do
- blk = Proc.new do
+ blk = proc do
Class.new do
include GenericService
rpc :AnRpc, GoodMsg, Object
@@ -176,13 +168,14 @@ describe GenericService do
end
it 'raises if a type arg only has the marshal method' do
+ # a bad message type with only a marshal method
class OnlyMarshal
def marshal(o)
o
end
end
- blk = Proc.new do
+ blk = proc do
Class.new do
include GenericService
rpc :AnRpc, OnlyMarshal, GoodMsg
@@ -192,12 +185,13 @@ describe GenericService do
end
it 'raises if a type arg only has the unmarshal method' do
+ # a bad message type with only an unmarshal method
class OnlyUnmarshal
def self.ummarshal(o)
o
end
end
- blk = Proc.new do
+ blk = proc do
Class.new do
include GenericService
rpc :AnRpc, GoodMsg, OnlyUnmarshal
@@ -208,7 +202,7 @@ describe GenericService do
end
it 'is ok for services that expect the default {un,}marshal methods' do
- blk = Proc.new do
+ blk = proc do
Class.new do
include GenericService
rpc :AnRpc, GoodMsg, GoodMsg
@@ -218,7 +212,7 @@ describe GenericService do
end
it 'is ok for services that override the default {un,}marshal methods' do
- blk = Proc.new do
+ blk = proc do
Class.new do
include GenericService
self.marshal_class_method = :encode
@@ -228,11 +222,9 @@ describe GenericService do
end
expect(&blk).not_to raise_error
end
-
end
describe '#rpc_stub_class' do
-
it 'generates a client class that defines any of the rpc methods' do
s = Class.new do
include GenericService
@@ -249,7 +241,6 @@ describe GenericService do
end
describe 'the generated instances' do
-
it 'can be instanciated with just a hostname' do
s = Class.new do
include GenericService
@@ -277,13 +268,10 @@ describe GenericService do
expect(o.methods).to include(:a_client_streamer)
expect(o.methods).to include(:a_bidi_streamer)
end
-
end
-
end
describe '#assert_rpc_descs_have_methods' do
-
it 'fails if there is no instance method for an rpc descriptor' do
c1 = Class.new do
include GenericService
@@ -310,16 +298,16 @@ describe GenericService do
rpc :AClientStreamer, stream(GoodMsg), GoodMsg
rpc :ABidiStreamer, stream(GoodMsg), stream(GoodMsg)
- def an_rpc(req, call)
+ def an_rpc(_req, _call)
end
- def a_server_streamer(req, call)
+ def a_server_streamer(_req, _call)
end
- def a_client_streamer(call)
+ def a_client_streamer(_call)
end
- def a_bidi_streamer(call)
+ def a_bidi_streamer(_call)
end
end
expect { c.assert_rpc_descs_have_methods }.to_not raise_error
@@ -330,7 +318,7 @@ describe GenericService do
include GenericService
rpc :AnRpc, GoodMsg, GoodMsg
- def an_rpc(req, call)
+ def an_rpc(_req, _call)
end
end
c = Class.new(base)
@@ -344,13 +332,11 @@ describe GenericService do
rpc :AnRpc, GoodMsg, GoodMsg
end
c = Class.new(base) do
- def an_rpc(req, call)
+ def an_rpc(_req, _call)
end
end
expect { c.assert_rpc_descs_have_methods }.to_not raise_error
expect(c.include?(GenericService)).to be(true)
end
-
end
-
end