aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/ruby/spec/channel_spec.rb
diff options
context:
space:
mode:
authorGravatar Nicolas "Pixel" Noble <pixel@nobis-crew.org>2015-04-30 01:52:19 +0200
committerGravatar Nicolas "Pixel" Noble <pixel@nobis-crew.org>2015-04-30 01:52:19 +0200
commitf173793e51e726a887b84b4c37588e2e308191cc (patch)
tree0c03feb8ebdb68a99c51d3f24c3aa39755f14793 /src/ruby/spec/channel_spec.rb
parent882d7a7eec148046a90e1d111b93e353e3df0c31 (diff)
parent1685d773ef81420bf747c6988a2ad9baefd126fa (diff)
Merge branch 'master' of github.com:grpc/grpc into travis-speedup
Conflicts: .travis.yml
Diffstat (limited to 'src/ruby/spec/channel_spec.rb')
-rw-r--r--src/ruby/spec/channel_spec.rb31
1 files changed, 11 insertions, 20 deletions
diff --git a/src/ruby/spec/channel_spec.rb b/src/ruby/spec/channel_spec.rb
index af73294abe..d471ff5db6 100644
--- a/src/ruby/spec/channel_spec.rb
+++ b/src/ruby/spec/channel_spec.rb
@@ -36,16 +36,13 @@ def load_test_certs
end
describe GRPC::Core::Channel do
- FAKE_HOST = 'localhost:0'
+ let(:fake_host) { 'localhost:0' }
+ let(:cq) { GRPC::Core::CompletionQueue.new }
def create_test_cert
GRPC::Core::Credentials.new(load_test_certs[0])
end
- before(:each) do
- @cq = GRPC::Core::CompletionQueue.new
- end
-
shared_examples '#new' do
it 'take a host name without channel args' do
expect { GRPC::Core::Channel.new('dummy_host', nil) }.not_to raise_error
@@ -61,7 +58,7 @@ describe GRPC::Core::Channel do
it 'does not take a hash with bad values as channel args' do
blk = construct_with_args(symbol: Object.new)
expect(&blk).to raise_error TypeError
- blk = construct_with_args('1' => Hash.new)
+ blk = construct_with_args('1' => {})
expect(&blk).to raise_error TypeError
end
@@ -115,25 +112,23 @@ describe GRPC::Core::Channel do
describe '#create_call' do
it 'creates a call OK' do
- host = FAKE_HOST
- ch = GRPC::Core::Channel.new(host, nil)
+ ch = GRPC::Core::Channel.new(fake_host, nil)
deadline = Time.now + 5
blk = proc do
- ch.create_call('dummy_method', 'dummy_host', deadline)
+ ch.create_call(cq, 'dummy_method', 'dummy_host', deadline)
end
expect(&blk).to_not raise_error
end
it 'raises an error if called on a closed channel' do
- host = FAKE_HOST
- ch = GRPC::Core::Channel.new(host, nil)
+ ch = GRPC::Core::Channel.new(fake_host, nil)
ch.close
deadline = Time.now + 5
blk = proc do
- ch.create_call('dummy_method', 'dummy_host', deadline)
+ ch.create_call(cq, 'dummy_method', 'dummy_host', deadline)
end
expect(&blk).to raise_error(RuntimeError)
end
@@ -141,15 +136,13 @@ describe GRPC::Core::Channel do
describe '#destroy' do
it 'destroys a channel ok' do
- host = FAKE_HOST
- ch = GRPC::Core::Channel.new(host, nil)
+ ch = GRPC::Core::Channel.new(fake_host, nil)
blk = proc { ch.destroy }
expect(&blk).to_not raise_error
end
it 'can be called more than once without error' do
- host = FAKE_HOST
- ch = GRPC::Core::Channel.new(host, nil)
+ ch = GRPC::Core::Channel.new(fake_host, nil)
blk = proc { ch.destroy }
blk.call
expect(&blk).to_not raise_error
@@ -164,15 +157,13 @@ describe GRPC::Core::Channel do
describe '#close' do
it 'closes a channel ok' do
- host = FAKE_HOST
- ch = GRPC::Core::Channel.new(host, nil)
+ ch = GRPC::Core::Channel.new(fake_host, nil)
blk = proc { ch.close }
expect(&blk).to_not raise_error
end
it 'can be called more than once without error' do
- host = FAKE_HOST
- ch = GRPC::Core::Channel.new(host, nil)
+ ch = GRPC::Core::Channel.new(fake_host, nil)
blk = proc { ch.close }
blk.call
expect(&blk).to_not raise_error