|
|
@ -273,73 +273,4 @@ describe GenericService do |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
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 |
|
|
|
|
|
|
|
rpc :AnRpc, GoodMsg, GoodMsg |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
expect { c1.assert_rpc_descs_have_methods }.to raise_error |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
c2 = Class.new do |
|
|
|
|
|
|
|
include GenericService |
|
|
|
|
|
|
|
rpc :AnRpc, GoodMsg, GoodMsg |
|
|
|
|
|
|
|
rpc :AnotherRpc, GoodMsg, GoodMsg |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def an_rpc |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
expect { c2.assert_rpc_descs_have_methods }.to raise_error |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it 'passes if there are corresponding methods for each descriptor' do |
|
|
|
|
|
|
|
c = Class.new do |
|
|
|
|
|
|
|
include GenericService |
|
|
|
|
|
|
|
rpc :AnRpc, GoodMsg, GoodMsg |
|
|
|
|
|
|
|
rpc :AServerStreamer, GoodMsg, stream(GoodMsg) |
|
|
|
|
|
|
|
rpc :AClientStreamer, stream(GoodMsg), GoodMsg |
|
|
|
|
|
|
|
rpc :ABidiStreamer, stream(GoodMsg), stream(GoodMsg) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def an_rpc(_req, _call) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def a_server_streamer(_req, _call) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def a_client_streamer(_call) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def a_bidi_streamer(_call) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
expect { c.assert_rpc_descs_have_methods }.to_not raise_error |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it 'passes for subclasses of that include GenericService' do |
|
|
|
|
|
|
|
base = Class.new do |
|
|
|
|
|
|
|
include GenericService |
|
|
|
|
|
|
|
rpc :AnRpc, GoodMsg, GoodMsg |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def an_rpc(_req, _call) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
c = Class.new(base) |
|
|
|
|
|
|
|
expect { c.assert_rpc_descs_have_methods }.to_not raise_error |
|
|
|
|
|
|
|
expect(c.include?(GenericService)).to be(true) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it 'passes if subclasses define the rpc methods' do |
|
|
|
|
|
|
|
base = Class.new do |
|
|
|
|
|
|
|
include GenericService |
|
|
|
|
|
|
|
rpc :AnRpc, GoodMsg, GoodMsg |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
c = Class.new(base) do |
|
|
|
|
|
|
|
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 |
|
|
|
end |
|
|
|