-
Notifications
You must be signed in to change notification settings - Fork 1
/
grpc_client_spec.rb
38 lines (31 loc) · 1.09 KB
/
grpc_client_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# frozen_string_literal: true
require "sbmt/pact/rspec"
RSpec.describe "Sbmt::Pact::Providers::Test::GrpcClient", :pact do
has_grpc_pact_between "sbmt-pact-test-app", "sbmt-pact-test-app"
let(:pet_id) { 123 }
let(:api) { ::PetStore::Grpc::PetStore::V1::Pets::Stub.new("127.0.0.1:3009", :this_channel_is_insecure) }
let(:make_request) { api.pet_by_id(PetStore::Grpc::PetStore::V1::PetByIdRequest.new(id: pet_id)) }
let(:interaction) do
new_interaction
.with_service("spec/internal/deps/services/pet_store/grpc/pet_store.proto", "Pets/PetById")
end
context "with Pets/PetById" do
context "with successful interaction" do
let(:interaction) do
super()
.given("pet exists", pet_id: pet_id)
.with_request(id: match_any_integer(pet_id))
.with_response(
pet: {
id: match_any_integer, name: match_any_string
}
)
end
it "executes the pact test without errors" do
interaction.execute do
expect { make_request }.not_to raise_error
end
end
end
end
end