aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/ruby
diff options
context:
space:
mode:
authorGravatar Muxi Yan <mxyan@google.com>2017-10-06 16:55:52 -0700
committerGravatar Muxi Yan <mxyan@google.com>2017-10-06 17:25:40 -0700
commit63602748415fb836afd7a9685fbe5e85bf5ebfed (patch)
treef621272bdfb56a20782c9ed3a1a06f286c121941 /src/ruby
parent906f69c1dfb09766708ca82217851cc20ebedd83 (diff)
Make the names of compression algorithms backwards compatible at surface API
Diffstat (limited to 'src/ruby')
-rwxr-xr-xsrc/ruby/pb/test/client.rb2
-rw-r--r--src/ruby/spec/compression_options_spec.rb24
2 files changed, 13 insertions, 13 deletions
diff --git a/src/ruby/pb/test/client.rb b/src/ruby/pb/test/client.rb
index f938f945f5..a110fec960 100755
--- a/src/ruby/pb/test/client.rb
+++ b/src/ruby/pb/test/client.rb
@@ -102,7 +102,7 @@ def create_stub(opts)
if ['client_compressed_unary',
'client_compressed_streaming'].include?(opts.test_case)
compression_options =
- GRPC::Core::CompressionOptions.new(default_algorithm: 'message/gzip')
+ GRPC::Core::CompressionOptions.new(default_algorithm: :gzip)
compression_channel_args = compression_options.to_channel_arg_hash
else
compression_channel_args = {}
diff --git a/src/ruby/spec/compression_options_spec.rb b/src/ruby/spec/compression_options_spec.rb
index bec82e42a9..03c3cd9f07 100644
--- a/src/ruby/spec/compression_options_spec.rb
+++ b/src/ruby/spec/compression_options_spec.rb
@@ -19,7 +19,7 @@ describe GRPC::Core::CompressionOptions do
# according to what the core lib provides.
# Names of supported compression algorithms
- ALGORITHMS = [:identity, 'message/deflate', 'message/gzip']
+ ALGORITHMS = [:identity, :deflate, :gzip]
# Names of valid supported compression levels
COMPRESS_LEVELS = [:none, :low, :medium, :high]
@@ -54,10 +54,10 @@ describe GRPC::Core::CompressionOptions do
options = GRPC::Core::CompressionOptions.new(
default_algorithm: :identity,
default_level: :none,
- disabled_algorithms: ['message/gzip', 'message/deflate']
+ disabled_algorithms: [:gzip, :deflate]
)
- ['message/gzip', 'message/deflate'].each do |algorithm|
+ [:gzip, :deflate].each do |algorithm|
expect(options.algorithm_enabled?(algorithm)).to be false
expect(options.disabled_algorithms.include?(algorithm)).to be true
end
@@ -69,16 +69,16 @@ describe GRPC::Core::CompressionOptions do
it 'works when all optional args have been set' do
options = GRPC::Core::CompressionOptions.new(
- default_algorithm: 'message/gzip',
+ default_algorithm: :gzip,
default_level: :low,
- disabled_algorithms: ['message/deflate']
+ disabled_algorithms: [:deflate]
)
- expect(options.algorithm_enabled?('message/deflate')).to be false
- expect(options.algorithm_enabled?('message/gzip')).to be true
- expect(options.disabled_algorithms).to eq(['message/deflate'])
+ expect(options.algorithm_enabled?(:deflate)).to be false
+ expect(options.algorithm_enabled?(:gzip)).to be true
+ expect(options.disabled_algorithms).to eq([:deflate])
- expect(options.default_algorithm).to be('message/gzip')
+ expect(options.default_algorithm).to be(:gzip)
expect(options.default_level).to be(:low)
expect(options.to_hash).to be_instance_of(Hash)
end
@@ -102,12 +102,12 @@ describe GRPC::Core::CompressionOptions do
describe '#new with bad parameters' do
it 'should fail with more than one parameter' do
- blk = proc { GRPC::Core::CompressionOptions.new('message/gzip', :none) }
+ blk = proc { GRPC::Core::CompressionOptions.new(:gzip, :none) }
expect { blk.call }.to raise_error
end
it 'should fail with a non-hash parameter' do
- blk = proc { GRPC::Core::CompressionOptions.new('message/gzip') }
+ blk = proc { GRPC::Core::CompressionOptions.new(:gzip) }
expect { blk.call }.to raise_error
end
end
@@ -137,7 +137,7 @@ describe GRPC::Core::CompressionOptions do
[:none, :any, 'gzip', Object.new, 1].each do |name|
it "should fail for parameter ${name} of class #{name.class}" do
options = GRPC::Core::CompressionOptions.new(
- disabled_algorithms: ['message/gzip'])
+ disabled_algorithms: [:gzip])
blk = proc do
options.algorithm_enabled?(name)