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
@@ -21,28 +21,28 @@ describe Protobuf::Rpc::Connectors::Base do
21
21
 
22
22
  describe '.new' do
23
23
  it 'assigns passed options and initializes success/failure callbacks' do
24
- subject.options.should eq(Protobuf::Rpc::Connectors::DEFAULT_OPTIONS.merge(options))
25
- subject.success_cb.should be_nil
26
- subject.failure_cb.should be_nil
24
+ expect(subject.options).to eq(Protobuf::Rpc::Connectors::DEFAULT_OPTIONS.merge(options))
25
+ expect(subject.success_cb).to be_nil
26
+ expect(subject.failure_cb).to be_nil
27
27
  end
28
28
  end
29
29
 
30
30
  describe '#success_cb' do
31
31
  it 'allows setting the success callback and calling it' do
32
- subject.success_cb.should be_nil
32
+ expect(subject.success_cb).to be_nil
33
33
  cb = proc {|res| raise res }
34
34
  subject.success_cb = cb
35
- subject.success_cb.should eq(cb)
35
+ expect(subject.success_cb).to eq(cb)
36
36
  expect { subject.success_cb.call('an error from cb') }.to raise_error 'an error from cb'
37
37
  end
38
38
  end
39
39
 
40
40
  describe '#failure_cb' do
41
41
  it 'allows setting the failure callback and calling it' do
42
- subject.failure_cb.should be_nil
42
+ expect(subject.failure_cb).to be_nil
43
43
  cb = proc {|res| raise res }
44
44
  subject.failure_cb = cb
45
- subject.failure_cb.should eq(cb)
45
+ expect(subject.failure_cb).to eq(cb)
46
46
  expect { subject.failure_cb.call('an error from cb') }.to raise_error 'an error from cb'
47
47
  end
48
48
  end
@@ -15,15 +15,15 @@ describe Protobuf::Rpc::Connectors::Common do
15
15
  subject { @subject ||= common_class.new(subject_options) }
16
16
 
17
17
  context "API" do
18
- specify { subject.respond_to?(:any_callbacks?).should be_true }
19
- specify { subject.respond_to?(:request_caller).should be_true }
20
- specify { subject.respond_to?(:data_callback).should be_true }
21
- specify { subject.respond_to?(:error).should be_true }
22
- specify { subject.respond_to?(:fail).should be_true }
23
- specify { subject.respond_to?(:complete).should be_true }
24
- specify { subject.respond_to?(:parse_response).should be_true }
25
- specify { subject.respond_to?(:verify_options!).should be_true }
26
- specify { subject.respond_to?(:verify_callbacks).should be_true }
18
+ specify { expect(subject.respond_to?(:any_callbacks?)).to be_truthy }
19
+ specify { expect(subject.respond_to?(:request_caller)).to be_truthy }
20
+ specify { expect(subject.respond_to?(:data_callback)).to be_truthy }
21
+ specify { expect(subject.respond_to?(:error)).to be_truthy }
22
+ specify { expect(subject.respond_to?(:fail)).to be_truthy }
23
+ specify { expect(subject.respond_to?(:complete)).to be_truthy }
24
+ specify { expect(subject.respond_to?(:parse_response)).to be_truthy }
25
+ specify { expect(subject.respond_to?(:verify_options!)).to be_truthy }
26
+ specify { expect(subject.respond_to?(:verify_callbacks)).to be_truthy }
27
27
  end
28
28
 
29
29
  describe "#any_callbacks?" do
@@ -31,7 +31,7 @@ describe Protobuf::Rpc::Connectors::Common do
31
31
  [:@complete_cb, :@success_cb, :@failure_cb].each do |cb|
32
32
  it "returns true if #{cb} is provided" do
33
33
  subject.instance_variable_set(cb, "something")
34
- subject.any_callbacks?.should be_true
34
+ expect(subject.any_callbacks?).to be_truthy
35
35
  end
36
36
  end
37
37
 
@@ -40,32 +40,32 @@ describe Protobuf::Rpc::Connectors::Common do
40
40
  subject.instance_variable_set(:@success_cb, nil)
41
41
  subject.instance_variable_set(:@failure_cb, nil)
42
42
 
43
- subject.any_callbacks?.should be_false
43
+ expect(subject.any_callbacks?).to be_falsey
44
44
  end
45
45
 
46
46
  end
47
47
 
48
48
  describe '#request_caller' do
49
- its(:request_caller) { should eq ::Protobuf.client_host }
49
+ specify { expect(subject.request_caller).to eq ::Protobuf.client_host }
50
50
 
51
51
  context 'when "client_host" option is given to initializer' do
52
52
  let(:hostname) { 'myhost.myserver.com' }
53
53
  let(:subject_options) { { :client_host => hostname } }
54
54
 
55
- its(:request_caller) { should_not eq ::Protobuf.client_host }
56
- its(:request_caller) { should eq hostname }
55
+ specify { expect(subject.request_caller).to_not eq ::Protobuf.client_host }
56
+ specify { expect(subject.request_caller).to eq hostname }
57
57
  end
58
58
  end
59
59
 
60
60
  describe "#data_callback" do
61
61
  it "changes state to use the data callback" do
62
62
  subject.data_callback("data")
63
- subject.instance_variable_get(:@used_data_callback).should be_true
63
+ expect(subject.instance_variable_get(:@used_data_callback)).to be_truthy
64
64
  end
65
65
 
66
66
  it "sets the data var when using the data_callback" do
67
67
  subject.data_callback("data")
68
- subject.instance_variable_get(:@data).should eq("data")
68
+ expect(subject.instance_variable_get(:@data)).to eq("data")
69
69
  end
70
70
  end
71
71
 
@@ -84,38 +84,38 @@ describe Protobuf::Rpc::Connectors::Common do
84
84
  :request_proto => '',
85
85
  :caller => client_host }) }
86
86
 
87
- before { subject.stub(:validate_request_type!).and_return(true) }
88
- before { subject.should_not_receive(:fail) }
87
+ before { allow(subject).to receive(:validate_request_type!).and_return(true) }
88
+ before { expect(subject).not_to receive(:fail) }
89
89
 
90
- its(:request_bytes) { should eq expected.encode }
90
+ specify { expect(subject.request_bytes).to eq expected.encode }
91
91
  end
92
92
 
93
93
  describe "#verify_callbacks" do
94
94
 
95
95
  it "sets @failure_cb to #data_callback when no callbacks are defined" do
96
96
  subject.verify_callbacks
97
- subject.instance_variable_get(:@failure_cb).should eq(subject.method(:data_callback))
97
+ expect(subject.instance_variable_get(:@failure_cb)).to eq(subject.method(:data_callback))
98
98
  end
99
99
 
100
100
  it "sets @success_cb to #data_callback when no callbacks are defined" do
101
101
  subject.verify_callbacks
102
- subject.instance_variable_get(:@success_cb).should eq(subject.method(:data_callback))
102
+ expect(subject.instance_variable_get(:@success_cb)).to eq(subject.method(:data_callback))
103
103
  end
104
104
 
105
105
  it "doesn't set @failure_cb when already defined" do
106
106
  set_cb = lambda{ true }
107
107
  subject.instance_variable_set(:@failure_cb, set_cb)
108
108
  subject.verify_callbacks
109
- subject.instance_variable_get(:@failure_cb).should eq(set_cb)
110
- subject.instance_variable_get(:@failure_cb).should_not eq(subject.method(:data_callback))
109
+ expect(subject.instance_variable_get(:@failure_cb)).to eq(set_cb)
110
+ expect(subject.instance_variable_get(:@failure_cb)).to_not eq(subject.method(:data_callback))
111
111
  end
112
112
 
113
113
  it "doesn't set @success_cb when already defined" do
114
114
  set_cb = lambda{ true }
115
115
  subject.instance_variable_set(:@success_cb, set_cb)
116
116
  subject.verify_callbacks
117
- subject.instance_variable_get(:@success_cb).should eq(set_cb)
118
- subject.instance_variable_get(:@success_cb).should_not eq(subject.method(:data_callback))
117
+ expect(subject.instance_variable_get(:@success_cb)).to eq(set_cb)
118
+ expect(subject.instance_variable_get(:@success_cb)).to_not eq(subject.method(:data_callback))
119
119
  end
120
120
 
121
121
  end
@@ -123,33 +123,31 @@ describe Protobuf::Rpc::Connectors::Common do
123
123
  shared_examples "a ConnectorDisposition" do |meth, cb, *args|
124
124
 
125
125
  it "calls #complete before exit" do
126
- stats = double("Object")
127
- stats.stub(:stop) { true }
128
- subject.stats = stats
126
+ subject.stats = double("Object", :stop => true)
129
127
 
130
- subject.should_receive(:complete)
128
+ expect(subject).to receive(:complete)
131
129
  subject.method(meth).call(*args)
132
130
  end
133
131
 
134
132
  it "calls the #{cb} callback when provided" do
135
133
  stats = double("Object")
136
- stats.stub(:stop) { true }
134
+ allow(stats).to receive(:stop).and_return(true)
137
135
  subject.stats = stats
138
136
  _cb = double("Object")
139
137
 
140
138
  subject.instance_variable_set("@#{cb}", _cb)
141
- _cb.should_receive(:call).and_return(true)
139
+ expect(_cb).to receive(:call).and_return(true)
142
140
  subject.method(meth).call(*args)
143
141
  end
144
142
 
145
143
  it "calls the complete callback when provided" do
146
144
  stats = double("Object")
147
- stats.stub(:stop) { true }
145
+ allow(stats).to receive(:stop).and_return(true)
148
146
  subject.stats = stats
149
147
  comp_cb = double("Object")
150
148
 
151
149
  subject.instance_variable_set(:@complete_cb, comp_cb)
152
- comp_cb.should_receive(:call).and_return(true)
150
+ expect(comp_cb).to receive(:call).and_return(true)
153
151
  subject.method(meth).call(*args)
154
152
  end
155
153
 
@@ -6,10 +6,10 @@ shared_examples "a Protobuf Connector" do
6
6
 
7
7
  context "API" do
8
8
  # Check the API
9
- specify{ subject.respond_to?(:send_request, true).should be_true }
10
- specify{ subject.respond_to?(:post_init, true).should be_true }
11
- specify{ subject.respond_to?(:close_connection, true).should be_true }
12
- specify{ subject.respond_to?(:error?, true).should be_true }
9
+ specify { expect(subject.respond_to?(:send_request, true)).to be_truthy }
10
+ specify { expect(subject.respond_to?(:post_init, true)).to be_truthy }
11
+ specify { expect(subject.respond_to?(:close_connection, true)).to be_truthy }
12
+ specify { expect(subject.respond_to?(:error?, true)).to be_truthy }
13
13
  end
14
14
  end
15
15
 
@@ -18,19 +18,19 @@ describe Protobuf::Rpc::Connectors::Socket do
18
18
 
19
19
  it_behaves_like "a Protobuf Connector"
20
20
 
21
- specify{ described_class.include?(Protobuf::Rpc::Connectors::Common).should be_true }
21
+ specify { expect(described_class.include?(Protobuf::Rpc::Connectors::Common)).to be_truthy }
22
22
 
23
23
  context "#read_response" do
24
- let(:data){ "New data" }
24
+ let(:data) { "New data" }
25
25
 
26
26
  it "fills the buffer with data from the socket" do
27
27
  socket = StringIO.new("#{data.bytesize}-#{data}")
28
28
  subject.instance_variable_set(:@socket, socket)
29
29
  subject.instance_variable_set(:@stats, OpenStruct.new)
30
- subject.should_receive(:parse_response).and_return(true)
30
+ expect(subject).to receive(:parse_response).and_return(true)
31
31
 
32
32
  subject.__send__(:read_response)
33
- subject.instance_variable_get(:@response_data).should eq(data)
33
+ expect(subject.instance_variable_get(:@response_data)).to eq(data)
34
34
  end
35
35
  end
36
36
  end
@@ -12,20 +12,11 @@ describe ::Protobuf::Rpc::Connectors::Zmq do
12
12
  :port => "9400"
13
13
  }}
14
14
 
15
- let(:socket_double) do
16
- sm = double(::ZMQ::Socket)
17
- sm.stub(:connect).and_return(0)
18
- sm
19
- end
20
-
21
- let(:zmq_context_double) do
22
- zc = double(::ZMQ::Context)
23
- zc.stub(:socket).and_return(socket_double)
24
- zc
25
- end
15
+ let(:socket_double) { double(::ZMQ::Socket, :connect => 0) }
16
+ let(:zmq_context_double) { double(::ZMQ::Context, :socket => socket_double) }
26
17
 
27
18
  before do
28
- ::ZMQ::Context.stub(:new).and_return(zmq_context_double)
19
+ allow(::ZMQ::Context).to receive(:new).and_return(zmq_context_double)
29
20
  end
30
21
 
31
22
  before(:all) do
@@ -42,19 +33,17 @@ describe ::Protobuf::Rpc::Connectors::Zmq do
42
33
  let(:listings) { [listing] }
43
34
  let(:running?) { true }
44
35
 
45
- before do
46
- subject.stub(:service_directory) { service_directory }
47
- end
36
+ before { allow(subject).to receive(:service_directory).and_return(service_directory) }
48
37
 
49
38
  context "when the service directory is running" do
50
39
  it "searches the service directory" do
51
- service_directory.stub(:all_listings_for).and_return(listings)
52
- subject.send(:lookup_server_uri).should eq "tcp://127.0.0.2:9399"
40
+ allow(service_directory).to receive(:all_listings_for).and_return(listings)
41
+ expect(subject.send(:lookup_server_uri)).to eq "tcp://127.0.0.2:9399"
53
42
  end
54
43
 
55
44
  it "defaults to the options" do
56
- service_directory.stub(:all_listings_for).and_return([])
57
- subject.send(:lookup_server_uri).should eq "tcp://127.0.0.1:9400"
45
+ allow(service_directory).to receive(:all_listings_for).and_return([])
46
+ expect(subject.send(:lookup_server_uri)).to eq "tcp://127.0.0.1:9400"
58
47
  end
59
48
  end
60
49
 
@@ -62,21 +51,21 @@ describe ::Protobuf::Rpc::Connectors::Zmq do
62
51
  let(:running?) { false }
63
52
 
64
53
  it "defaults to the options" do
65
- service_directory.stub(:all_listings_for).and_return([])
66
- subject.send(:lookup_server_uri).should eq "tcp://127.0.0.1:9400"
54
+ allow(service_directory).to receive(:all_listings_for).and_return([])
55
+ expect(subject.send(:lookup_server_uri)).to eq "tcp://127.0.0.1:9400"
67
56
  end
68
57
  end
69
58
 
70
59
  it "checks if the server is alive" do
71
- service_directory.stub(:all_listings_for).and_return([])
72
- subject.should_receive(:host_alive?).with("127.0.0.1") { true }
73
- subject.send(:lookup_server_uri).should eq "tcp://127.0.0.1:9400"
60
+ allow(service_directory).to receive(:all_listings_for).and_return([])
61
+ expect(subject).to receive(:host_alive?).with("127.0.0.1") { true }
62
+ expect(subject.send(:lookup_server_uri)).to eq "tcp://127.0.0.1:9400"
74
63
  end
75
64
 
76
65
  context "when no host is alive" do
77
66
  it "raises an error" do
78
- service_directory.stub(:all_listings_for).and_return(listings)
79
- subject.stub(:host_alive?).and_return(false)
67
+ allow(service_directory).to receive(:all_listings_for).and_return(listings)
68
+ allow(subject).to receive(:host_alive?).and_return(false)
80
69
  expect { subject.send(:lookup_server_uri) }.to raise_error
81
70
  end
82
71
  end
@@ -90,11 +79,11 @@ describe ::Protobuf::Rpc::Connectors::Zmq do
90
79
  end
91
80
 
92
81
  it "returns true" do
93
- subject.send(:host_alive?, "yip.yip").should be_true
82
+ expect(subject.send(:host_alive?, "yip.yip")).to be_truthy
94
83
  end
95
84
 
96
85
  it "does not attempt a connection" do
97
- TCPSocket.should_not_receive(:new)
86
+ expect(TCPSocket).not_to receive(:new)
98
87
  subject.send(:host_alive?, "blargh.com")
99
88
  end
100
89
  end
@@ -105,20 +94,20 @@ describe ::Protobuf::Rpc::Connectors::Zmq do
105
94
  end
106
95
 
107
96
  it "returns true when the connection succeeds" do
108
- TCPSocket.should_receive(:new).with("huzzah.com", 3307) { double(:close => nil) }
109
- subject.send(:host_alive?, "huzzah.com").should be_true
97
+ expect(TCPSocket).to receive(:new).with("huzzah.com", 3307).and_return(double(:close => nil))
98
+ expect(subject.send(:host_alive?, "huzzah.com")).to be_truthy
110
99
  end
111
100
 
112
101
  it "returns false when the connection fails" do
113
- TCPSocket.should_receive(:new).with("hayoob.com", 3307).and_raise(Errno::ECONNREFUSED)
114
- subject.send(:host_alive?, "hayoob.com").should be_false
102
+ expect(TCPSocket).to receive(:new).with("hayoob.com", 3307).and_raise(Errno::ECONNREFUSED)
103
+ expect(subject.send(:host_alive?, "hayoob.com")).to be_falsey
115
104
  end
116
105
 
117
106
  it "closes the socket" do
118
107
  socket = double("TCPSocket")
119
- socket.should_receive(:close)
120
- TCPSocket.should_receive(:new).with("absorbalof.com", 3307) { socket }
121
- subject.send(:host_alive?, "absorbalof.com").should be_true
108
+ expect(socket).to receive(:close)
109
+ expect(TCPSocket).to receive(:new).with("absorbalof.com", 3307).and_return(socket)
110
+ expect(subject.send(:host_alive?, "absorbalof.com")).to be_truthy
122
111
  end
123
112
  end
124
113
  end
@@ -8,19 +8,19 @@ describe Protobuf::Rpc::Middleware::ExceptionHandler do
8
8
 
9
9
  describe "#call" do
10
10
  it "calls the stack" do
11
- app.should_receive(:call).with(env)
11
+ expect(app).to receive(:call).with(env)
12
12
  subject.call(env)
13
13
  end
14
14
 
15
15
  it "returns the env" do
16
- subject.call(env).should eq env
16
+ expect(subject.call(env)).to eq env
17
17
  end
18
18
 
19
19
  context "when exceptions occur" do
20
20
  let(:encoded_error) { error.encode }
21
21
  let(:error) { Protobuf::Rpc::MethodNotFound.new('Boom!') }
22
22
 
23
- before { app.stub(:call).and_raise(error, 'Boom!') }
23
+ before { allow(app).to receive(:call).and_raise(error, 'Boom!') }
24
24
 
25
25
  it "rescues exceptions" do
26
26
  expect { subject.call(env) }.not_to raise_exception
@@ -32,12 +32,12 @@ describe Protobuf::Rpc::Middleware::ExceptionHandler do
32
32
 
33
33
  # Can't compare the error instances because the response has been
34
34
  # raised and thus has a backtrace while the error does not.
35
- stack_env.response.class.should eq error.class
35
+ expect(stack_env.response.class).to eq error.class
36
36
  end
37
37
 
38
38
  it "encodes the response" do
39
39
  stack_env = subject.call(env)
40
- stack_env.encoded_response.should eq encoded_error
40
+ expect(stack_env.encoded_response).to eq encoded_error
41
41
  end
42
42
  end
43
43
 
@@ -45,16 +45,16 @@ describe Protobuf::Rpc::Middleware::ExceptionHandler do
45
45
  let(:encoded_error) { error.encode }
46
46
  let(:error) { Protobuf::Rpc::RpcFailed.new('Boom!') }
47
47
 
48
- before { app.stub(:call).and_raise(RuntimeError, 'Boom!') }
48
+ before { allow(app).to receive(:call).and_raise(RuntimeError, 'Boom!') }
49
49
 
50
50
  it "wraps the exception in a generic Protobuf error" do
51
51
  stack_env = subject.call(env)
52
- stack_env.response.should eq error
52
+ expect(stack_env.response).to eq error
53
53
  end
54
54
 
55
55
  it "encodes the wrapped exception" do
56
56
  stack_env = subject.call(env)
57
- stack_env.encoded_response.should eq encoded_error
57
+ expect(stack_env.encoded_response).to eq encoded_error
58
58
  end
59
59
  end
60
60
  end
@@ -38,12 +38,12 @@ describe Protobuf::Rpc::Middleware::Logger do
38
38
 
39
39
  describe "#call" do
40
40
  it "calls the stack" do
41
- app.should_receive(:call).with(env)
41
+ expect(app).to receive(:call).with(env).and_return(env)
42
42
  subject.call(env)
43
43
  end
44
44
 
45
45
  it "returns the env" do
46
- subject.call(env).should eq env
46
+ expect(subject.call(env)).to eq env
47
47
  end
48
48
  end
49
49
  end
@@ -31,51 +31,51 @@ describe Protobuf::Rpc::Middleware::RequestDecoder do
31
31
  describe "#call" do
32
32
  it "decodes the request" do
33
33
  stack_env = subject.call(env)
34
- stack_env.request.should eq request
34
+ expect(stack_env.request).to eq request
35
35
  end
36
36
 
37
37
  it "calls the stack" do
38
- app.should_receive(:call).with(env)
38
+ expect(app).to receive(:call).with(env)
39
39
  subject.call(env)
40
40
  end
41
41
 
42
42
  it "sets Env#client_host" do
43
43
  stack_env = subject.call(env)
44
- stack_env.client_host.should eq client_host
44
+ expect(stack_env.client_host).to eq client_host
45
45
  end
46
46
 
47
47
  it "sets Env#service_name" do
48
48
  stack_env = subject.call(env)
49
- stack_env.service_name.should eq service_name
49
+ expect(stack_env.service_name).to eq service_name
50
50
  end
51
51
 
52
52
  it "sets Env#method_name" do
53
53
  stack_env = subject.call(env)
54
- stack_env.method_name.should eq method_name.to_sym
54
+ expect(stack_env.method_name).to eq method_name.to_sym
55
55
  end
56
56
 
57
57
  it "sets Env#request_type" do
58
58
  stack_env = subject.call(env)
59
- stack_env.request_type.should eq request_type
59
+ expect(stack_env.request_type).to eq request_type
60
60
  end
61
61
 
62
62
  it "sets Env#response_type" do
63
63
  stack_env = subject.call(env)
64
- stack_env.response_type.should eq response_type
64
+ expect(stack_env.response_type).to eq response_type
65
65
  end
66
66
 
67
67
  it "sets Env#rpc_method" do
68
68
  stack_env = subject.call(env)
69
- stack_env.rpc_method.should eq rpc_method
69
+ expect(stack_env.rpc_method).to eq rpc_method
70
70
  end
71
71
 
72
72
  it "sets Env#rpc_service" do
73
73
  stack_env = subject.call(env)
74
- stack_env.rpc_service.should eq rpc_service
74
+ expect(stack_env.rpc_service).to eq rpc_service
75
75
  end
76
76
 
77
77
  context "when decoding fails" do
78
- before { Protobuf::Socketrpc::Request.stub(:decode).and_raise(RuntimeError) }
78
+ before { allow(Protobuf::Socketrpc::Request).to receive(:decode).and_raise(RuntimeError) }
79
79
 
80
80
  it "raises a bad request data exception" do
81
81
  expect { subject.call(env) }.to raise_exception(Protobuf::Rpc::BadRequestData)