protobuf 3.0.4 → 3.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -0
  3. data/lib/protobuf/field/base_field.rb +5 -1
  4. data/lib/protobuf/field/float_field.rb +4 -0
  5. data/lib/protobuf/rpc/connectors/zmq.rb +31 -20
  6. data/lib/protobuf/rpc/servers/zmq/broker.rb +1 -1
  7. data/lib/protobuf/version.rb +1 -1
  8. data/protobuf.gemspec +1 -1
  9. data/spec/encoding/all_types_spec.rb +1 -1
  10. data/spec/encoding/extreme_values_spec.rb +0 -0
  11. data/spec/functional/socket_server_spec.rb +5 -4
  12. data/spec/functional/zmq_server_spec.rb +7 -7
  13. data/spec/lib/protobuf/cli_spec.rb +39 -39
  14. data/spec/lib/protobuf/code_generator_spec.rb +4 -4
  15. data/spec/lib/protobuf/enum_spec.rb +23 -23
  16. data/spec/lib/protobuf/field/float_field_spec.rb +55 -0
  17. data/spec/lib/protobuf/field/string_field_spec.rb +4 -4
  18. data/spec/lib/protobuf/generators/base_spec.rb +4 -7
  19. data/spec/lib/protobuf/generators/enum_generator_spec.rb +3 -3
  20. data/spec/lib/protobuf/generators/extension_generator_spec.rb +4 -4
  21. data/spec/lib/protobuf/generators/field_generator_spec.rb +11 -11
  22. data/spec/lib/protobuf/generators/file_generator_spec.rb +3 -3
  23. data/spec/lib/protobuf/generators/service_generator_spec.rb +2 -2
  24. data/spec/lib/protobuf/lifecycle_spec.rb +16 -16
  25. data/spec/lib/protobuf/logger_spec.rb +27 -27
  26. data/spec/lib/protobuf/message_spec.rb +42 -42
  27. data/spec/lib/protobuf/optionable_spec.rb +1 -1
  28. data/spec/lib/protobuf/rpc/client_spec.rb +13 -13
  29. data/spec/lib/protobuf/rpc/connector_spec.rb +4 -4
  30. data/spec/lib/protobuf/rpc/connectors/base_spec.rb +7 -7
  31. data/spec/lib/protobuf/rpc/connectors/common_spec.rb +31 -33
  32. data/spec/lib/protobuf/rpc/connectors/socket_spec.rb +8 -8
  33. data/spec/lib/protobuf/rpc/connectors/zmq_spec.rb +24 -35
  34. data/spec/lib/protobuf/rpc/middleware/exception_handler_spec.rb +8 -8
  35. data/spec/lib/protobuf/rpc/middleware/logger_spec.rb +2 -2
  36. data/spec/lib/protobuf/rpc/middleware/request_decoder_spec.rb +10 -10
  37. data/spec/lib/protobuf/rpc/middleware/response_encoder_spec.rb +6 -6
  38. data/spec/lib/protobuf/rpc/servers/socket_server_spec.rb +3 -3
  39. data/spec/lib/protobuf/rpc/servers/zmq/server_spec.rb +3 -3
  40. data/spec/lib/protobuf/rpc/servers/zmq/util_spec.rb +2 -2
  41. data/spec/lib/protobuf/rpc/servers/zmq/worker_spec.rb +5 -5
  42. data/spec/lib/protobuf/rpc/service_directory_spec.rb +26 -27
  43. data/spec/lib/protobuf/rpc/service_dispatcher_spec.rb +4 -4
  44. data/spec/lib/protobuf/rpc/service_filters_spec.rb +39 -39
  45. data/spec/lib/protobuf/rpc/service_spec.rb +27 -27
  46. data/spec/lib/protobuf/rpc/stat_spec.rb +4 -4
  47. data/spec/lib/protobuf_spec.rb +7 -7
  48. data/spec/spec_helper.rb +1 -0
  49. data/spec/support/packed_field.rb +1 -1
  50. metadata +6 -76
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dd448f24362b0e9378d3281d77291538d862d4d1
4
- data.tar.gz: 592b16f0af1c48b7c8336ea32f35a646f3947a9c
3
+ metadata.gz: 0081c6fc0146c8bd5d61a987d0f5b374a950d13b
4
+ data.tar.gz: cccc8f0d7acb314e3725816fe3e7081d06e1e346
5
5
  SHA512:
6
- metadata.gz: a73428f4308d156ea94d9737e792b16db2455013a976ef6c5e22f2ca7f59ab156e43323816d1c30099934131fdde704d3741becf909decf76cf590b36d0fd75c
7
- data.tar.gz: 9e66f6d8762f9c62c2d1ce01c34fc1ef841ebd32c05bc8630d0008f05572e7c9644e197e9e66d74bee08cc77b81a20c3f8c4300c64524ef8839dc8bea44ab2cc
6
+ metadata.gz: 19e94efb5c58ed704afac0ff0a2023589dbd9ec2aef35bd376cbba7dc4ec3c6feb7fb01363b123ee01913d3ecdfead89d4e3a79526536d4a78859450a67595b5
7
+ data.tar.gz: f9fc9d6001dae54bb777a4112db945abb04a34ceb80e63a500d1f13bb1583a62481d366c293c7a7d0bde334e71b7d5b683001b88501141db878de38b83a466c3
@@ -2,6 +2,7 @@ language: ruby
2
2
  rvm:
3
3
  - "1.9.3"
4
4
  - "2.0.0"
5
+ - "2.1.1"
5
6
  script: NO_COMPILE_TEST_PROTOS=1 bundle exec rake spec/lib
6
7
  notifications:
7
8
  webhooks:
@@ -63,6 +63,10 @@ module Protobuf
63
63
  true
64
64
  end
65
65
 
66
+ def coerce!(value)
67
+ value
68
+ end
69
+
66
70
  def enum?
67
71
  false
68
72
  end
@@ -226,7 +230,7 @@ module Protobuf
226
230
  if val.nil? || (val.respond_to?(:empty?) && val.empty?)
227
231
  @values.delete(field.name)
228
232
  elsif field.acceptable?(val)
229
- @values[field.name] = val
233
+ @values[field.name] = field.coerce!(val)
230
234
  else
231
235
  raise TypeError, "Unacceptable value #{val} for field #{field.name} of type #{field.type_class}"
232
236
  end
@@ -20,6 +20,10 @@ module Protobuf
20
20
  val.respond_to?(:to_f)
21
21
  end
22
22
 
23
+ def coerce!(val)
24
+ Float(val)
25
+ end
26
+
23
27
  def decode(bytes)
24
28
  bytes.unpack('e').first
25
29
  end
@@ -5,20 +5,18 @@ module Protobuf
5
5
  module Rpc
6
6
  module Connectors
7
7
  class Zmq < Base
8
-
9
8
  RequestTimeout = Class.new(RuntimeError)
9
+ ZmqRecoverableError = Class.new(RuntimeError)
10
10
 
11
11
  ##
12
12
  # Included Modules
13
13
  #
14
-
15
14
  include Protobuf::Rpc::Connectors::Common
16
15
  include Protobuf::Logger::LogMethods
17
16
 
18
17
  ##
19
18
  # Class Constants
20
19
  #
21
-
22
20
  CLIENT_RETRIES = (ENV['PB_CLIENT_RETRIES'] || 3)
23
21
 
24
22
  ##
@@ -68,21 +66,27 @@ module Protobuf
68
66
 
69
67
  begin
70
68
  server_uri = lookup_server_uri
71
-
72
69
  socket = zmq_context.socket(::ZMQ::REQ)
73
- socket.setsockopt(::ZMQ::LINGER, 0)
74
70
 
75
- log_debug { sign_message("Establishing connection: #{server_uri}") }
76
- zmq_error_check(socket.connect(server_uri), :socket_connect)
77
- log_debug { sign_message("Connection established to #{server_uri}") }
78
-
79
- if first_alive_load_balance?
80
- check_available_response = ""
81
- zmq_error_check(socket.send_string(::Protobuf::Rpc::Zmq::CHECK_AVAILABLE_MESSAGE), :socket_send_string)
82
- zmq_error_check(socket.recv_string(check_available_response), :socket_recv_string)
83
-
84
- if check_available_response == ::Protobuf::Rpc::Zmq::NO_WORKERS_AVAILABLE
85
- zmq_error_check(socket.close, :socket_close)
71
+ if socket # Make sure the context builds the socket
72
+ socket.setsockopt(::ZMQ::LINGER, 0)
73
+
74
+ log_debug { sign_message("Establishing connection: #{server_uri}") }
75
+ zmq_error_check(socket.connect(server_uri), :socket_connect)
76
+ log_debug { sign_message("Connection established to #{server_uri}") }
77
+
78
+ if first_alive_load_balance?
79
+ begin
80
+ check_available_response = ""
81
+ zmq_recoverable_error_check(socket.send_string(::Protobuf::Rpc::Zmq::CHECK_AVAILABLE_MESSAGE), :socket_send_string)
82
+ zmq_recoverable_error_check(socket.recv_string(check_available_response), :socket_recv_string)
83
+
84
+ if check_available_response == ::Protobuf::Rpc::Zmq::NO_WORKERS_AVAILABLE
85
+ zmq_recoverable_error_check(socket.close, :socket_close)
86
+ end
87
+ rescue ZmqRecoverableError
88
+ socket = nil # couldn't make a connection and need to try again
89
+ end
86
90
  end
87
91
  end
88
92
  end while socket.try(:socket).nil?
@@ -101,7 +105,7 @@ module Protobuf
101
105
  # to the host and port in the options
102
106
  #
103
107
  def lookup_server_uri
104
- 50.times do
108
+ 5.times do
105
109
  service_directory.all_listings_for(service).each do |listing|
106
110
  host = listing.try(:address)
107
111
  port = listing.try(:port)
@@ -111,8 +115,6 @@ module Protobuf
111
115
  host = options[:host]
112
116
  port = options[:port]
113
117
  return "tcp://#{host}:#{port}" if host_alive?(host)
114
-
115
- sleep(1.0/10.0) # not sure why sleeping at all, but should be way less than 1 second
116
118
  end
117
119
 
118
120
  raise "Host not found for service #{service}"
@@ -120,7 +122,6 @@ module Protobuf
120
122
 
121
123
  def host_alive?(host)
122
124
  return true unless ping_port_enabled?
123
-
124
125
  socket = TCPSocket.new(host, ping_port.to_i)
125
126
 
126
127
  true
@@ -199,6 +200,16 @@ module Protobuf
199
200
  ERROR
200
201
  end
201
202
  end
203
+
204
+ def zmq_recoverable_error_check(return_code, source)
205
+ unless ::ZMQ::Util.resultcode_ok?(return_code || -1)
206
+ raise ZmqRecoverableError, <<-ERROR
207
+ Last ZMQ API call to #{source} failed with "#{::ZMQ::Util.error_string}".
208
+
209
+ #{caller(1).join($/)}
210
+ ERROR
211
+ end
212
+ end
202
213
  end
203
214
  end
204
215
  end
@@ -102,7 +102,7 @@ module Protobuf
102
102
  address, _, message, *frames = read_from_frontend
103
103
 
104
104
  if message == ::Protobuf::Rpc::Zmq::CHECK_AVAILABLE_MESSAGE
105
- if @idle_workers.any? || local_queue.empty?
105
+ if @idle_workers.any? || local_queue.size < 5 # Should make queue a SizedQueue and allow users to configure queue size
106
106
  write_to_frontend([address, "", ::Protobuf::Rpc::Zmq::WORKERS_AVAILABLE])
107
107
  else
108
108
  write_to_frontend([address, "", ::Protobuf::Rpc::Zmq::NO_WORKERS_AVAILABLE])
@@ -1,3 +1,3 @@
1
1
  module Protobuf
2
- VERSION = '3.0.4'
2
+ VERSION = '3.0.5'
3
3
  end
@@ -27,7 +27,7 @@ require "protobuf/version"
27
27
  s.add_development_dependency 'ffi-rzmq'
28
28
  s.add_development_dependency 'pry-nav'
29
29
  s.add_development_dependency 'rake'
30
- s.add_development_dependency 'rspec'
30
+ s.add_development_dependency 'rspec', '>= 3.0'
31
31
  s.add_development_dependency 'simplecov'
32
32
  s.add_development_dependency 'yard'
33
33
  s.add_development_dependency 'timecop'
@@ -86,6 +86,6 @@ describe ::Protobuf do
86
86
  file.read
87
87
  end
88
88
 
89
- data.should eq message.serialize_to_string
89
+ expect(data).to eq(message.serialize_to_string)
90
90
  end
91
91
  end
@@ -21,8 +21,8 @@ describe 'Functional Socket Client' do
21
21
 
22
22
  client.find(:name => 'Test Name', :active => true) do |c|
23
23
  c.on_success do |succ|
24
- succ.name.should eq("Test Name")
25
- succ.status.should eq(::Test::StatusType::ENABLED)
24
+ expect(succ.name).to eq("Test Name")
25
+ expect(succ.status).to eq(::Test::StatusType::ENABLED)
26
26
  end
27
27
 
28
28
  c.on_failure do |err|
@@ -41,7 +41,8 @@ describe 'Functional Socket Client' do
41
41
  c.on_success { raise "shouldn't pass"}
42
42
  c.on_failure {|e| error = e}
43
43
  end
44
- error.message.should =~ /name.*required/
44
+
45
+ expect(error.message).to match(/name.*required/)
45
46
  end
46
47
 
47
48
  it 'calls the on_failure callback when the request type is wrong' do
@@ -53,7 +54,7 @@ describe 'Functional Socket Client' do
53
54
  c.on_success { raise "shouldn't pass"}
54
55
  c.on_failure {|e| error = e}
55
56
  end
56
- error.message.should =~ /expected request.*ResourceFindRequest.*Resource instead/i
57
+ expect(error.message).to match(/expected request.*ResourceFindRequest.*Resource instead/i)
57
58
  end
58
59
  end
59
60
 
@@ -27,8 +27,8 @@ describe 'Functional ZMQ Client' do
27
27
 
28
28
  client.find(:name => 'Test Name', :active => true) do |c|
29
29
  c.on_success do |succ|
30
- succ.name.should eq("Test Name")
31
- succ.status.should eq(::Test::StatusType::ENABLED)
30
+ expect(succ.name).to eq("Test Name")
31
+ expect(succ.status).to eq(::Test::StatusType::ENABLED)
32
32
  end
33
33
 
34
34
  c.on_failure do |err|
@@ -46,8 +46,8 @@ describe 'Functional ZMQ Client' do
46
46
 
47
47
  client.find(:name => 'Test Name', :active => true) do |c|
48
48
  c.on_success do |succ|
49
- succ.name.should eq("Test Name")
50
- succ.status.should eq(::Test::StatusType::ENABLED)
49
+ expect(succ.name).to eq("Test Name")
50
+ expect(succ.status).to eq(::Test::StatusType::ENABLED)
51
51
  end
52
52
 
53
53
  c.on_failure do |err|
@@ -69,7 +69,7 @@ describe 'Functional ZMQ Client' do
69
69
  c.on_success { raise "shouldn't pass" }
70
70
  c.on_failure {|e| error = e }
71
71
  end
72
- error.message.should match(/name.*required/)
72
+ expect(error.message).to match(/name.*required/)
73
73
  end
74
74
  end
75
75
 
@@ -83,7 +83,7 @@ describe 'Functional ZMQ Client' do
83
83
  c.on_success { raise "shouldn't pass" }
84
84
  c.on_failure {|e| error = e}
85
85
  end
86
- error.message.should match(/expected request.*ResourceFindRequest.*Resource instead/i)
86
+ expect(error.message).to match(/expected request.*ResourceFindRequest.*Resource instead/i)
87
87
  end
88
88
  end
89
89
 
@@ -96,7 +96,7 @@ describe 'Functional ZMQ Client' do
96
96
  c.on_success { raise "shouldn't pass" }
97
97
  c.on_failure { |e| error = e }
98
98
  end
99
- error.message.should match(/The server repeatedly failed to respond/)
99
+ expect(error.message).to match(/The server repeatedly failed to respond/)
100
100
  end
101
101
  end
102
102
 
@@ -9,19 +9,19 @@ describe ::Protobuf::CLI do
9
9
 
10
10
  let(:sock_runner) {
11
11
  runner = double("SocketRunner", :register_signals => nil)
12
- runner.stub(:run) { ::ActiveSupport::Notifications.publish( "after_server_bind" ) }
12
+ allow(runner).to receive(:run).and_return(::ActiveSupport::Notifications.publish("after_server_bind"))
13
13
  runner
14
14
  }
15
15
 
16
16
  let(:zmq_runner) {
17
17
  runner = double "ZmqRunner", register_signals: nil
18
- runner.stub(:run) { ::ActiveSupport::Notifications.publish( "after_server_bind" ) }
18
+ allow(runner).to receive(:run).and_return(::ActiveSupport::Notifications.publish("after_server_bind"))
19
19
  runner
20
20
  }
21
21
 
22
22
  before(:each) do
23
- ::Protobuf::Rpc::SocketRunner.stub(:new) { sock_runner }
24
- ::Protobuf::Rpc::ZmqRunner.stub(:new) { zmq_runner }
23
+ allow(::Protobuf::Rpc::SocketRunner).to receive(:new).and_return(sock_runner)
24
+ allow(::Protobuf::Rpc::ZmqRunner).to receive(:new).and_return(zmq_runner)
25
25
  end
26
26
 
27
27
  describe '#start' do
@@ -33,8 +33,8 @@ describe ::Protobuf::CLI do
33
33
  let(:test_args) { [ '--host=123.123.123.123' ] }
34
34
 
35
35
  it 'sends the host option to the runner' do
36
- ::Protobuf::Rpc::SocketRunner.should_receive(:new) do |options|
37
- options[:host].should eq '123.123.123.123'
36
+ expect(::Protobuf::Rpc::SocketRunner).to receive(:new) do |options|
37
+ expect(options[:host]).to eq '123.123.123.123'
38
38
  end.and_return(sock_runner)
39
39
  described_class.start(args)
40
40
  end
@@ -44,8 +44,8 @@ describe ::Protobuf::CLI do
44
44
  let(:test_args) { [ '--port=12345' ] }
45
45
 
46
46
  it 'sends the port option to the runner' do
47
- ::Protobuf::Rpc::SocketRunner.should_receive(:new) do |options|
48
- options[:port].should eq 12345
47
+ expect(::Protobuf::Rpc::SocketRunner).to receive(:new) do |options|
48
+ expect(options[:port]).to eq 12345
49
49
  end.and_return(sock_runner)
50
50
  described_class.start(args)
51
51
  end
@@ -55,8 +55,8 @@ describe ::Protobuf::CLI do
55
55
  let(:test_args) { [ '--threads=500' ] }
56
56
 
57
57
  it 'sends the threads option to the runner' do
58
- ::Protobuf::Rpc::SocketRunner.should_receive(:new) do |options|
59
- options[:threads].should eq 500
58
+ expect(::Protobuf::Rpc::SocketRunner).to receive(:new) do |options|
59
+ expect(options[:threads]).to eq 500
60
60
  end.and_return(sock_runner)
61
61
  described_class.start(args)
62
62
  end
@@ -66,8 +66,8 @@ describe ::Protobuf::CLI do
66
66
  let(:test_args) { [ '--backlog=500' ] }
67
67
 
68
68
  it 'sends the backlog option to the runner' do
69
- ::Protobuf::Rpc::SocketRunner.should_receive(:new) do |options|
70
- options[:backlog].should eq 500
69
+ expect(::Protobuf::Rpc::SocketRunner).to receive(:new) do |options|
70
+ expect(options[:backlog]).to eq 500
71
71
  end.and_return(sock_runner)
72
72
  described_class.start(args)
73
73
  end
@@ -77,8 +77,8 @@ describe ::Protobuf::CLI do
77
77
  let(:test_args) { [ '--threshold=500' ] }
78
78
 
79
79
  it 'sends the backlog option to the runner' do
80
- ::Protobuf::Rpc::SocketRunner.should_receive(:new) do |options|
81
- options[:threshold].should eq 500
80
+ expect(::Protobuf::Rpc::SocketRunner).to receive(:new) do |options|
81
+ expect(options[:threshold]).to eq 500
82
82
  end.and_return(sock_runner)
83
83
  described_class.start(args)
84
84
  end
@@ -88,9 +88,9 @@ describe ::Protobuf::CLI do
88
88
  let(:test_args) { [ '--log=mylog.log', '--level=0' ] }
89
89
 
90
90
  it 'sends the log file and level options to the runner' do
91
- ::Protobuf::Logger.should_receive(:configure) do |options|
92
- options[:file].should eq 'mylog.log'
93
- options[:level].should eq 0
91
+ expect(::Protobuf::Logger).to receive(:configure) do |options|
92
+ expect(options[:file]).to eq 'mylog.log'
93
+ expect(options[:level]).to eq 0
94
94
  end
95
95
  described_class.start(args)
96
96
  end
@@ -103,7 +103,7 @@ describe ::Protobuf::CLI do
103
103
 
104
104
  it 'sets both request and serialization pausing to false' do
105
105
  described_class.start(args)
106
- ::Protobuf.should_not be_gc_pause_server_request
106
+ expect(::Protobuf).to_not be_gc_pause_server_request
107
107
  end
108
108
  end
109
109
 
@@ -113,7 +113,7 @@ describe ::Protobuf::CLI do
113
113
 
114
114
  it 'sets the configuration option to GC pause server request' do
115
115
  described_class.start(args)
116
- ::Protobuf.should be_gc_pause_server_request
116
+ expect(::Protobuf).to be_gc_pause_server_request
117
117
  end
118
118
  end
119
119
  end
@@ -128,7 +128,7 @@ describe ::Protobuf::CLI do
128
128
 
129
129
  it 'sets the deprecation warning flag to true' do
130
130
  described_class.start(args)
131
- ::Protobuf.print_deprecation_warnings?.should be_true
131
+ expect(::Protobuf.print_deprecation_warnings?).to be_truthy
132
132
  end
133
133
  end
134
134
 
@@ -138,7 +138,7 @@ describe ::Protobuf::CLI do
138
138
 
139
139
  it 'sets the deprecation warning flag to false ' do
140
140
  described_class.start(args)
141
- ::Protobuf.print_deprecation_warnings?.should be_false
141
+ expect(::Protobuf.print_deprecation_warnings?).to be_falsey
142
142
  end
143
143
  end
144
144
  end
@@ -148,7 +148,7 @@ describe ::Protobuf::CLI do
148
148
 
149
149
  it 'sets the deprecation warning flag to true' do
150
150
  described_class.start(args)
151
- ::Protobuf.print_deprecation_warnings?.should be_true
151
+ expect(::Protobuf.print_deprecation_warnings?).to be_truthy
152
152
  end
153
153
  end
154
154
 
@@ -157,7 +157,7 @@ describe ::Protobuf::CLI do
157
157
 
158
158
  it 'sets the deprecation warning flag to false' do
159
159
  described_class.start(args)
160
- ::Protobuf.print_deprecation_warnings?.should be_false
160
+ expect(::Protobuf.print_deprecation_warnings?).to be_falsey
161
161
  end
162
162
  end
163
163
  end
@@ -169,24 +169,24 @@ describe ::Protobuf::CLI do
169
169
  let(:runner) { ::Protobuf::Rpc::SocketRunner }
170
170
 
171
171
  before do
172
- ::Protobuf::Rpc::ZmqRunner.should_not_receive(:new)
172
+ expect(::Protobuf::Rpc::ZmqRunner).not_to receive(:new)
173
173
  end
174
174
 
175
175
  it 'is activated by the --socket switch' do
176
- runner.should_receive(:new)
176
+ expect(runner).to receive(:new)
177
177
  described_class.start(args)
178
178
  end
179
179
 
180
180
  it 'is activated by PB_SERVER_TYPE=Socket ENV variable' do
181
181
  ENV['PB_SERVER_TYPE'] = "Socket"
182
- runner.should_receive(:new).and_return(sock_runner)
182
+ expect(runner).to receive(:new).and_return(sock_runner)
183
183
  described_class.start(args)
184
184
  ENV.delete('PB_SERVER_TYPE')
185
185
  end
186
186
 
187
187
  it 'configures the connector type to be socket' do
188
188
  load "protobuf/socket.rb"
189
- ::Protobuf.connector_type.should == :socket
189
+ expect(::Protobuf.connector_type).to eq(:socket)
190
190
  end
191
191
  end
192
192
 
@@ -195,12 +195,12 @@ describe ::Protobuf::CLI do
195
195
  let(:runner) { ::Protobuf::Rpc::ZmqRunner }
196
196
 
197
197
  before do
198
- ::Protobuf::Rpc::SocketRunner.should_not_receive(:new)
198
+ expect(::Protobuf::Rpc::SocketRunner).not_to receive(:new)
199
199
  end
200
200
 
201
201
  it 'is activated by the --workers_only switch' do
202
- runner.should_receive(:new) do |options|
203
- options[:workers_only].should be_true
202
+ expect(runner).to receive(:new) do |options|
203
+ expect(options[:workers_only]).to be_truthy
204
204
  end.and_return(zmq_runner)
205
205
 
206
206
  described_class.start(args)
@@ -208,8 +208,8 @@ describe ::Protobuf::CLI do
208
208
 
209
209
  it 'is activated by PB_WORKERS_ONLY=1 ENV variable' do
210
210
  ENV['PB_WORKERS_ONLY'] = "1"
211
- runner.should_receive(:new) do |options|
212
- options[:workers_only].should be_true
211
+ expect(runner).to receive(:new) do |options|
212
+ expect(options[:workers_only]).to be_truthy
213
213
  end.and_return(zmq_runner)
214
214
 
215
215
  described_class.start(args)
@@ -222,12 +222,12 @@ describe ::Protobuf::CLI do
222
222
  let(:runner) { ::Protobuf::Rpc::ZmqRunner }
223
223
 
224
224
  before do
225
- ::Protobuf::Rpc::SocketRunner.should_not_receive(:new)
225
+ expect(::Protobuf::Rpc::SocketRunner).not_to receive(:new)
226
226
  end
227
227
 
228
228
  it 'is activated by the --worker_port switch' do
229
- runner.should_receive(:new) do |options|
230
- options[:worker_port].should eq(1234)
229
+ expect(runner).to receive(:new) do |options|
230
+ expect(options[:worker_port]).to eq(1234)
231
231
  end.and_return(zmq_runner)
232
232
 
233
233
  described_class.start(args)
@@ -239,24 +239,24 @@ describe ::Protobuf::CLI do
239
239
  let(:runner) { ::Protobuf::Rpc::ZmqRunner }
240
240
 
241
241
  before do
242
- ::Protobuf::Rpc::SocketRunner.should_not_receive(:new)
242
+ expect(::Protobuf::Rpc::SocketRunner).not_to receive(:new)
243
243
  end
244
244
 
245
245
  it 'is activated by the --zmq switch' do
246
- runner.should_receive(:new)
246
+ expect(runner).to receive(:new)
247
247
  described_class.start(args)
248
248
  end
249
249
 
250
250
  it 'is activated by PB_SERVER_TYPE=Zmq ENV variable' do
251
251
  ENV['PB_SERVER_TYPE'] = "Zmq"
252
- runner.should_receive(:new)
252
+ expect(runner).to receive(:new)
253
253
  described_class.start(args)
254
254
  ENV.delete('PB_SERVER_TYPE')
255
255
  end
256
256
 
257
257
  it 'configures the connector type to be zmq' do
258
258
  load "protobuf/zmq.rb"
259
- ::Protobuf.connector_type.should == :zmq
259
+ expect(::Protobuf.connector_type).to eq(:zmq)
260
260
  end
261
261
  end
262
262